lundi 24 août 2015

Should I mock ALL external Services in angular?

I'm currently getting started with angular unit testing. As the first controller I wanted to tes looked like this, I got confused.

angular.module('sgmPaperApp')
  .controller('AccountCtrl', function ($mdToast, user, $firebaseArray, Ref) {
var vm = this;
vm.data = user;
vm.save = saveUser;
vm.comments = $firebaseArray(Ref.child('comments').orderByChild('person').equalTo(user.$id));


function saveUser() {
  vm.data.$save().then(function () {
    $mdToast.showSimple('Data saved');
  });
}
});

Should I really mock all external services I use? After all that controller isn't very much more then external services and mocking the firebaseArray could be difficult.

Thanks for your advice and helping me get started with testing

Aucun commentaire:

Enregistrer un commentaire