Created
November 13, 2015 16:07
-
-
Save tonyjoanes/e8a08c2a8d9266365ad0 to your computer and use it in GitHub Desktop.
Jasmine sample controller test spec
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
/// <reference path="../MvcAngularJasmineTests/Scripts/angular.js"/> | |
/// <reference path="../MvcAngularJasmineTests/Scripts/angular-route.js"/> | |
/// <reference path="Scripts/angular-mocks.js"/> | |
/// <reference path="../MvcAngularJasmineTests/Scripts/app/app.js"/> | |
/// <reference path="../MvcAngularJasmineTests/Scripts/home/home.controller.js"/> | |
/// <reference path="Scripts/jasmine/jasmine.js"/> | |
describe('When working with the home.controller', function () { | |
var sut; | |
beforeEach(module("SampleApp")); | |
beforeEach(inject(function ($controller) { | |
sut = $controller('HomeController'); | |
})); | |
describe('object definition tests', function () { | |
it('Should be defined', function () { | |
expect(sut).toBeDefined(); | |
}); | |
}); | |
function test(testCase) { | |
it(testCase.it, function () { | |
expect(sut[testCase.object]).toBeDefined(); | |
}); | |
} | |
var testCases = [ | |
{ it: 'Should define sampleText', object: 'sampleText' }, | |
{ it: 'Should define pageTitle', object: 'pageTitle' } | |
]; | |
describe('property definitions', function () { | |
angular.forEach(testCases, function (testCase) { | |
test(testCase); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment