diff options
| author | Shinigami <[email protected]> | 2022-04-22 14:45:35 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-04-22 12:45:35 +0000 |
| commit | 29bba7be530d2e11c56de021fc67a9641b2e6e0d (patch) | |
| tree | b6ac672ff4665bc43fbef44bd28949ec58280aa6 /test | |
| parent | a9048f8642bc045bb1e24abed7d54327f14981b7 (diff) | |
| download | faker-29bba7be530d2e11c56de021fc67a9641b2e6e0d.tar.xz faker-29bba7be530d2e11c56de021fc67a9641b2e6e0d.zip | |
feat: resettable unique store (#800)
Diffstat (limited to 'test')
| -rw-r--r-- | test/unique.spec.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/unique.spec.ts b/test/unique.spec.ts index 6f26a0c5..07123166 100644 --- a/test/unique.spec.ts +++ b/test/unique.spec.ts @@ -210,4 +210,20 @@ Try adjusting maxTime or maxRetries parameters for faker.unique().`) expect(options.exclude).toBe(exclude); expect(options.compare).toBe(compare); }); + + it('should be possible to pass a user-specific store', () => { + const store = {}; + + const method = () => 'with conflict: 0'; + + expect(faker.unique(method, [], { store })).toBe('with conflict: 0'); + expect(store).toEqual({ 'with conflict: 0': 'with conflict: 0' }); + + expect(() => faker.unique(method, [], { store })).toThrow(); + + delete store['with conflict: 0']; + + expect(faker.unique(method, [], { store })).toBe('with conflict: 0'); + expect(store).toEqual({ 'with conflict: 0': 'with conflict: 0' }); + }); }); |
