Bri Prebilic Cole | 7c92a3d | 2015-01-09 16:50:03 -0800 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 22 | describe('Controller: OvDeviceCtrl', function () { |
| 23 | // instantiate the Device module |
Bri Prebilic Cole | 4fab8af | 2015-01-15 16:40:47 -0800 | [diff] [blame^] | 24 | beforeEach(module('ovDevice', 'onosRemote')); |
Bri Prebilic Cole | 7c92a3d | 2015-01-09 16:50:03 -0800 | [diff] [blame] | 25 | |
| 26 | var $log, $controller, ctrl, $mockHttp; |
| 27 | |
| 28 | var fakeData = { |
Bri Prebilic Cole | 4fab8af | 2015-01-15 16:40:47 -0800 | [diff] [blame^] | 29 | "devices": [{ |
Bri Prebilic Cole | 7c92a3d | 2015-01-09 16:50:03 -0800 | [diff] [blame] | 30 | "id": "of:0000000000000001", |
| 31 | "available": true, |
Bri Prebilic Cole | 7c92a3d | 2015-01-09 16:50:03 -0800 | [diff] [blame] | 32 | "mfr": "Nicira, Inc.", |
| 33 | "hw": "Open vSwitch", |
Bri Prebilic Cole | 4fab8af | 2015-01-15 16:40:47 -0800 | [diff] [blame^] | 34 | "sw": "2.0.1" |
Bri Prebilic Cole | 7c92a3d | 2015-01-09 16:50:03 -0800 | [diff] [blame] | 35 | }, |
| 36 | { |
| 37 | "id": "of:0000000000000004", |
| 38 | "available": true, |
Bri Prebilic Cole | 7c92a3d | 2015-01-09 16:50:03 -0800 | [diff] [blame] | 39 | "mfr": "Nicira, Inc.", |
| 40 | "hw": "Open vSwitch", |
Bri Prebilic Cole | 4fab8af | 2015-01-15 16:40:47 -0800 | [diff] [blame^] | 41 | "sw": "2.0.1" |
Bri Prebilic Cole | 7c92a3d | 2015-01-09 16:50:03 -0800 | [diff] [blame] | 42 | }] |
| 43 | }; |
| 44 | |
Bri Prebilic Cole | 7c92a3d | 2015-01-09 16:50:03 -0800 | [diff] [blame] | 45 | beforeEach(inject(function(_$log_, _$controller_, $httpBackend) { |
| 46 | $log = _$log_; |
| 47 | $controller = _$controller_; |
| 48 | $mockHttp = $httpBackend; |
| 49 | |
Bri Prebilic Cole | 4fab8af | 2015-01-15 16:40:47 -0800 | [diff] [blame^] | 50 | $mockHttp.whenGET(/\/device$/).respond(fakeData); |
Bri Prebilic Cole | 7c92a3d | 2015-01-09 16:50:03 -0800 | [diff] [blame] | 51 | })); |
| 52 | |
Bri Prebilic Cole | 7c92a3d | 2015-01-09 16:50:03 -0800 | [diff] [blame] | 53 | it('should be an empty array', function () { |
| 54 | ctrl = $controller('OvDeviceCtrl'); |
| 55 | expect(ctrl.deviceData).toEqual([]); |
Bri Prebilic Cole | 4fab8af | 2015-01-15 16:40:47 -0800 | [diff] [blame^] | 56 | $mockHttp.flush(); |
| 57 | expect(ctrl.deviceData).toEqual(fakeData.devices); |
Bri Prebilic Cole | 7c92a3d | 2015-01-09 16:50:03 -0800 | [diff] [blame] | 58 | }); |
| 59 | |
Bri Prebilic Cole | 7c92a3d | 2015-01-09 16:50:03 -0800 | [diff] [blame] | 60 | }); |