Skip to content
Myr

chore(test): fix unit test for 0 vs -0 and clarify

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Michel Weststrate · committed by Michel Weststrate · parent 6ec0106 · Browse files · 1 file+13 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+13 added−1 removed

  • tests:+13 added−1 removed

1 file+13 added−1 removed

modified:__tests__/base.js+13 added-1 removed
1276 unmodified lines
1277 }1278 const nextState = produce(baseState, draft => {1279 draft.x = +01280 })1281 // 0 === -0 // true1282 // Object.is(0, -0) // false1283 //1284 // MWE:1285 // Immer preserves the difference between -0 and +0,1286 // so a new state is created.1287 // This isn't defined anywhere explicitly, so could be changed1288 // in the future to follow === behavior, rather than Object.is.1289 // But I think this is fine as is.1290 expect(nextState).not.toBe(baseState)1282 expect(nextState).not.toEqual(baseState)1291 expect(nextState.x).toBe(-0)1292 expect(nextState.x).not.toBe(+0)1293 // however, toEqual treats -0 === +0 (which is true!)1294 expect(nextState).toEqual(baseState)1295 })12961297 it("should handle equality correctly - 3", () => {1298 const baseState = {
1200 unmodified lines