diff options
| author | Leyla Jähnig <[email protected]> | 2022-03-21 14:19:36 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-03-21 13:19:36 +0000 |
| commit | 9ab0825add89474635bcc3b60595abd584088138 (patch) | |
| tree | 1143b246137d93a35b357e320cd8e3d89bbf5d1a /test | |
| parent | 486c76e34f22cf1fd66fa2c99e605d52c7077760 (diff) | |
| download | faker-9ab0825add89474635bcc3b60595abd584088138.tar.xz faker-9ab0825add89474635bcc3b60595abd584088138.zip | |
refactor: make number input immutable (#545)
Co-authored-by: Leyla Jähnig <[email protected]>
Diffstat (limited to 'test')
| -rw-r--r-- | test/datatype.spec.ts | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/test/datatype.spec.ts b/test/datatype.spec.ts index bee280d7..35ac512f 100644 --- a/test/datatype.spec.ts +++ b/test/datatype.spec.ts @@ -445,18 +445,27 @@ describe('datatype', () => { } }); - it('should not modify the input object', () => { - const min = 1; - const max = 2; - const opts = { - min: min, - max: max, + it('should not mutate the input object', () => { + const initalMin = 1; + const initalPrecision = 1; + const initalOtherProperty = 'hello darkness my old friend'; + const input: { + min?: number; + max?: number; + precision?: number; + otherProperty: string; + } = { + min: initalMin, + precision: initalPrecision, + otherProperty: initalOtherProperty, }; - faker.datatype.number(opts); + faker.datatype.number(input); - expect(opts.min).toBe(min); - expect(opts.max).toBe(max); + expect(input.min).toBe(initalMin); + expect(input.precision).toBe(initalPrecision); + expect(input.max).toBe(undefined); + expect(input.otherProperty).toBe(initalOtherProperty); }); }); |
