Add environment type check to tests (#344)

This commit is contained in:
Jaco
2022-05-11 12:10:44 +02:00
committed by GitHub
parent a85615f12b
commit b01f35cde5
2 changed files with 7 additions and 3 deletions

View File

@@ -1,6 +1,8 @@
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
const { assert } = require('@polkadot/util');
const wasm = require('../../build');
const bip39 = require('./bip39.cjs');
const ed25519 = require('./ed25519.cjs');
@@ -21,11 +23,13 @@ const tests = {
...hashing
};
async function beforeAll () {
async function beforeAll (name) {
const result = await wasm.waitReady();
console.log(`*** waitReady()=${result} for ${wasm.__bridge.type}`);
assert(name.toLowerCase() === wasm.__bridge.type, `Incorrect environment laucnhed, expected ${name.toLowerCase()}, found ${wasm.__bridge.type}`);
return result;
}
@@ -62,7 +66,7 @@ function runAll (name) {
function runUnassisted (name) {
console.log(`\n*** ${name}: Running tests`);
beforeAll()
beforeAll(name)
.then(() => runAll(name))
.then(() => {
console.log(`\n*** ${name}: All passed`);

View File

@@ -9,7 +9,7 @@ import { beforeAll as beforeAllFn, tests, wasm } from './all/index.cjs';
describe('wasm-crypto', () => {
beforeAll(async () => {
await beforeAllFn();
await beforeAllFn('wasm');
});
Object.keys(tests).forEach((name) => {