Skip to content

Commit

Permalink
tests(vest): make test.memo test more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed May 12, 2022
1 parent 6397275 commit 6a67315
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions packages/vest/src/core/test/__tests__/memo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,36 +76,33 @@ describe('test.memo', () => {
describe('async', () => {
it('Should immediately return previous result on re-run', async () => {
{
const suite = promisify(
vest.create(() => {
vestTest.memo(
'field1',
async () => {
await wait(500);
enforce(1).equals(2);
},
[1]
);
vestTest.memo(
'field2',
async () => {
await wait(500);
enforce(1).equals(2);
},
[2]
);
})
);
const suite = vest.create(() => {
vestTest.memo(
'field1',
async () => {
await wait(500);
enforce(1).equals(2);
},
[1]
);
vestTest.memo(
'field2',
async () => {
await wait(500);
enforce(1).equals(2);
},
[2]
);
});

const asyncSuite = promisify(suite);

let start = Date.now();
const res1 = await suite();
const res1 = await asyncSuite();
enforce(Date.now() - start).gte(500);

start = Date.now();
const res2 = await suite();

// Should be immediate
enforce(Date.now() - start).lte(1);
const res2 = suite();

expect(res1).isDeepCopyOf(res2);
}
Expand Down

1 comment on commit 6a67315

@vercel
Copy link

@vercel vercel bot commented on 6a67315 May 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vest-next – ./website

vest-next.vercel.app
vest-website.vercel.app
vest-next-git-latest-ealush.vercel.app
vest-next-ealush.vercel.app

Please sign in to comment.