blob: 6faedc936118f50ab6259f084f603b2b8e556330 [file] [log] [blame]
Simon Hunt584122a2015-01-21 15:32:40 -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 -- Remote -- Web Socket Service - Unit Tests
19 */
20describe('factory: fw/remote/websocket.js', function () {
21 var $log, fs, wss;
22
Simon Hunt2d16fc82015-03-10 20:19:52 -070023 beforeEach(module('onosRemote', 'onosLayer', 'ngRoute', 'onosNav', 'onosSvg'));
Simon Hunt584122a2015-01-21 15:32:40 -080024
25 beforeEach(module(function($provide) {
Simon Hunt2d16fc82015-03-10 20:19:52 -070026 $provide.factory('$location', function () {
Simon Hunt584122a2015-01-21 15:32:40 -080027 return {
28 protocol: function () { return 'http'; },
29 host: function () { return 'foo'; },
30 port: function () { return '80'; }
31 };
32 })
33 }));
34
35 beforeEach(inject(function (_$log_, FnService, WebSocketService) {
36 $log = _$log_;
37 fs = FnService;
38 wss = WebSocketService;
39 }));
40
41
42 it('should define WebSocketService', function () {
43 expect(wss).toBeDefined();
44 });
45
46 it('should define api functions', function () {
47 expect(fs.areFunctions(wss, [
Simon Hunt2d16fc82015-03-10 20:19:52 -070048 'resetSid', 'createWebSocket', 'bindHandlers', 'unbindHandlers',
49 'sendEvent'
Simon Hunt584122a2015-01-21 15:32:40 -080050 ])).toBeTruthy();
51 });
52
53 it('should use the appropriate URL', function () {
Simon Hunt2d16fc82015-03-10 20:19:52 -070054 var url = wss.createWebSocket();
55 expect(url).toEqual('ws://foo:80/onos/ui/websock/core');
Simon Hunt584122a2015-01-21 15:32:40 -080056 });
57
Simon Huntacf410b2015-01-23 10:05:48 -080058 it('should use the appropriate URL with modified port', function () {
Simon Hunt2d16fc82015-03-10 20:19:52 -070059 var url = wss.createWebSocket({ wsport: 1243 });
60 expect(url).toEqual('ws://foo:1243/onos/ui/websock/core');
Simon Huntacf410b2015-01-23 10:05:48 -080061 });
62
Simon Hunt2d16fc82015-03-10 20:19:52 -070063 // TODO: inject mock WSock service and write more tests ...
Simon Huntacf410b2015-01-23 10:05:48 -080064
Simon Hunt584122a2015-01-21 15:32:40 -080065});