Skip to content

Commit

Permalink
test: use Buffer.alloc, Buffer.from. (eggjs#1895)
Browse files Browse the repository at this point in the history
Since new Buffer() was deprecated since Node.js v6.
  • Loading branch information
aladdin-add authored and popomore committed Dec 29, 2017
1 parent 73bc636 commit c136470
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/app/extend/response.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('test/app/extend/response.test.js', () => {
ctx.body = '1';
ctx.response.remove('content-length');
assert(ctx.response.length === 1);
ctx.body = new Buffer(2);
ctx.body = Buffer.alloc(2);
ctx.response.remove('content-length');
assert(ctx.response.length === 2);
ctx.body = {};
Expand Down
2 changes: 1 addition & 1 deletion test/lib/core/cookies.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('test/lib/core/cookies.test.js', () => {

it('should log CookieLimitExceed error when cookie value too long', done => {
const ctx = app.mockContext();
const value = new Buffer(4094).fill(49).toString();
const value = Buffer.alloc(4094).fill(49).toString();
ctx.cookies.set('foo', value);
setTimeout(() => {
const logPath = path.join(utils.getFilepath('apps/secure-app'), 'logs/secure-app/common-error.log');
Expand Down
2 changes: 1 addition & 1 deletion test/lib/core/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('test/lib/core/utils.test.js', () => {
const obj = {
bufferClass$: Buffer,
bufferClassExtend$: SlowBuffer,
buffer$: new Buffer('123'),
buffer$: Buffer.from('123'),
bufferExtend$: new SlowBuffer('123'),
};
utils.convertObject(obj);
Expand Down

0 comments on commit c136470

Please sign in to comment.