blob: a3646e3cef3ab35874ffca47b136c9868693a206 [file] [log] [blame]
Matteo Scandolo7dea2432016-03-24 15:11:29 -07001/**
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 Scandolo9e6c6fc2016-04-14 14:59:09 -070012 describe('The xos.helper module', function(){
13 describe('The NoHyperlinks factory', () => {
Matteo Scandolo7dea2432016-03-24 15:11:29 -070014
Matteo Scandolo9e6c6fc2016-04-14 14:59:09 -070015 let httpProviderObj, httpBackend, http, noHyperlinks;
Matteo Scandolo7dea2432016-03-24 15:11:29 -070016
Matteo Scandolo9e6c6fc2016-04-14 14:59:09 -070017 beforeEach(() => {
18 module(
19 'xos.helpers',
20 ($httpProvider) => {
21 //save our interceptor
22 httpProviderObj = $httpProvider;
23 }
24 );
Matteo Scandolo7dea2432016-03-24 15:11:29 -070025
Matteo Scandolo9e6c6fc2016-04-14 14:59:09 -070026 inject(function (_$httpBackend_, _$http_, _NoHyperlinks_) {
27 httpBackend = _$httpBackend_;
28 http = _$http_;
29 noHyperlinks = _NoHyperlinks_
30 });
31
32 httpProviderObj.interceptors.push('NoHyperlinks');
33
Matteo Scandolo7dea2432016-03-24 15:11:29 -070034 });
35
Matteo Scandolo9e6c6fc2016-04-14 14:59:09 -070036 it('should set NoHyperlinks interceptor', () => {
37 expect(httpProviderObj.interceptors).toContain('NoHyperlinks');
38 });
39
40 it('should attach ?no_hyperlinks=1 to the request url', () => {
41 let result = noHyperlinks.request({url: 'sample.url'});
42 expect(result.url).toEqual('sample.url?no_hyperlinks=1');
43 });
44
45 it('should NOT attach ?no_hyperlinks=1 to the request url if is HTML', () => {
46 let result = noHyperlinks.request({url: 'sample.html'});
47 expect(result.url).toEqual('sample.html');
48 });
Matteo Scandolo7dea2432016-03-24 15:11:29 -070049
50 });
Matteo Scandolo7dea2432016-03-24 15:11:29 -070051 });
52})();
53