Simple monitor for displaying MIDI status for digital pianos.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

isNaturalKey.test.ts 1.7 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import * as fc from 'fast-check'
  2. import isNaturalKey from './isNaturalKey'
  3. it('should exist', () => {
  4. expect(isNaturalKey).toBeDefined()
  5. })
  6. it('should be a callable', () => {
  7. expect(typeof isNaturalKey).toBe('function')
  8. })
  9. it('should accept 1 parameter', () => {
  10. expect(isNaturalKey).toHaveLength(1)
  11. })
  12. it('should throw TypeError upon passing invalid types', () => {
  13. fc.assert(
  14. fc.property(
  15. fc.anything().filter((anything) => typeof anything !== 'number'),
  16. (anything) => {
  17. expect(() => isNaturalKey(anything as number)).toThrowError(TypeError)
  18. },
  19. ),
  20. )
  21. })
  22. it('should throw RangeError upon passing NaN', () => {
  23. expect(() => isNaturalKey(NaN)).toThrowError(RangeError)
  24. })
  25. it('should throw RangeError upon passing negative numbers', () => {
  26. fc.assert(
  27. fc.property(
  28. fc.anything().filter((anything) => typeof anything! === 'number' && !isNaN(anything) && anything < 0),
  29. (negativeValue) => {
  30. expect(() => isNaturalKey(negativeValue as number)).toThrowError(RangeError)
  31. },
  32. ),
  33. )
  34. })
  35. describe('upon passing a positive number or zero', () => {
  36. it('should not throw any error', () => {
  37. fc.assert(
  38. fc.property(
  39. fc.anything().filter((anything) => typeof anything! === 'number' && !isNaN(anything) && anything >= 0),
  40. (value) => {
  41. expect(() => isNaturalKey(value as number)).not.toThrow()
  42. },
  43. ),
  44. )
  45. })
  46. it('should return a boolean', () => {
  47. fc.assert(
  48. fc.property(
  49. fc.anything().filter((anything) => typeof anything! === 'number' && !isNaN(anything) && anything >= 0),
  50. (value) => {
  51. expect(typeof isNaturalKey(value as number)).toBe('boolean')
  52. },
  53. ),
  54. )
  55. })
  56. })