blob: 132f522b90c8fcf85ce823b3fea719bcc4c74a2e [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
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080019 */
20describe('Controller: OvDeviceCtrl', function () {
21 // instantiate the Device module
Bri Prebilic Cole4fab8af2015-01-15 16:40:47 -080022 beforeEach(module('ovDevice', 'onosRemote'));
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080023
24 var $log, $controller, ctrl, $mockHttp;
25
26 var fakeData = {
Bri Prebilic Cole4fab8af2015-01-15 16:40:47 -080027 "devices": [{
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080028 "id": "of:0000000000000001",
29 "available": true,
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080030 "mfr": "Nicira, Inc.",
31 "hw": "Open vSwitch",
Bri Prebilic Cole4fab8af2015-01-15 16:40:47 -080032 "sw": "2.0.1"
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080033 },
34 {
35 "id": "of:0000000000000004",
36 "available": true,
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080037 "mfr": "Nicira, Inc.",
38 "hw": "Open vSwitch",
Bri Prebilic Cole4fab8af2015-01-15 16:40:47 -080039 "sw": "2.0.1"
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080040 }]
41 };
42
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080043 beforeEach(inject(function(_$log_, _$controller_, $httpBackend) {
44 $log = _$log_;
45 $controller = _$controller_;
46 $mockHttp = $httpBackend;
47
Bri Prebilic Cole4fab8af2015-01-15 16:40:47 -080048 $mockHttp.whenGET(/\/device$/).respond(fakeData);
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080049 }));
50
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080051 it('should be an empty array', function () {
52 ctrl = $controller('OvDeviceCtrl');
53 expect(ctrl.deviceData).toEqual([]);
Bri Prebilic Cole4fab8af2015-01-15 16:40:47 -080054 $mockHttp.flush();
55 expect(ctrl.deviceData).toEqual(fakeData.devices);
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080056 });
57
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080058});