1
1
'use strict' ;
2
2
3
3
const Server = require ( '../../utils/server.js' ) ;
4
+ try {
5
+ // check whether api-testing can be loaded by the node 6 CI
6
+ const apiTesting = require ( 'api-testing' ) ;
7
+ }
8
+ catch ( e ) {
9
+ // skip this whole test suite if api-testing is not loadable
10
+ return ;
11
+ }
4
12
const { REST , assert } = require ( 'api-testing' ) ;
5
13
const mwUtil = require ( '../../../lib/mwUtil' ) ;
6
14
@@ -37,7 +45,7 @@ describe('transform api', function() {
37
45
)
38
46
. then ( ( res ) => {
39
47
assert . deepEqual ( res . status , 200 ) ;
40
- assert . contentTypes ( res , mwUtil . constructRegex ( [ contentTypes . html ] ) ) ;
48
+ assert . match ( res . headers [ 'content-type' ] , mwUtil . constructRegex ( [ contentTypes . html ] ) ) ;
41
49
const pattern = / < h 2 .* > H e a d i n g < \/ h 2 > / ;
42
50
if ( ! pattern . test ( res . text ) ) {
43
51
throw new Error ( `Expected pattern in response: ${ pattern } \nSaw: ${ res . text } ` ) ;
@@ -52,7 +60,7 @@ describe('transform api', function() {
52
60
)
53
61
. then ( ( res ) => {
54
62
assert . deepEqual ( res . status , 200 ) ;
55
- assert . contentTypes ( res , mwUtil . constructRegex ( [ contentTypes . html ] ) ) ;
63
+ assert . match ( res . headers [ 'content-type' ] , mwUtil . constructRegex ( [ contentTypes . html ] ) ) ;
56
64
const pattern = / < h 2 .* > H e a d i n g < \/ h 2 > / ;
57
65
if ( ! pattern . test ( res . text ) ) {
58
66
throw new Error ( `Expected pattern in response: ${ pattern } \nSaw: ${ res . text } ` ) ;
@@ -67,7 +75,7 @@ describe('transform api', function() {
67
75
)
68
76
. then ( ( res ) => {
69
77
assert . deepEqual ( res . status , 200 ) ;
70
- assert . contentTypes ( res , mwUtil . constructRegex ( [ contentTypes . html ] ) ) ;
78
+ assert . match ( res . headers [ 'content-type' ] , mwUtil . constructRegex ( [ contentTypes . html ] ) ) ;
71
79
const pattern = / ^ < h 2 .* > H e a d i n g < \/ h 2 > $ / ;
72
80
if ( ! pattern . test ( res . text ) ) {
73
81
throw new Error ( `Expected pattern in response: ${ pattern
@@ -105,7 +113,7 @@ describe('transform api', function() {
105
113
. then ( ( res ) => {
106
114
assert . deepEqual ( res . status , 200 ) ;
107
115
assert . deepEqual ( res . text , 'The modified HTML' ) ;
108
- assert . contentTypes ( res , mwUtil . constructRegex ( [ contentTypes . wikitext ] ) ) ;
116
+ assert . match ( res . headers [ 'content-type' ] , mwUtil . constructRegex ( [ contentTypes . wikitext ] ) ) ;
109
117
} ) ;
110
118
} ) ;
111
119
@@ -117,7 +125,7 @@ describe('transform api', function() {
117
125
. then ( ( res ) => {
118
126
assert . deepEqual ( res . status , 200 ) ;
119
127
assert . deepEqual ( res . text , testPage . wikitext ) ;
120
- assert . contentTypes ( res , mwUtil . constructRegex ( [ contentTypes . wikitext ] ) ) ;
128
+ assert . match ( res . headers [ 'content-type' ] , mwUtil . constructRegex ( [ contentTypes . wikitext ] ) ) ;
121
129
} ) ;
122
130
} ) ;
123
131
@@ -146,7 +154,7 @@ describe('transform api', function() {
146
154
throw new Error ( `Expected pattern in response: ${ pattern
147
155
} \nSaw: ${ JSON . stringify ( res , null , 2 ) } `) ;
148
156
}
149
- assert . contentTypes ( res , mwUtil . constructRegex ( [ contentTypes . wikitext ] ) ) ;
157
+ assert . match ( res . headers [ 'content-type' ] , mwUtil . constructRegex ( [ contentTypes . wikitext ] ) ) ;
150
158
} ) ;
151
159
} ) ;
152
160
0 commit comments