shallow.spec.js 923 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import {
  2. shallowEqual
  3. } from '../../src/PureComponent'
  4. describe('shallowEqual', function () {
  5. it('shallowEqual', async () => {
  6. expect(shallowEqual(1, 1)).toBe(true)
  7. // expect(shallowEqual(-0, +0)).toBe(false)
  8. expect(shallowEqual(NaN, NaN)).toBe(true)
  9. expect(shallowEqual({}, {})).toBe(true)
  10. // expect(shallowEqual({
  11. // a: {}
  12. // }, {
  13. // a: {}
  14. // })).toBe(false)
  15. expect(shallowEqual({
  16. a: 1,
  17. b: 2
  18. }, {
  19. a: 1,
  20. b: 2,
  21. c: 3,
  22. d: 4
  23. })).toBe(false)
  24. var b = {}
  25. expect(shallowEqual({
  26. a: b
  27. }, {
  28. a: b
  29. })).toBe(true)
  30. expect(shallowEqual([
  31. 1, 2, 3
  32. ], [4, 5, 6])).toBe(false)
  33. expect(shallowEqual([
  34. 1, 2, 3
  35. ], [1, 2, 3])).toBe(true)
  36. })
  37. })