Useful methods for file-related functions.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
932 B

  1. import * as fc from 'fast-check'
  2. import Blob from './Blob'
  3. jest.mock('./isBrowser', function IsBrowser() {
  4. return () => false
  5. })
  6. it('should exist', () => {
  7. expect(Blob).toBeDefined()
  8. })
  9. it('should be a callable', () => {
  10. expect(typeof Blob).toBe('function')
  11. })
  12. describe('instances', () => {
  13. it('should contain a type', () => {
  14. fc.assert(
  15. fc.property(
  16. fc.tuple(
  17. fc.oneof(
  18. fc.constant('application'),
  19. fc.constant('font'),
  20. fc.constant('audio'),
  21. fc.constant('model'),
  22. fc.constant('video'),
  23. fc.constant('text')
  24. ),
  25. fc.string().filter(s => /^[a-zA-Z0-9._-]+$/.test(s))
  26. ),
  27. mimeTypeFragments => {
  28. const file = new Blob([], { type: mimeTypeFragments.join('/') })
  29. expect(file).toHaveProperty('type', mimeTypeFragments.join('/').toLowerCase())
  30. }
  31. )
  32. )
  33. })
  34. })