Skip to content

Commit cd9d923

Browse files
committed
Enable unit test for non-UTF-8 on CLI
1 parent 4fbca4c commit cd9d923

File tree

4 files changed

+31
-29
lines changed

4 files changed

+31
-29
lines changed

Gruntfile.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ module.exports = function (grunt) {
77
options: {
88
port: 8765,
99
hostname: "127.0.0.1",
10+
middleware: function (connect, options, middlewares) {
11+
middlewares.unshift(function (req, res, next) {
12+
if (/\s*\.html/.test(req.url)) {
13+
// work around https://github.com/gruntjs/grunt-contrib-connect/issues/95
14+
res.setHeader("Content-Type", "text/html;");
15+
}
16+
return next();
17+
});
18+
return middlewares;
19+
},
1020
},
1121
},
1222
},

test/.jshintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"spyOn": true,
1616

1717
"ifNotInWebkitOrBlinkIt": true,
18-
"ifNotInHeadlessChrome": true,
1918
"testHelper": true,
2019
"diffHelper": true,
2120

test/helpers.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"use strict";
33

44
var isWebkitOrBlink = navigator.userAgent.indexOf("WebKit") >= 0,
5-
isHeadlessChrome = navigator.userAgent.indexOf("HeadlessChrome") >= 0,
65
testDisabledOnCondition = function (condition, text, functionHandle) {
76
var spec = it(text, functionHandle);
87
if (condition) {
@@ -13,7 +12,4 @@
1312
window.ifNotInWebkitOrBlinkIt = function (text, functionHandle) {
1413
return testDisabledOnCondition(isWebkitOrBlink, text, functionHandle);
1514
};
16-
window.ifNotInHeadlessChrome = function (text, functionHandle) {
17-
return testDisabledOnCondition(isHeadlessChrome, text, functionHandle);
18-
};
1915
})();

test/specs/integration.test.js

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -152,33 +152,30 @@ describe("Integration test", function () {
152152
.finally(done);
153153
});
154154

155-
ifNotInHeadlessChrome(
156-
"should take a URL and load non UTF-8 content",
157-
function (done) {
158-
var inlineReferencesSpy = spyOn(
159-
inlineresources,
160-
"inlineReferences"
161-
).and.returnValue(Promise.resolve());
155+
it("should take a URL and load non UTF-8 content", function (done) {
156+
var inlineReferencesSpy = spyOn(
157+
inlineresources,
158+
"inlineReferences"
159+
).and.returnValue(Promise.resolve());
162160

163-
rasterizeHTML
164-
.drawURL(testHelper.fixturesPath + "nonUTF8Encoding.html")
165-
.then(function () {
166-
expect(inlineReferencesSpy).toHaveBeenCalled();
161+
rasterizeHTML
162+
.drawURL(testHelper.fixturesPath + "nonUTF8Encoding.html")
163+
.then(function () {
164+
expect(inlineReferencesSpy).toHaveBeenCalled();
167165

168-
var doc = inlineReferencesSpy.calls.mostRecent().args[0];
166+
var doc = inlineReferencesSpy.calls.mostRecent().args[0];
169167

170-
// This fails if SpecRunner is opened locally in Firefox. Open over a local webserver helps here.
171-
expect(doc.querySelector("body").innerHTML.trim()).toEqual(
172-
"这是中文"
173-
);
174-
})
175-
.catch(function (err) {
176-
expect(err).toBe(null);
177-
fail();
178-
})
179-
.finally(done);
180-
}
181-
);
168+
// This fails if SpecRunner is opened locally in Firefox. Open over a local webserver helps here.
169+
expect(doc.querySelector("body").innerHTML.trim()).toEqual(
170+
"这是中文"
171+
);
172+
})
173+
.catch(function (err) {
174+
expect(err).toBe(null);
175+
fail();
176+
})
177+
.finally(done);
178+
});
182179

183180
it("should work around Firefox bug with `null` style properties", function (done) {
184181
// The bug only turns up when there's no JS executed which creates a new document

0 commit comments

Comments
 (0)