Last active
August 29, 2015 14:02
-
-
Save cpoDesign/37b602ec02b872c6368f to your computer and use it in GitHub Desktop.
Basic unit testing with angular - variable in controller
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
// for every module you include here, you need to add required resource files into your test file | |
var app = angular.module('app', ['ngSanitize', 'ngResource', 'ngRoute']); | |
// definition of controller | |
'use strict'; | |
app.controller('AdminCtr', | |
function AdminCtr() { | |
this.helpAndSupportText = 'Hello'; | |
}); | |
// unit test | |
/// <reference path="../../../angular.js" /> | |
/// <reference path="../../../angular-route.min.js" /> | |
/// <reference path="../../../angular-resource.js" /> | |
/// <reference path="../../../angular-sanitize.min.js" /> | |
/// <reference path="../../../angular-mocks.js" /> | |
/// <reference path="../../../app/app.js" /> | |
/// <reference path="../../../app/controllers/adminCtr.js" /> | |
'use strict'; | |
describe('adminCtrSpec', function () { | |
var adminCtr; | |
beforeEach(module("app")); | |
beforeEach(inject(function($controller) { | |
adminCtr = $controller("AdminCtr"); | |
})); | |
describe('AdminCtrl', function() { | |
it('should have a message hello', function() { | |
expect(adminCtr.helpAndSupportText).toBe("Hello"); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment