arrays.test.ts 596 B

1234567891011121314151617181920
  1. import { describe, expect, it } from 'vitest'
  2. import { castArray as lodashCastArray } from 'lodash-es'
  3. import { castArray, ensureArray, unique } from '..'
  4. describe('arrays', () => {
  5. it('unique should work', () => {
  6. expect(unique([1, 2, 3, 1])).toEqual([1, 2, 3])
  7. expect(unique([1, 2, 3])).toEqual([1, 2, 3])
  8. })
  9. it('castArray should work', () => {
  10. expect(castArray([1, 2, 3])).toEqual([1, 2, 3])
  11. expect(castArray(0)).toEqual([0])
  12. expect(castArray(undefined)).toEqual([])
  13. })
  14. it('re-export ensureArray', () => {
  15. expect(ensureArray).toBe(lodashCastArray)
  16. })
  17. })