Skip to content

Commit 87b5067

Browse files
author
Anton Savoskin
committed
fix: migrate tests from ts to js
1 parent 94000df commit 87b5067

11 files changed

+37
-42
lines changed

package.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,12 @@
4646
"jest": {
4747
"preset": "ts-jest",
4848
"setupFiles": [
49-
"<rootDir>/test/setup.ts"
49+
"<rootDir>/test/setup.js"
5050
],
5151
"testEnvironment": "node",
5252
"testMatch": [
53-
"<rootDir>/test/**/*.test.ts"
54-
],
55-
"transform": {
56-
"^.+\\.tsx?$": "ts-jest"
57-
}
53+
"<rootDir>/test/**/*.test.js"
54+
]
5855
},
5956
"dependencies": {
6057
"@babel/core": "^7.2.2",

test/commands/clean.test.ts test/commands/clean.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { test } from '@oclif/test';
2-
import { copyFile, mkdir, rmdir } from '../utils';
3-
import * as lokaliseKeysJson from './__mocks__/lokaliseKeys.json';
1+
const { test } = require('@oclif/test');
2+
const { copyFile, mkdir, rmdir } = require('../utils');
3+
const lokaliseKeysJson = require('./__mocks__/lokaliseKeys.json');
44

55
const messagesDir = 'messagesClean';
66

test/commands/extract.test.ts test/commands/extract.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { test } from '@oclif/test';
2-
import { readJson, mkdir, rmdir } from '../utils';
1+
const { test } = require('@oclif/test');
2+
const { readJson, mkdir, rmdir } = require('../utils');
33

44
const messagesDir = 'messagesExtract';
55

test/commands/sync.test.ts test/commands/sync.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { test } from '@oclif/test';
2-
import { copyFile, mkdir, readJson, rmdir } from '../utils';
3-
import * as lokaliseKeysJson from './__mocks__/lokaliseKeys.json';
1+
const { test } = require('@oclif/test');
2+
const { copyFile, mkdir, readJson, rmdir } = require('../utils');
3+
const lokaliseKeysJson = require('./__mocks__/lokaliseKeys.json');
44

55
const messagesDir = 'messagesSync';
66

@@ -25,7 +25,7 @@ describe('sync lokalise', () => {
2525
.get(`/api2/projects/${projectId}/keys`)
2626
.query(true)
2727
.reply(200, { project_id: '139504615bd04772c3b220.60315670', keys: [] })
28-
.post(`/api2/projects/${projectId}/keys`, (body: object) => {
28+
.post(`/api2/projects/${projectId}/keys`, body => {
2929
expect(body).toMatchSnapshot();
3030
return true;
3131
})
@@ -66,7 +66,7 @@ describe('sync locize', () => {
6666
api
6767
.get(`/${projectId}/latest/en/test`)
6868
.reply(200, {})
69-
.post(`/missing/${projectId}/latest/en/test`, (body: object) => {
69+
.post(`/missing/${projectId}/latest/en/test`, body => {
7070
expect(body).toMatchSnapshot();
7171
return true;
7272
})

test/setup.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const { resolve } = require('path');
2+
const { config } = require('dotenv');
3+
4+
process.chdir(resolve(__dirname, 'test-project'));
5+
config();

test/setup.ts

-5
This file was deleted.

test/tsconfig.json

-9
This file was deleted.

test/utils.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const { mkdirSync, readdirSync, readFileSync, rmdirSync, unlinkSync, writeFileSync } = require('fs');
2+
const { resolve } = require('path');
3+
4+
const readJson = path => JSON.parse(readFileSync(path, 'utf8'));
5+
const mkdir = path => mkdirSync(path);
6+
const rmdir = path => {
7+
readdirSync(path).forEach(file => {
8+
unlinkSync(resolve(path, file));
9+
});
10+
rmdirSync(path);
11+
};
12+
const copyFile = (source, target) => writeFileSync(target, readFileSync(source));
13+
14+
module.exports = {
15+
readJson,
16+
mkdir,
17+
rmdir,
18+
copyFile,
19+
};

test/utils.ts

-12
This file was deleted.

0 commit comments

Comments
 (0)