1
0
Files
sashinexists/node_modules/promise-make-counter/test/index.js
2024-12-07 13:18:31 +11:00

53 lines
806 B
JavaScript

/* IMPORT */
import {describe} from 'fava';
import makeCounterPromise from '../dist/index.js';
/* MAIN */
describe ( 'Promise Make Counter', it => {
it ( 'resolves without increments', async t => {
const {isPending} = makeCounterPromise ();
t.true ( isPending () );
await t.wait ( 0 );
t.false ( isPending () );
});
it ( 'resolves after equal increments and decrements', async t => {
const {isPending, increment, decrement} = makeCounterPromise ();
t.true ( isPending () );
increment ();
increment ();
increment ();
await t.wait ( 0 );
t.true ( isPending () );
decrement ();
decrement ();
await t.wait ( 0 );
t.true ( isPending () );
decrement ();
await t.wait ( 0 );
t.false ( isPending () );
});
});