Skip to content

Commit e62fd15

Browse files
authored
test: fix flaky unique test coverage (#667)
1 parent 9291b62 commit e62fd15

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/unique.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,21 @@ describe('unique', () => {
133133
});
134134
expect(result).toBe('http');
135135
});
136+
137+
it('no conflict', () => {
138+
let i = 0;
139+
const method = () => `no conflict: ${i++}`;
140+
expect(faker.unique(method)).toBe('no conflict: 0');
141+
expect(faker.unique(method)).toBe('no conflict: 1');
142+
});
143+
144+
it('with conflict', () => {
145+
const method = () => 'with conflict: 0';
146+
expect(faker.unique(method)).toBe('with conflict: 0');
147+
expect(() =>
148+
faker.unique(method, [], {
149+
maxRetries: 1,
150+
})
151+
).toThrow();
152+
});
136153
});

0 commit comments

Comments
 (0)