3
3
4
4
module . exports = function ( grunt ) {
5
5
6
+ function encodingMiddleware ( request , response , next ) {
7
+ var url = require ( 'url' ) . parse ( request . url , true , true ) ;
8
+ var query = url . query ;
9
+ var pathname = url . pathname ;
10
+
11
+ if ( pathname !== '/encoding' ) {
12
+ next ( ) ;
13
+ return ;
14
+ }
15
+
16
+ var cookieName = query . name ;
17
+ var cookieValue = query . value ;
18
+
19
+ response . setHeader ( 'content-type' , 'application/json' ) ;
20
+ response . end ( JSON . stringify ( {
21
+ name : cookieName ,
22
+ value : cookieValue
23
+ } ) ) ;
24
+ }
25
+
6
26
grunt . initConfig ( {
7
27
pkg : grunt . file . readJSON ( 'package.json' ) ,
8
28
qunit : {
9
29
all : {
10
30
options : {
11
- httpBase : 'http://127.0.0.1:9998'
12
- } ,
13
- src : [ 'test/index.html' , 'test/encoding.html' , 'test/amd.html' ]
14
- }
31
+ urls : [
32
+ 'http://127.0.0.1:9998/' ,
33
+ 'http://127.0.0.1:9998/amd.html' ,
34
+ 'http://127.0.0.1:9998/encoding.html?integration_baseurl=http://127.0.0.1:9998'
35
+ ]
36
+ }
37
+ } ,
15
38
} ,
16
39
nodeunit : {
17
40
all : 'test/node.js'
@@ -76,15 +99,19 @@ module.exports = function (grunt) {
76
99
}
77
100
} ,
78
101
connect : {
79
- 'build-sauce ' : {
102
+ 'build-qunit ' : {
80
103
options : {
81
- port : 9999 ,
82
- base : [ '.' , 'test' ]
104
+ port : 9998 ,
105
+ base : [ '.' , 'test' ] ,
106
+ middleware : function ( connect , options , middlewares ) {
107
+ middlewares . unshift ( encodingMiddleware ) ;
108
+ return middlewares ;
109
+ }
83
110
}
84
111
} ,
85
- 'build-qunit ' : {
112
+ 'build-sauce ' : {
86
113
options : {
87
- port : 9998 ,
114
+ port : 9999 ,
88
115
base : [ '.' , 'test' ]
89
116
}
90
117
} ,
@@ -94,7 +121,11 @@ module.exports = function (grunt) {
94
121
base : [ '.' , 'test' ] ,
95
122
open : 'http://127.0.0.1:10000' ,
96
123
keepalive : true ,
97
- livereload : true
124
+ livereload : true ,
125
+ middleware : function ( connect , options , middlewares ) {
126
+ middlewares . unshift ( encodingMiddleware ) ;
127
+ return middlewares ;
128
+ }
98
129
}
99
130
}
100
131
} ,
0 commit comments