Matteo Scandolo | 6297a26 | 2016-03-24 15:11:29 -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 NoHyperlinks factory', () => { |
| 13 | |
| 14 | let httpProviderObj, httpBackend, http, noHyperlinks; |
| 15 | |
| 16 | beforeEach(() => { |
| 17 | module( |
| 18 | 'xos.helpers', |
| 19 | ($httpProvider) => { |
| 20 | //save our interceptor |
| 21 | httpProviderObj = $httpProvider; |
| 22 | } |
| 23 | ); |
| 24 | |
| 25 | inject(function (_$httpBackend_, _$http_, _NoHyperlinks_) { |
| 26 | httpBackend = _$httpBackend_; |
| 27 | http = _$http_; |
| 28 | noHyperlinks = _NoHyperlinks_ |
| 29 | }); |
| 30 | |
| 31 | httpProviderObj.interceptors.push('NoHyperlinks'); |
| 32 | |
| 33 | }); |
| 34 | |
| 35 | it('should set NoHyperlinks interceptor', () => { |
| 36 | expect(httpProviderObj.interceptors).toContain('NoHyperlinks'); |
| 37 | }); |
| 38 | |
| 39 | it('should attach ?no_hyperlinks=1 to the request url', () => { |
| 40 | let result = noHyperlinks.request({url: 'sample.url'}); |
| 41 | expect(result.url).toEqual('sample.url?no_hyperlinks=1'); |
| 42 | }); |
| 43 | |
| 44 | it('should NOT attach ?no_hyperlinks=1 to the request url if is HTML', () => { |
| 45 | let result = noHyperlinks.request({url: 'sample.html'}); |
| 46 | expect(result.url).toEqual('sample.html'); |
| 47 | }); |
| 48 | |
| 49 | }); |
| 50 | })(); |
| 51 | |