Skip to content

Commit 917da16

Browse files
authored
fix: import TextDecoder (VF-000) (#82)
* fix: import TextDecoder (VF-000) * chore: update deps * chore: fix tests
1 parent cc479d2 commit 917da16

File tree

6 files changed

+506
-683
lines changed

6 files changed

+506
-683
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@types/supertest": "^2.0.11",
4343
"@voiceflow/commitlint-config": "2.0.0",
4444
"@voiceflow/common": "7.27.0",
45-
"@voiceflow/eslint-config": "5.1.2",
45+
"@voiceflow/eslint-config": "6.0.1",
4646
"@voiceflow/git-branch-check": "1.2.3",
4747
"@voiceflow/prettier-config": "1.0.7",
4848
"@voiceflow/tsconfig": "1.2.5",
@@ -54,7 +54,7 @@
5454
"eslint": "^7.32.0",
5555
"eslint-output": "^3.0.1",
5656
"express": "^4.17.3",
57-
"express-validator": "^6.10.1",
57+
"express-validator": "^6.3.0",
5858
"fixpack": "^4.0.0",
5959
"husky": "^4.3.8",
6060
"lint-staged": "12.2.2",

src/common/zip/reader.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { AnyRecord } from '@voiceflow/common';
22
import JSZip from 'jszip';
33
import minimatch from 'minimatch';
4+
import { TextDecoder } from 'util';
45

56
import { isZipFile } from './guard';
67

tests/common/zip/reader.unit.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect } from 'chai';
22
import JSZip from 'jszip';
3+
import { TextDecoder } from 'util';
34

45
import { ZipReader } from '../../../src/common/zip';
56

tests/responseBuilder.unit.ts

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('responseBuilder unit tests', () => {
3131
it('returns ok response with different code', async () => {
3232
const responseBuilder = new ResponseBuilder();
3333
const res = { status: sinon.stub().returns({ json: sinon.stub() }) };
34-
const dataPromise = new Promise((resolve) => resolve({ foo: 'bar' }));
34+
const dataPromise = Promise.resolve({ foo: 'bar' });
3535

3636
await responseBuilder.route(dataPromise, VError.HTTP_STATUS.NO_CONTENT)({ originalUrl: '/test' }, res);
3737

@@ -89,7 +89,7 @@ describe('responseBuilder unit tests', () => {
8989
it('returns bad response with overridden code', async () => {
9090
const responseBuilder = new ResponseBuilder();
9191
const res = { status: sinon.stub().returns({ json: sinon.stub() }) };
92-
const dataPromise = new Promise((resolve, reject) => reject(new VError('boom')));
92+
const dataPromise = Promise.reject(new VError('boom'));
9393

9494
await responseBuilder.route(dataPromise, undefined, VError.HTTP_STATUS.BAD_REQUEST)({ originalUrl: '/test' }, res);
9595

@@ -130,7 +130,7 @@ describe('responseBuilder unit tests', () => {
130130
it('returns bad response with Error', async () => {
131131
const responseBuilder = new ResponseBuilder();
132132
const res = { status: sinon.stub().returns({ json: sinon.stub() }) };
133-
const dataPromise = new Promise((resolve, reject) => reject(new Error('boom')));
133+
const dataPromise = Promise.reject(new VError('boom'));
134134

135135
await responseBuilder.route(dataPromise)({ originalUrl: '/test' }, res);
136136

@@ -153,7 +153,7 @@ describe('responseBuilder unit tests', () => {
153153
it('returns bad response with code 503', async () => {
154154
const responseBuilder = new ResponseBuilder();
155155
const res = { status: sinon.stub().returns({ json: sinon.stub() }) };
156-
const dataPromise = new Promise((resolve, reject) => reject(new VError('boom', HttpStatus.SERVICE_UNAVAILABLE)));
156+
const dataPromise = Promise.reject(new VError('boom', HttpStatus.SERVICE_UNAVAILABLE));
157157

158158
await responseBuilder.route(dataPromise)({ originalUrl: '/test' }, res);
159159

@@ -176,7 +176,7 @@ describe('responseBuilder unit tests', () => {
176176
it('returns bad response with data', async () => {
177177
const responseBuilder = new ResponseBuilder();
178178
const res = { status: sinon.stub().returns({ json: sinon.stub() }) };
179-
const dataPromise = new Promise((resolve, reject) => reject(new VError('boom', undefined, { foo: 'bar' })));
179+
const dataPromise = Promise.reject(new VError('boom', undefined, { foo: 'bar' }));
180180

181181
await responseBuilder.route(dataPromise)({ originalUrl: '/test' }, res);
182182

@@ -189,27 +189,4 @@ describe('responseBuilder unit tests', () => {
189189

190190
expect(res.status().json.args[0][0]).to.eql({ foo: 'bar' });
191191
});
192-
193-
it('returns bad response with data from message', async () => {
194-
const responseBuilder = new ResponseBuilder();
195-
const res = { status: sinon.stub().returns({ json: sinon.stub() }) };
196-
const dataPromise = new Promise((resolve, reject) => reject(new VError('boom')));
197-
198-
await responseBuilder.route(dataPromise)({ originalUrl: '/test' }, res);
199-
200-
const expected = {
201-
code: 500,
202-
status: 'Internal Server Error',
203-
data: 'boom',
204-
};
205-
206-
expect(res.status.args[0][0]).to.eql(expected.code);
207-
208-
expect(res.status().json.args[0][0].code).to.eql(expected.code);
209-
expect(res.status().json.args[0][0].data).to.eql(expected.data);
210-
expect(res.status().json.args[0][0].status).to.eql(expected.status);
211-
212-
expect(res.status().json.args[0][0].dateTime).to.not.be.undefined;
213-
expect(res.status().json.args[0][0].timestamp).to.not.be.undefined;
214-
});
215192
});

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extends": "@voiceflow/tsconfig",
33
"compilerOptions": {
44
"baseUrl": "./src",
5-
"lib": ["DOM", "ES2020"]
5+
"lib": ["ES2020"]
66
},
77
"compileOnSave": false,
88
"include": [

0 commit comments

Comments
 (0)