util.spec.js 929 B

1234567891011121314151617181920212223242526272829
  1. import WaveSurfer from '../src/wavesurfer.js';
  2. /** @test {util} */
  3. describe('util:', function() {
  4. /** @test {getId} */
  5. it('getId returns a random string', function() {
  6. expect(WaveSurfer.util.getId()).toStartWith('wavesurfer_');
  7. });
  8. /** @test {min} */
  9. it('min returns the smallest number in the provided array', function() {
  10. expect(WaveSurfer.util.min([0, 1, 1.1, 100, -1])).toEqual(-1);
  11. });
  12. /** @test {min} */
  13. it('min returns +Infinity for an empty array', function() {
  14. expect(WaveSurfer.util.min([])).toEqual(+Infinity);
  15. });
  16. /** @test {max} */
  17. it('max returns the largest number in the provided array', function() {
  18. expect(WaveSurfer.util.max([0, 1, 1.1, 100, -1])).toEqual(100);
  19. });
  20. /** @test {max} */
  21. it('max returns -Infinity for an empty array', function() {
  22. expect(WaveSurfer.util.max([])).toEqual(-Infinity);
  23. });
  24. });