Running the tests is a great way to minimize the number of bugs introduced in the application along with the new feature. Let's go ahead and test the implementation of the administrator page.
Like all other tests, we are testing our Angular controllers with the Mocha and Karma runners. Since we modified admin.controller.js
, we need to test that all is working as intended. Add this new file:
/* client/app/admin/admin.controller.spec.js */ describe('AdminCtrl', function() { beforeEach(module('meanshopApp')); var Product, User, $state, $controller, controller, $scope; var productAttributes = [ {_id: 1, title: 'Product1', price: 100.10, stock: 10}, {_id: 2, title: 'Product2', price: 200.00, stock: 20} ]; var userAttributes = [ {_id: 1, name: 'User1', email: '[email protected]', provider: 'local'}, {_id: 2, name: 'User2', email: '[email protected]', provider: 'facebook'} ]; beforeEach(inject(function (_$controller_, $rootScope...