aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2022-03-26 00:07:57 +0100
committerGitHub <[email protected]>2022-03-26 00:07:57 +0100
commite62fd15cc7b83cc314a22ad9b13cd68f222d4076 (patch)
tree7ba7a2195c2b4beba5f030d0cbdcefc088d631fc
parent9291b621d5e96826970c754172595ea922625b85 (diff)
downloadfaker-e62fd15cc7b83cc314a22ad9b13cd68f222d4076.tar.xz
faker-e62fd15cc7b83cc314a22ad9b13cd68f222d4076.zip
test: fix flaky unique test coverage (#667)
-rw-r--r--test/unique.spec.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/unique.spec.ts b/test/unique.spec.ts
index 483fe05e..f222b7ce 100644
--- a/test/unique.spec.ts
+++ b/test/unique.spec.ts
@@ -133,4 +133,21 @@ describe('unique', () => {
});
expect(result).toBe('http');
});
+
+ it('no conflict', () => {
+ let i = 0;
+ const method = () => `no conflict: ${i++}`;
+ expect(faker.unique(method)).toBe('no conflict: 0');
+ expect(faker.unique(method)).toBe('no conflict: 1');
+ });
+
+ it('with conflict', () => {
+ const method = () => 'with conflict: 0';
+ expect(faker.unique(method)).toBe('with conflict: 0');
+ expect(() =>
+ faker.unique(method, [], {
+ maxRetries: 1,
+ })
+ ).toThrow();
+ });
});