Common front-end components for Web using the Tesseract design system, written for React. https://make.modal.sh/tesseract/web/react/common
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import * as fc from 'fast-check'
  2. import * as fcArb from '../../utilities/fast-check/arbitraries'
  3. import stringify from './stringify'
  4. it('should exist', () => {
  5. expect(stringify).toBeDefined()
  6. })
  7. it('should be a function', () => {
  8. expect(stringify).toBeFunction()
  9. })
  10. it('should accept 1 argument', () => {
  11. expect(stringify).toHaveLength(1)
  12. })
  13. it('should return a string value', () => {
  14. fc.assert(
  15. fc.property(fc.anything(), (v) => {
  16. expect(stringify(v)).toBeString()
  17. }),
  18. )
  19. })
  20. describe('on arguments', () => {
  21. it('should consider `undefined` as empty string', () => {
  22. expect(stringify(undefined)).toBe('')
  23. })
  24. it('should consider `null` as empty string', () => {
  25. expect(stringify(null)).toBe('')
  26. })
  27. it('should stringify non-objects', () => {
  28. fc.assert(
  29. fc.property(fcArb.nonObject(), fc.string(), (v) => {
  30. expect(stringify(v)).toBe(String(v))
  31. }),
  32. )
  33. })
  34. it('should stringify objects', () => {
  35. fc.assert(
  36. fc.property(fc.object(), (v) => {
  37. expect(stringify(v)).toBe(JSON.stringify(v))
  38. }),
  39. )
  40. })
  41. describe('on arrays', () => {
  42. it('should stringify empty arrays', () => {
  43. fc.assert(
  44. fc.property(fc.array(fcArb.nonObject(), 0), (v) => {
  45. expect(stringify(v)).toBe('')
  46. }),
  47. )
  48. })
  49. it('should stringify arrays with single values', () => {
  50. fc.assert(
  51. fc.property(fc.array(fcArb.nonObject(), 1, 1), (v) => {
  52. expect(stringify(v)).toBe(String(v[0]))
  53. }),
  54. )
  55. })
  56. it('should stringify arrays with 2 or more values', () => {
  57. fc.assert(
  58. fc.property(fc.array(fcArb.nonObject(), 2, 20), (v) => {
  59. expect(stringify(v)).toContain(',')
  60. }),
  61. )
  62. })
  63. })
  64. })