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 | |
Matteo Scandolo | a7e64fd | 2016-04-14 14:59:09 -0700 | [diff] [blame] | 12 | describe('The xos.helper module', function(){ |
| 13 | describe('The NoHyperlinks factory', () => { |
Matteo Scandolo | 6297a26 | 2016-03-24 15:11:29 -0700 | [diff] [blame] | 14 | |
Matteo Scandolo | 833c7d8 | 2016-04-15 13:00:01 -0700 | [diff] [blame] | 15 | let httpProviderObj, noHyperlinks; |
Matteo Scandolo | 6297a26 | 2016-03-24 15:11:29 -0700 | [diff] [blame] | 16 | |
Matteo Scandolo | a7e64fd | 2016-04-14 14:59:09 -0700 | [diff] [blame] | 17 | beforeEach(() => { |
| 18 | module( |
| 19 | 'xos.helpers', |
| 20 | ($httpProvider) => { |
| 21 | //save our interceptor |
| 22 | httpProviderObj = $httpProvider; |
| 23 | } |
| 24 | ); |
Matteo Scandolo | 6297a26 | 2016-03-24 15:11:29 -0700 | [diff] [blame] | 25 | |
Matteo Scandolo | 833c7d8 | 2016-04-15 13:00:01 -0700 | [diff] [blame] | 26 | inject(function (_NoHyperlinks_) { |
Matteo Scandolo | a7e64fd | 2016-04-14 14:59:09 -0700 | [diff] [blame] | 27 | noHyperlinks = _NoHyperlinks_ |
| 28 | }); |
| 29 | |
| 30 | httpProviderObj.interceptors.push('NoHyperlinks'); |
| 31 | |
Matteo Scandolo | 6297a26 | 2016-03-24 15:11:29 -0700 | [diff] [blame] | 32 | }); |
| 33 | |
Matteo Scandolo | a7e64fd | 2016-04-14 14:59:09 -0700 | [diff] [blame] | 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 | }); |
Matteo Scandolo | 6297a26 | 2016-03-24 15:11:29 -0700 | [diff] [blame] | 47 | |
| 48 | }); |
Matteo Scandolo | 6297a26 | 2016-03-24 15:11:29 -0700 | [diff] [blame] | 49 | }); |
| 50 | })(); |
| 51 | |