blob: 05575cfc1341104846914e199402fd1e0ff389f1 [file] [log] [blame]
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 ONOS GUI -- Device Controller - Unit Tests
19
20 @author Simon Hunt
21 */
22describe('Controller: OvDeviceCtrl', function () {
23 // instantiate the Device module
24 beforeEach(module('ovDevice'));
25
26 var $log, $controller, ctrl, $mockHttp;
27
28 var fakeData = {
29 "devices": [
30 {
31 "id": "of:0000000000000001",
32 "available": true,
33 "role": "MASTER",
34 "mfr": "Nicira, Inc.",
35 "hw": "Open vSwitch",
36 "sw": "2.0.1",
37 "serial": "None",
38 "annotations": {
39 "protocol": "OF_10"
40 }
41 },
42 {
43 "id": "of:0000000000000004",
44 "available": true,
45 "role": "MASTER",
46 "mfr": "Nicira, Inc.",
47 "hw": "Open vSwitch",
48 "sw": "2.0.1",
49 "serial": "None",
50 "annotations": {
51 "protocol": "OF_10"
52 }
53 }]
54 };
55
56 // we need an instance of the controller
57 beforeEach(inject(function(_$log_, _$controller_, $httpBackend) {
58 $log = _$log_;
59 $controller = _$controller_;
60 $mockHttp = $httpBackend;
61
62 $mockHttp.whenGET(/devices/).respond(fakeData);
63
64 }));
65
66 //afterEach($mockHttp.resetExpectations);
67
68 it('should be an empty array', function () {
69 ctrl = $controller('OvDeviceCtrl');
70 expect(ctrl.deviceData).toEqual([]);
71 });
72
73 it('should have data in it', function () {
74 ctrl = $controller('OvDeviceCtrl');
75 $mockHttp.flush();
76 expect(ctrl.deviceData).toEqual(fakeData.devices);
77 })
78});