Template for Testing with Jasmine

Drop in your code, drop in your Jasmine specs, and away you go!

by ncapito

HTML

<script src="http://searls.github.com/jasmine-all/jasmine-all-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-mocks.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-resource.js"></script>

JavaScript

var mod = angular.module('test', ['ngResource']);

mod.factory('Course', function ($resource) {
    return  $resource('http://unboxed.com/:CourseID');;
});


describe("Course", function () {
    it("get() without course calls root", function () {
        $httpBackend.expectGET('http://unboxed.com').respond(200, {Test:'Nick was here'});

        var course = Course.get();
        $httpBackend.flush();
    });
    
      it("get() withid maps param and calls as id", function () {
        $httpBackend.expectGET('http://unboxed.com/1').respond(200, {});
        var briefs = Course.get({
            CourseID: 1
        });
        
        $httpBackend.flush();


    });


    beforeEach(function () {
        module('test');

        inject(function ($injector) {
            $httpBackend = $injector.get('$httpBackend');
            Course = $injector.get('Course');
        });

    });

    afterEach(function () {
        $httpBackend.verifyNoOutstandingExpectation();
        $httpBackend.verifyNoOutstandingRequest();
    });



});