Created
March 31, 2016 17:31
-
-
Save stevermeister/014339d4f8630c1537d3cdf4fcf30d13 to your computer and use it in GitHub Desktop.
app-test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Calc', function() { | |
beforeEach(module('myApp')); | |
describe('service', function() { | |
it('should do sum', inject(function(Calc) { | |
expect(Calc.sum(3,4)).toBe(7); | |
})); | |
}); | |
describe('controller', function() { | |
var controller, Calc; | |
beforeEach(inject(function($controller, _Calc_) { | |
Calc = _Calc_; | |
spyOn(Calc, 'sum').and.returnValue(7); | |
controller = $controller('MainController', { Calc: Calc}); | |
})); | |
it('should call Calc service', function() { | |
controller.doCalculations(3, 4); | |
expect(Calc.sum).toHaveBeenCalled(); | |
}); | |
it('should set result', function() { | |
controller.doCalculations(3, 4); | |
expect(controller.result).toBe(7); | |
}); | |
}); | |
}); |
Author
stevermeister
commented
Mar 31, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment