Skip to content

Instantly share code, notes, and snippets.

@ewhitmore
Created November 17, 2013 22:35
Show Gist options
  • Save ewhitmore/7519178 to your computer and use it in GitHub Desktop.
Save ewhitmore/7519178 to your computer and use it in GitHub Desktop.
Visual Studio 2013 Jasmine/AngularJS Spec
/// <reference path="../../Scripts/jasmine/jasmine.js" />
/// <reference path="../../Scripts/angular.js" />
/// <reference path="../../Scripts/angular-mocks.js" />
/// <reference path="../../Scripts/angular-resource.js" />
/// <reference path="../../Scripts/angular-route.js" />
/// <reference path="../../Scripts/ui-bootstrap-tpls-0.6.0.js" />
/// <reference path="../app.js" />
/// <reference path="../DataEntry/DataEntryCtrl.js" />
describe("DataEntryCtrl", function () {
var $scope = null;
var $controller = null;
var $httpBackend = null;
beforeEach(function () {
module("app");
});
beforeEach(function () {// we need to use toEqualData because the Resource has extra properties
// which make simple .toEqual not work.
this.addMatchers({
toEqualData: function (expect) {
return angular.equals(expect, this.actual);
}
});
});
//you need to indicate your module in a test
// read: http://docs.angularjs.org/api/ngMock.$httpBackend
beforeEach(inject(function ($rootScope, _$controller_, _$httpBackend_) {
$scope = $rootScope.$new();
$controller = _$controller_;
$httpBackend = _$httpBackend_;
// Fake all my services
//$httpBackend.whenGET("api/location").respond([]);
//$httpBackend.whenGET("api/tuitionType").respond([]);
//$httpBackend.whenGET("api/cohort").respond([]);
//$httpBackend.whenGET("api/course").respond([]);
var ctrl = $controller('DataEntryCtrl', { $scope: $scope });
}));
// Actual Unit Tests
// Naming: Method_Scenario_ExpectedBehavior
it("oneEqualsOne_ReturnTrue", function () {
expect(1).toEqual(1);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment