@@ -3,12 +3,18 @@ const mock = require('mock-require');
3
3
const path = require ( 'path' ) ;
4
4
5
5
const should = chai . should ( ) ;
6
+
7
+ const HELPERS_ID = path . resolve ( __dirname , '..' , 'www' , 'helpers' ) ;
6
8
const PLUGIN_ID = path . resolve ( __dirname , '..' , 'www' , 'advanced-http' ) ;
7
9
8
10
describe ( 'Advanced HTTP www interface' , function ( ) {
9
11
let http = { } ;
12
+ let helpers = { } ;
13
+
10
14
const noop = ( ) => { /* intentionally doing nothing */ } ;
15
+
11
16
const loadHttp = ( ) => {
17
+ mock ( `${ PLUGIN_ID } .helpers` , mock . reRequire ( '../www/helpers' ) ) ;
12
18
http = mock . reRequire ( '../www/advanced-http' ) ;
13
19
} ;
14
20
@@ -19,8 +25,12 @@ describe('Advanced HTTP www interface', function() {
19
25
global . btoa = decoded => new Buffer ( decoded ) . toString ( 'base64' ) ;
20
26
21
27
mock ( 'cordova/exec' , noop ) ;
22
- mock ( `${ PLUGIN_ID } .angular-integration` , { registerService : noop } ) ;
23
28
mock ( `${ PLUGIN_ID } .cookie-handler` , { } ) ;
29
+ mock ( `${ HELPERS_ID } .cookie-handler` , { } ) ;
30
+ mock ( `${ PLUGIN_ID } .messages` , require ( '../www/messages' ) ) ;
31
+ mock ( `${ HELPERS_ID } .messages` , require ( '../www/messages' ) ) ;
32
+ mock ( `${ PLUGIN_ID } .angular-integration` , { registerService : noop } ) ;
33
+
24
34
loadHttp ( ) ;
25
35
} ) ;
26
36
@@ -40,7 +50,7 @@ describe('Advanced HTTP www interface', function() {
40
50
} ) ;
41
51
42
52
it ( 'resolves global headers correctly #24' , ( ) => {
43
- mock ( `${ PLUGIN_ID } .cookie-handler` , {
53
+ mock ( `${ HELPERS_ID } .cookie-handler` , {
44
54
getCookieString : ( ) => 'fakeCookieString'
45
55
} ) ;
46
56
@@ -59,7 +69,7 @@ describe('Advanced HTTP www interface', function() {
59
69
} ) ;
60
70
61
71
it ( 'resolves host headers correctly (set without port number) #37' , ( ) => {
62
- mock ( `${ PLUGIN_ID } .cookie-handler` , {
72
+ mock ( `${ HELPERS_ID } .cookie-handler` , {
63
73
getCookieString : ( ) => 'fakeCookieString'
64
74
} ) ;
65
75
@@ -78,7 +88,7 @@ describe('Advanced HTTP www interface', function() {
78
88
} ) ;
79
89
80
90
it ( 'resolves host headers correctly (set with port number) #37' , ( ) => {
81
- mock ( `${ PLUGIN_ID } .cookie-handler` , {
91
+ mock ( `${ HELPERS_ID } .cookie-handler` , {
82
92
getCookieString : ( ) => 'fakeCookieString'
83
93
} ) ;
84
94
@@ -97,7 +107,7 @@ describe('Advanced HTTP www interface', function() {
97
107
} ) ;
98
108
99
109
it ( 'resolves request headers correctly' , ( ) => {
100
- mock ( `${ PLUGIN_ID } .cookie-handler` , {
110
+ mock ( `${ HELPERS_ID } .cookie-handler` , {
101
111
getCookieString : ( ) => 'fakeCookieString'
102
112
} ) ;
103
113
0 commit comments