Matteo Scandolo | a5d03d5 | 2016-07-21 11:35:46 -0700 | [diff] [blame] | 1 | /** |
| 2 | * © OpenCORD |
| 3 | * |
| 4 | * Visit http://guide.xosproject.org/devguide/addview/ for more information |
| 5 | * |
| 6 | * Created by teone on 3/24/16. |
| 7 | */ |
| 8 | |
| 9 | (function () { |
| 10 | 'use strict'; |
| 11 | |
| 12 | describe('The xos.helper module', function(){ |
| 13 | describe('The NoHyperlinks factory', () => { |
| 14 | |
| 15 | let httpProviderObj, noHyperlinks; |
| 16 | |
| 17 | beforeEach(() => { |
| 18 | module( |
| 19 | 'xos.helpers', |
| 20 | ($httpProvider) => { |
| 21 | //save our interceptor |
| 22 | httpProviderObj = $httpProvider; |
| 23 | } |
| 24 | ); |
| 25 | |
| 26 | inject(function (_NoHyperlinks_) { |
| 27 | noHyperlinks = _NoHyperlinks_ |
| 28 | }); |
| 29 | |
| 30 | httpProviderObj.interceptors.push('NoHyperlinks'); |
| 31 | |
| 32 | }); |
| 33 | |
| 34 | it('should set NoHyperlinks interceptor', () => { |
| 35 | expect(httpProviderObj.interceptors).toContain('NoHyperlinks'); |
| 36 | }); |
| 37 | |
| 38 | it('should attach ?no_hyperlinks=1 to the request url', () => { |
| 39 | let result = noHyperlinks.request({url: 'sample.url'}); |
| 40 | expect(result.url).toEqual('sample.url?no_hyperlinks=1'); |
| 41 | }); |
| 42 | |
| 43 | it('should NOT attach ?no_hyperlinks=1 to the request url if is HTML', () => { |
| 44 | let result = noHyperlinks.request({url: 'sample.html'}); |
| 45 | expect(result.url).toEqual('sample.html'); |
| 46 | }); |
| 47 | |
| 48 | }); |
| 49 | }); |
| 50 | })(); |
| 51 | |