diff --git a/test/app/middleware/site_file.test.js b/test/app/middleware/site_file.test.js
index 2ff8528732..0824348b20 100644
--- a/test/app/middleware/site_file.test.js
+++ b/test/app/middleware/site_file.test.js
@@ -28,7 +28,7 @@ describe('test/app/middleware/site_file.test.js', () => {
it('should 200 when accessing /robots.txt', () => {
return app.httpRequest()
.get('/robots.txt')
- .expect('User-agent: Baiduspider\nDisallow: /\n\nUser-agent: baiduspider\nDisallow: /')
+ .expect(/^User-agent: Baiduspider\r?\nDisallow: \/\r?\n\r?\nUser-agent: baiduspider\r?\nDisallow: \/$/)
.expect(200);
});
@@ -42,7 +42,7 @@ describe('test/app/middleware/site_file.test.js', () => {
it('should support HEAD', () => {
return app.httpRequest()
.head('/robots.txt')
- .expect('content-length', '72')
+ .expect(res => assert(Number(res.header['content-length']) > 0))
// body must be empty for HEAD
.expect(res => assert.equal(res.text, undefined))
.expect(200);
diff --git a/test/lib/core/view.test.js b/test/lib/core/view.test.js
index 9241483da8..381d50cd89 100644
--- a/test/lib/core/view.test.js
+++ b/test/lib/core/view.test.js
@@ -96,14 +96,19 @@ describe('test/lib/core/view.test.js', () => {
app.httpRequest()
.get('/')
.expect(200)
- .expect(`Hi, mk・2\ntest-app-helper: test-bar@${app.config.baseDir}\nraw:
dar
\n2014 @ mk2 <br>\n`, done);
+ .expect(res => assert.equal(String(res.text).replace(/\r/g, ''), `Hi, mk・2\ntest-app-helper: test-bar@${app.config.baseDir}\nraw: dar
\n2014 @ mk2 <br>\n`))
+ .end(done)
+
+ ;
});
it('should render with async function controller', function(done) {
app.httpRequest()
.get('/async')
.expect(200)
- .expect(`Hi, mk・2\ntest-app-helper: test-bar@${app.config.baseDir}\nraw: dar
\n2014 @ mk2 <br>\n`, done);
+ .expect(res => assert.equal(String(res.text).replace(/\r/g, ''), `Hi, mk・2\ntest-app-helper: test-bar@${app.config.baseDir}\nraw: dar
\n2014 @ mk2 <br>\n`))
+ .end(done)
+ ;
});
it('should render have helper instance', function(done) {
@@ -116,7 +121,10 @@ describe('test/lib/core/view.test.js', () => {
app.httpRequest()
.get('/empty')
.expect(200)
- .expect(`Hi, \ntest-app-helper: test-bar@${app.config.baseDir}\nraw: dar
\n2014 @ mk2 <br>\n`, done);
+ .expect(res => assert.equal(String(res.text).replace(/\r/g, ''), `Hi, \ntest-app-helper: test-bar@${app.config.baseDir}\nraw: dar
\n2014 @ mk2 <br>\n`))
+
+ .end(done)
+ ;
});
it('should render template string', function(done) {
diff --git a/test/lib/plugins/i18n.test.js b/test/lib/plugins/i18n.test.js
index 66f0167863..326c659588 100644
--- a/test/lib/plugins/i18n.test.js
+++ b/test/lib/plugins/i18n.test.js
@@ -1,5 +1,4 @@
'use strict';
-
const utils = require('../../utils');
describe('test/lib/plugins/i18n.test.js', () => {
@@ -37,7 +36,7 @@ describe('test/lib/plugins/i18n.test.js', () => {
.get('/')
.expect(200)
.expect('Set-Cookie', /locale=en-us; path=\/; expires=[^;]+ GMT/)
- .expect('Email: \nHello fengmk2, how are you today?\nfoo bar\n');
+ .expect(/^Email: <\/li>\r?\nHello fengmk2, how are you today\?<\/li>\r?\nfoo bar<\/li>\r?\n$/);
});
it('should render with query locale: zh_CN', () => {
@@ -46,7 +45,7 @@ describe('test/lib/plugins/i18n.test.js', () => {
.set('Host', 'foo.example.com')
.expect(200)
.expect('Set-Cookie', /locale=zh-cn; path=\/; expires=[^;]+ GMT/)
- .expect('邮箱: \nfengmk2,今天过得如何?\nfoo bar\n');
+ .expect(/^邮箱: <\/li>\r?\nfengmk2,今天过得如何?<\/li>\r?\nfoo bar<\/li>\r?\n$/);
});
});
});
diff --git a/test/lib/plugins/static.test.js b/test/lib/plugins/static.test.js
index bdfd43c3dc..9d43841b5f 100644
--- a/test/lib/plugins/static.test.js
+++ b/test/lib/plugins/static.test.js
@@ -1,5 +1,4 @@
'use strict';
-
const utils = require('../../utils');
describe('test/lib/plugins/static.test.js', () => {
@@ -12,7 +11,7 @@ describe('test/lib/plugins/static.test.js', () => {
it('should get exists js file', () => {
return app.httpRequest()
.get('/public/foo.js')
- .expect('alert(\'bar\');\n')
+ .expect(/alert\(\'bar\'\);\r?\n/)
.expect(200);
});
});