Skip to content

Commit ac0d699

Browse files
committed
Remove the mocha entirely from dependency
1 parent 5f7bcf9 commit ac0d699

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+239
-387
lines changed

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@
4848
"prettier": "^2.2.1",
4949
"ts-loader": "^8.0.14",
5050
"ts-node": "^9.1.1",
51-
"typescript": "^4.1.3"
51+
"typescript": "^4.1.3",
52+
"@types/jest": "^26.0.22",
53+
"jest": "^26.6.3",
54+
"ts-jest": "^26.5.5"
5255
},
5356
"resolutions": {
5457
"@types/react": "^16.14.4"

packages/background/jest.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
preset: "ts-jest",
3+
testEnvironment: "node",
4+
testMatch: ["**/src/**/?(*.)+(spec|test).[jt]s?(x)"],
5+
};

packages/background/package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@
1212
"clean": "rm -rf node_modules; rm -rf build",
1313
"build": "tsc",
1414
"dev": "tsc -w",
15-
"test": "mocha --timeout 30000 -r ts-node/register 'src/**/*.spec.ts'",
15+
"test": "jest --passWithNoTests",
1616
"lint-test": "eslint \"src/**/*\" && prettier --check \"src/**/*\"",
1717
"lint-fix": "eslint --fix \"src/**/*\" && prettier --write \"src/**/*\""
1818
},
1919
"devDependencies": {
2020
"@types/aes-js": "^3.1.0",
2121
"@types/ledgerhq__hw-transport-webusb": "^4.70.1",
22-
"@types/secp256k1": "^4.0.1",
23-
"mocha": "^8.2.1",
24-
"@types/mocha": "^5.2.7"
22+
"@types/secp256k1": "^4.0.1"
2523
},
2624
"dependencies": {
2725
"@cosmjs/launchpad": "^0.24.0-alpha.25",

packages/background/src/chains/types.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import assert from "assert";
2-
import "mocha";
32
import {
43
Bech32ConfigSchema,
54
ChainInfoSchema,

packages/background/src/noop.spec.ts

-1
This file was deleted.

packages/common/jest.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
preset: "ts-jest",
3+
testEnvironment: "node",
4+
testMatch: ["**/src/**/?(*.)+(spec|test).[jt]s?(x)"],
5+
};

packages/common/package.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@
1212
"clean": "rm -rf node_modules; rm -rf build",
1313
"build": "tsc",
1414
"dev": "tsc -w",
15-
"test": "mocha --timeout 30000 -r ts-node/register 'src/**/*.spec.ts'",
15+
"test": "jest --passWithNoTests",
1616
"lint-test": "eslint \"src/**/*\" && prettier --check \"src/**/*\"",
1717
"lint-fix": "eslint --fix \"src/**/*\" && prettier --write \"src/**/*\""
1818
},
19-
"devDependencies": {
20-
"mocha": "^8.2.1",
21-
"@types/mocha": "^5.2.7"
22-
},
19+
"devDependencies": {},
2320
"dependencies": {
2421
"delay": "^4.4.0"
2522
}
+4-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
import assert from "assert";
2-
import "mocha";
31
import { MemoryKVStore } from "./memory";
42

53
describe("Test kvstore", () => {
6-
it("kvstore should not conflict", async () => {
4+
test("kvstore should not conflict", async () => {
75
const test1KVStore = new MemoryKVStore("test1");
86
const test2KVStore = new MemoryKVStore("test2");
97

108
const key = "key";
119
await test1KVStore.set(key, "test1");
1210

1311
let valueFromTest2 = await test2KVStore.get(key);
14-
assert.strictEqual(valueFromTest2, undefined);
12+
expect(valueFromTest2).toBe(undefined);
1513

1614
await test2KVStore.set(key, "test2");
1715
const valueFromTest1 = await test1KVStore.get(key);
1816
valueFromTest2 = await test2KVStore.get(key);
19-
assert.strictEqual(valueFromTest1, "test1");
20-
assert.strictEqual(valueFromTest2, "test2");
17+
expect(valueFromTest1).toBe("test1");
18+
expect(valueFromTest2).toBe("test2");
2119
});
2220
});

packages/common/src/noop.spec.ts

-1
This file was deleted.
+7-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import assert from "assert";
2-
import "mocha";
31
import { Debouncer } from "./debouncer";
42

53
describe("Test common utils", () => {
6-
it("Test debouncer", async () => {
4+
test("Test debouncer", async () => {
75
let i = 0;
86
const fn = (): Promise<number> => {
97
i++;
@@ -17,9 +15,9 @@ describe("Test common utils", () => {
1715

1816
// Non debounced fn should return the different results.
1917
let [r1, r2, r3] = await Promise.all([fn(), fn(), fn()]);
20-
assert.strictEqual(r1, 1);
21-
assert.strictEqual(r2, 2);
22-
assert.strictEqual(r3, 3);
18+
expect(r1).toBe(1);
19+
expect(r2).toBe(2);
20+
expect(r3).toBe(3);
2321

2422
const debouncedFn = Debouncer.promise(fn);
2523
// debounced fn should return the same results.
@@ -28,8 +26,8 @@ describe("Test common utils", () => {
2826
debouncedFn(),
2927
debouncedFn(),
3028
]);
31-
assert.strictEqual(r1, 4);
32-
assert.strictEqual(r2, 4);
33-
assert.strictEqual(r3, 4);
29+
expect(r1).toBe(4);
30+
expect(r2).toBe(4);
31+
expect(r3).toBe(4);
3432
});
3533
});

packages/cosmos/jest.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
preset: "ts-jest",
3+
testEnvironment: "node",
4+
testMatch: ["**/src/**/?(*.)+(spec|test).[jt]s?(x)"],
5+
};

packages/cosmos/package.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@
1212
"clean": "rm -rf node_modules; rm -rf build",
1313
"build": "tsc; mkdir -p build/stargate/proto/generated && cp ./src/stargate/proto/generated/* ./build/stargate/proto/generated",
1414
"dev": "tsc -w",
15-
"test": "mocha --timeout 30000 -r ts-node/register 'src/**/*.spec.ts'",
15+
"test": "jest --passWithNoTests",
1616
"lint-test": "eslint \"src/**/*\" && prettier --check \"src/**/*\"",
1717
"lint-fix": "eslint --fix \"src/**/*\" && prettier --write \"src/**/*\""
1818
},
19-
"devDependencies": {
20-
"mocha": "^8.2.1",
21-
"@types/mocha": "^5.2.7"
22-
},
19+
"devDependencies": {},
2320
"dependencies": {
2421
"@cosmjs/launchpad": "^0.24.0-alpha.25",
2522
"@keplr-wallet/common": "^0.8.6-rc.0",

packages/cosmos/src/noop.spec.ts

-1
This file was deleted.

packages/crypto/jest.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
preset: "ts-jest",
3+
testEnvironment: "node",
4+
testMatch: ["**/src/**/?(*.)+(spec|test).[jt]s?(x)"],
5+
};

packages/crypto/package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@
1212
"clean": "rm -rf node_modules; rm -rf build",
1313
"build": "tsc",
1414
"dev": "tsc -w",
15-
"test": "mocha --timeout 30000 -r ts-node/register 'src/**/*.spec.ts'",
15+
"test": "jest --passWithNoTests",
1616
"lint-test": "eslint \"src/**/*\" && prettier --check \"src/**/*\"",
1717
"lint-fix": "eslint --fix \"src/**/*\" && prettier --write \"src/**/*\""
1818
},
1919
"devDependencies": {
2020
"@keplr-wallet/cosmos": "^0.8.6-rc.0",
2121
"@types/crypto-js": "^4.0.1",
2222
"@types/elliptic": "^6.4.12",
23-
"@types/sha.js": "^2.4.0",
24-
"mocha": "^8.2.1",
25-
"@types/mocha": "^5.2.7"
23+
"@types/sha.js": "^2.4.0"
2624
},
2725
"dependencies": {
2826
"bip32": "^2.0.6",

packages/crypto/src/key.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import assert from "assert";
2-
import "mocha";
32
import { Mnemonic } from "./mnemonic";
43
import { PrivKeySecp256k1 } from "./key";
54
import { Bech32Address } from "@keplr-wallet/cosmos";

packages/crypto/src/noop.spec.ts

-1
This file was deleted.

packages/ens/jest.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
preset: "ts-jest",
3+
testEnvironment: "node",
4+
testMatch: ["**/src/**/?(*.)+(spec|test).[jt]s?(x)"],
5+
};

packages/ens/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"clean": "rm -rf node_modules; rm -rf build",
1313
"build": "tsc",
1414
"dev": "tsc -w",
15-
"test": "mocha --timeout 30000 -r ts-node/register 'src/**/*.spec.ts'",
15+
"test": "jest --passWithNoTests",
1616
"lint-test": "eslint \"src/**/*\" && prettier --check \"src/**/*\"",
1717
"lint-fix": "eslint --fix \"src/**/*\" && prettier --write \"src/**/*\""
1818
},

packages/ens/src/noop.spec.ts

-1
This file was deleted.

packages/extension/jest.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ module.exports = {
44
moduleNameMapper: {
55
"\\.(css|scss|sass)$": "identity-obj-proxy",
66
},
7+
testMatch: ["**/src/**/?(*.)+(spec|test).[jt]s?(x)"],
78
};

packages/extension/package.json

-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
"@types/chrome": "0.0.88",
6565
"@types/classnames": "^2.2.9",
6666
"@types/firefox-webext-browser": "^70.0.1",
67-
"@types/jest": "^26.0.22",
6867
"@types/js-yaml": "^4.0.0",
6968
"@types/react": "^16.14.4",
7069
"@types/react-dom": "^16.9.11",
@@ -78,12 +77,10 @@
7877
"fork-ts-checker-webpack-plugin": "^1.5.0",
7978
"html-webpack-plugin": "^3.2.0",
8079
"identity-obj-proxy": "^3.0.0",
81-
"jest": "^26.6.3",
8280
"node-sass": "^4.14.1",
8381
"sass-loader": "^7.3.1",
8482
"serialize-javascript": ">=3.1.0",
8583
"style-loader": "^1.0.0",
86-
"ts-jest": "^26.5.5",
8784
"webpack": "^4.39.2",
8885
"webpack-bundle-analyzer": "^3.9.0",
8986
"webpack-cli": "^3.3.7",

packages/extension/src/stores/root.tsx

+52-41
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ export class RootStore {
6767
);
6868

6969
this.keyRingStore = new KeyRingStore(
70+
{
71+
dispatchEvent: (type: string) => {
72+
window.dispatchEvent(new Event(type));
73+
},
74+
},
7075
this.chainStore,
7176
new InExtensionMessageRequester(),
7277
this.interactionStore
@@ -93,52 +98,57 @@ export class RootStore {
9398
mixInSecretQueries(mixInCosmosQueries(QueriesSetBase))
9499
);
95100

96-
this.accountStore = new AccountStore(this.chainStore, this.queriesStore, {
97-
defaultOpts: {
98-
// When the unlock request sent from external webpage,
99-
// it will open the extension popup below the uri "/unlock".
100-
// But, in this case, if the prefetching option is true, it will redirect
101-
// the page to the "/unlock" with **interactionInternal=true**
102-
// because prefetching will request the unlock from the internal.
103-
// To prevent this problem, just check the first uri is "#/unlcok" and
104-
// if it is "#/unlock", don't use the prefetching option.
105-
prefetching: !window.location.href.includes("#/unlock"),
106-
},
107-
chainOpts: this.chainStore.chainInfos.map((chainInfo) => {
108-
// In certik, change the msg type of the MsgSend to "bank/MsgSend"
109-
if (chainInfo.chainId.startsWith("shentu-")) {
110-
return {
111-
chainId: chainInfo.chainId,
112-
msgOpts: {
113-
send: {
114-
native: {
115-
type: "bank/MsgSend",
101+
this.accountStore = new AccountStore(
102+
window,
103+
this.chainStore,
104+
this.queriesStore,
105+
{
106+
defaultOpts: {
107+
// When the unlock request sent from external webpage,
108+
// it will open the extension popup below the uri "/unlock".
109+
// But, in this case, if the prefetching option is true, it will redirect
110+
// the page to the "/unlock" with **interactionInternal=true**
111+
// because prefetching will request the unlock from the internal.
112+
// To prevent this problem, just check the first uri is "#/unlcok" and
113+
// if it is "#/unlock", don't use the prefetching option.
114+
prefetching: !window.location.href.includes("#/unlock"),
115+
},
116+
chainOpts: this.chainStore.chainInfos.map((chainInfo) => {
117+
// In certik, change the msg type of the MsgSend to "bank/MsgSend"
118+
if (chainInfo.chainId.startsWith("shentu-")) {
119+
return {
120+
chainId: chainInfo.chainId,
121+
msgOpts: {
122+
send: {
123+
native: {
124+
type: "bank/MsgSend",
125+
},
116126
},
117127
},
118-
},
119-
};
120-
}
121-
122-
// In akash or sifchain, increase the default gas for sending
123-
if (
124-
chainInfo.chainId.startsWith("akashnet-") ||
125-
chainInfo.chainId.startsWith("sifchain")
126-
) {
127-
return {
128-
chainId: chainInfo.chainId,
129-
msgOpts: {
130-
send: {
131-
native: {
132-
gas: 120000,
128+
};
129+
}
130+
131+
// In akash or sifchain, increase the default gas for sending
132+
if (
133+
chainInfo.chainId.startsWith("akashnet-") ||
134+
chainInfo.chainId.startsWith("sifchain")
135+
) {
136+
return {
137+
chainId: chainInfo.chainId,
138+
msgOpts: {
139+
send: {
140+
native: {
141+
gas: 120000,
142+
},
133143
},
134144
},
135-
},
136-
};
137-
}
145+
};
146+
}
138147

139-
return { chainId: chainInfo.chainId };
140-
}),
141-
});
148+
return { chainId: chainInfo.chainId };
149+
}),
150+
}
151+
);
142152

143153
this.priceStore = new CoinGeckoPriceStore(
144154
new ExtensionKVStore("store_prices"),
@@ -151,6 +161,7 @@ export class RootStore {
151161
);
152162

153163
this.tokensStore = new TokensStore(
164+
window,
154165
this.chainStore,
155166
new InExtensionMessageRequester(),
156167
this.interactionStore

packages/hooks/jest.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
preset: "ts-jest",
3+
testEnvironment: "node",
4+
testMatch: ["**/src/**/?(*.)+(spec|test).[jt]s?(x)"],
5+
};

packages/hooks/package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@
1212
"clean": "rm -rf node_modules; rm -rf build",
1313
"build": "tsc",
1414
"dev": "tsc -w",
15-
"test": "mocha -r ts-node/register 'src/**/*.spec.ts'",
15+
"test": "jest --passWithNoTests",
1616
"lint-test": "eslint \"src/**/*\" && prettier --check \"src/**/*\"",
1717
"lint-fix": "eslint --fix \"src/**/*\" && prettier --write \"src/**/*\""
1818
},
1919
"devDependencies": {
20-
"@types/react": "^16.14.4",
21-
"mocha": "^8.2.1",
22-
"@types/mocha": "^5.2.7"
20+
"@types/react": "^16.14.4"
2321
},
2422
"dependencies": {
2523
"@cosmjs/launchpad": "^0.24.0-alpha.25",

packages/hooks/src/noop.spec.ts

-1
This file was deleted.

packages/popup/jest.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
preset: "ts-jest",
3+
testEnvironment: "node",
4+
testMatch: ["**/src/**/?(*.)+(spec|test).[jt]s?(x)"],
5+
};

packages/popup/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"clean": "rm -rf node_modules; rm -rf build",
1313
"build": "tsc",
1414
"dev": "tsc -w",
15-
"test": "mocha -r ts-node/register 'src/**/*.spec.ts'",
15+
"test": "jest --passWithNoTests",
1616
"lint-test": "eslint \"src/**/*\" && prettier --check \"src/**/*\"",
1717
"lint-fix": "eslint --fix \"src/**/*\" && prettier --write \"src/**/*\""
1818
}

packages/popup/src/noop.spec.ts

-1
This file was deleted.

0 commit comments

Comments
 (0)