blob: 7b6e9d06f8b3be90dca143d90332195009af96bd [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 Scandolod72d4902016-04-15 13:00:01 -070015 let httpProviderObj, 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 Scandolod72d4902016-04-15 13:00:01 -070026 inject(function (_NoHyperlinks_) {
Matteo Scandolo9e6c6fc2016-04-14 14:59:09 -070027 noHyperlinks = _NoHyperlinks_
28 });
29
30 httpProviderObj.interceptors.push('NoHyperlinks');
31
Matteo Scandolo7dea2432016-03-24 15:11:29 -070032 });
33
Matteo Scandolo9e6c6fc2016-04-14 14:59:09 -070034 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 Scandolo7dea2432016-03-24 15:11:29 -070047
48 });
Matteo Scandolo7dea2432016-03-24 15:11:29 -070049 });
50})();
51