aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/web/gui/src/test/webapp/_sdh/ng-examples/js/ch03-controllerSpec.js
blob: b2d4947be55ac66cfe2fc51b18a08027aafd7c11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Jasmine unit tests for ch03-controller.js

describe('Controller: ListCtrl', function () {
    // instantiate a new version of my module before each test
    beforeEach(module('notesApp'));

    var ctrl;

    // before each unit test, instantiate a new instance of the controller
    beforeEach(inject(function ($controller) {
        ctrl = $controller('ListCtrl');
    }));

    it('should have items available on load', function () {
        expect(ctrl.items).toEqual([
            {id: 1, label: 'First', done: true},
            {id: 2, label: 'Second', done: false}
        ]);
    });

    it('should have highlight items based on state', function () {
        var item = {id: 1, label: 'First', done: true};

        var actualClass = ctrl.getDoneClass(item);
        expect(actualClass.finished).toBeTruthy();
        expect(actualClass.unfinished).toBeFalsy();

        item.done = false;

        actualClass = ctrl.getDoneClass(item);
        expect(actualClass.finished).toBeFalsy();
        expect(actualClass.unfinished).toBeTruthy();
    });

});