Matteo Scandolo | 686547a | 2017-08-08 13:05:25 -0700 | [diff] [blame^] | 1 | |
| 2 | /* |
| 3 | * Copyright 2017-present Open Networking Foundation |
| 4 | |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | |
Matteo Scandolo | a5d03d5 | 2016-07-21 11:35:46 -0700 | [diff] [blame] | 19 | /** |
| 20 | * © OpenCORD |
| 21 | * |
| 22 | * Visit http://guide.xosproject.org/devguide/addview/ for more information |
| 23 | * |
| 24 | * Created by teone on 3/24/16. |
| 25 | */ |
| 26 | |
| 27 | (function () { |
| 28 | 'use strict'; |
| 29 | |
| 30 | describe('The xos.helper module', function(){ |
| 31 | describe('The NoHyperlinks factory', () => { |
| 32 | |
| 33 | let httpProviderObj, noHyperlinks; |
| 34 | |
| 35 | beforeEach(() => { |
| 36 | module( |
| 37 | 'xos.helpers', |
| 38 | ($httpProvider) => { |
| 39 | //save our interceptor |
| 40 | httpProviderObj = $httpProvider; |
| 41 | } |
| 42 | ); |
| 43 | |
| 44 | inject(function (_NoHyperlinks_) { |
| 45 | noHyperlinks = _NoHyperlinks_ |
| 46 | }); |
| 47 | |
| 48 | httpProviderObj.interceptors.push('NoHyperlinks'); |
| 49 | |
| 50 | }); |
| 51 | |
| 52 | it('should set NoHyperlinks interceptor', () => { |
| 53 | expect(httpProviderObj.interceptors).toContain('NoHyperlinks'); |
| 54 | }); |
| 55 | |
| 56 | it('should attach ?no_hyperlinks=1 to the request url', () => { |
| 57 | let result = noHyperlinks.request({url: 'sample.url'}); |
| 58 | expect(result.url).toEqual('sample.url?no_hyperlinks=1'); |
| 59 | }); |
| 60 | |
| 61 | it('should NOT attach ?no_hyperlinks=1 to the request url if is HTML', () => { |
| 62 | let result = noHyperlinks.request({url: 'sample.html'}); |
| 63 | expect(result.url).toEqual('sample.html'); |
| 64 | }); |
| 65 | |
| 66 | }); |
| 67 | }); |
| 68 | })(); |
| 69 | |