Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe('Controller: TopologyCtrl', function () {
- beforeEach(angular.mock.module('myApp'));
- var scope, httpBackend, Restangular, createController;
- beforeEach(module(function ($urlRouterProvider) {
- $urlRouterProvider.deferIntercept();
- }));
- beforeEach(inject(function (_MyService_, $controller, $rootScope, _$httpBackend_, _Restangular_, _$q_) {
- Restangular = _Restangular_;
- httpBackend = _$httpBackend_;
- scope = $rootScope.$new();
- q = _$q_;
- createController = function () {
- $controller('MyCtrl', {
- $scope: scope
- });
- };
- });
- afterEach(function () {
- httpBackend.verifyNoOutstandingExpectation();
- httpBackend.verifyNoOutstandingRequest();
- });
- it('should edit a node', function() {
- createController();
- spyOn(Restangular, 'one').and.callThrough();
- scope['lists'][level].push(newFakeNode);
- expect(scope['lists'][level].length).toBe(1); // this expectation fulfilled when running test
- scope.editNode(7, 'bar');
- httpBackend.expectPUT('/nodes/7', JSON.stringify({name : 'foo'})).respond(200);
- httpBackend.flush();
- scope.$apply();
- expect(Restangular.one).toHaveBeenCalledWith('/nodes', 7);
- expect(scope['lists'][level].length).toBe(1); // expected 0 to be 1 since scope['lists'] equals [[], [], []] --> why?!
- expect(scope['lists'][level][0].name).toBe('foo');
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement