blob: 503688a059a4d1b65db4d88cdd9b3aec9b42720e [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
Bri Prebilic Cole4fab8af2015-01-15 16:40:47 -080024 beforeEach(module('ovDevice', 'onosRemote'));
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080025
26 var $log, $controller, ctrl, $mockHttp;
27
28 var fakeData = {
Bri Prebilic Cole4fab8af2015-01-15 16:40:47 -080029 "devices": [{
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080030 "id": "of:0000000000000001",
31 "available": true,
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080032 "mfr": "Nicira, Inc.",
33 "hw": "Open vSwitch",
Bri Prebilic Cole4fab8af2015-01-15 16:40:47 -080034 "sw": "2.0.1"
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080035 },
36 {
37 "id": "of:0000000000000004",
38 "available": true,
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080039 "mfr": "Nicira, Inc.",
40 "hw": "Open vSwitch",
Bri Prebilic Cole4fab8af2015-01-15 16:40:47 -080041 "sw": "2.0.1"
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080042 }]
43 };
44
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080045 beforeEach(inject(function(_$log_, _$controller_, $httpBackend) {
46 $log = _$log_;
47 $controller = _$controller_;
48 $mockHttp = $httpBackend;
49
Bri Prebilic Cole4fab8af2015-01-15 16:40:47 -080050 $mockHttp.whenGET(/\/device$/).respond(fakeData);
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080051 }));
52
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080053 it('should be an empty array', function () {
54 ctrl = $controller('OvDeviceCtrl');
55 expect(ctrl.deviceData).toEqual([]);
Bri Prebilic Cole4fab8af2015-01-15 16:40:47 -080056 $mockHttp.flush();
57 expect(ctrl.deviceData).toEqual(fakeData.devices);
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080058 });
59
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080060});