Skip to content

Commit

Permalink
Tests: splitAsync tests share setup between tests
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Dec 30, 2022
1 parent 200a643 commit 6085ba5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions test/splitAsync.test.js
Expand Up @@ -44,7 +44,7 @@ describe('splitAsync', () => {
function runTests(createImport, isNativeImport) {
describe('1 call', () => {
let val, importFn, mod;
beforeEach(async () => {
beforeAll(async () => {
({val, importFn} = createImport());
mod = await importFn();
});
Expand Down Expand Up @@ -147,7 +147,7 @@ function runTests(createImport, isNativeImport) {

describe('multiple calls with different values', () => {
let vals, importFns;
beforeEach(() => {
beforeAll(() => {
vals = [];
importFns = [];
for (let index = 0; index < NUM_FIXTURES; index++) {
Expand All @@ -163,7 +163,7 @@ function runTests(createImport, isNativeImport) {

describe('when called synchronously', () => {
let promises, modules;
beforeEach(async () => {
beforeAll(async () => {
promises = importFns.map(importFn => importFn());
modules = await Promise.all(promises);
});
Expand All @@ -185,7 +185,7 @@ function runTests(createImport, isNativeImport) {

describe('when called asynchronously', () => {
let promises, modules;
beforeEach(async () => {
beforeAll(async () => {
promises = [];
modules = [];
for (const importFn of importFns) {
Expand Down Expand Up @@ -215,7 +215,7 @@ function runTests(createImport, isNativeImport) {

describe('multiple calls with same value', () => {
let val, importFns;
beforeEach(() => {
beforeAll(() => {
const values = [];
val = {x: 0};
importFns = [];
Expand All @@ -233,7 +233,7 @@ function runTests(createImport, isNativeImport) {

describe('when called synchronously', () => {
let promises, modules;
beforeEach(async () => {
beforeAll(async () => {
promises = importFns.map(importFn => importFn());
modules = await Promise.all(promises);
});
Expand All @@ -255,7 +255,7 @@ function runTests(createImport, isNativeImport) {

describe('when called asynchronously', () => {
let promises, modules;
beforeEach(async () => {
beforeAll(async () => {
promises = [];
modules = [];
for (const importFn of importFns) {
Expand Down

0 comments on commit 6085ba5

Please sign in to comment.