Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function() {
return fc.assert(
fc.asyncProperty(
fc.anything(),
async (anything: any) => {
let input = anything
const output = await PromiseWorker(
input
)
expect(input).toEqual(
output
)
}
),
{ numRuns: 10000 }
)
},
10 * 1000 // 10s
it('should display more and more sugestions as results come', () =>
fc.assert(
fc
.asyncProperty(AllResultsArbitrary, QueriesArbitrary, fc.scheduler({ act }), async (allResults, queries, s) => {
// Arrange
const query = queries[queries.length - 1];
const searchImplem: typeof search = s.scheduleFunction(function search(query, maxResults) {
return Promise.resolve(allResults.filter(r => r.includes(query)).slice(0, maxResults));
});
// Act
const { getByRole, queryAllByRole } = render();
const input = getByRole('input') as HTMLElement;
for (const event of buildAutocompleteEvents(input, queries)) {
await event.builder();
} // All the user's inputs have been fired onto the AutocompleField
// Assert
let suggestions: string[] = [];
it("- composition", () =>
fc.assert(
fc.asyncProperty(
arbIO(fc.string()),
fc.constant(strlen),
fc.constant(even),
functor.composition
)
)
);
it("any number of successful IOs surrounding a failed IO produces the error of the failed IO", () =>
fc.assert(
fc.asyncProperty(
fc.array(arbIO(fc.integer())),
arbErrorIO(fc.constant("failure")),
fc.array(arbIO(fc.integer())),
(before, err, after) => {
const arr = [...before, err, ...after]
const result = array.sequence(io.instances)(arr)
return eqvIO(result, io.as(err, [] as number[]));
}
)
)
);
it("uninterruptible fibers are not interruptible", () =>
fc.assert(
fc.asyncProperty(
fc.nat(50),
(delay) =>
expectExit(
io.chain(
makeDeferred(),
(latch) =>
io.chain(makeRef(false),
(cell) =>
io.chain(
io.fork(
io.uninterruptible(io.applySecond(latch.wait, cell.set(true)))
),
(child) =>
io.applySecond(
io.fork(io.shiftAsyncBefore(child.interrupt)),
io.applySecond(
it("allows for multiple fibers to coordinate", () =>
fc.assert(
fc.asyncProperty(
fc.nat(50),
(delay) =>
expectExit(
io.chain(makeDeferred(),
(def) =>
io.applySecond(
io.fork(io.delay(def.done(42), delay)),
def.wait
)
),
done(42)
)
)
)
);
it('/api/comment', async () =>
await fc.assert(
fc.asyncProperty(
inferPayloadArbitrary(
{
user: { login: 'toto' },
comment: { message: 'lorem ipsum', postId: 5, commentId: 8, public: false, details: ['', 5] }
},
true,
true
),
async payload => {
await throwIfHttpFailed(httpPost(server, '/api/comment', payload));
}
),
{ timeout: 100 }
));
});
it("- homomorphism", () =>
fc.assert(
fc.asyncProperty(
fc.constant(strlen),
fc.string(),
applicative.homomorphism
)
)
);
it("- interchange", () =>
fc.assert(
fc.asyncProperty(
fc.string(),
arbIO(fc.constant(strlen)),
applicative.interchange
)
)
);
it(" - derived map", () =>
fc.assert(
fc.asyncProperty(
fc.constant(strlen),
arbIO(fc.string()),
monad.derivedMap
)
)
);