combine-latest.js 878 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import assert from 'assert';
  2. import { parse } from './parse.js';
  3. import { combineLatest } from '../../src/extras.js';
  4. describe('extras/combineLatest', () => {
  5. it('should emit arrays containing the most recent values', async () => {
  6. let output = [];
  7. await combineLatest(
  8. parse('a-b-c-d'),
  9. parse('-A-B-C-D')
  10. ).forEach(
  11. value => output.push(value.join(''))
  12. );
  13. assert.deepEqual(output, [
  14. 'aA',
  15. 'bA',
  16. 'bB',
  17. 'cB',
  18. 'cC',
  19. 'dC',
  20. 'dD',
  21. ]);
  22. });
  23. it('should emit values in the correct order', async () => {
  24. let output = [];
  25. await combineLatest(
  26. parse('-a-b-c-d'),
  27. parse('A-B-C-D')
  28. ).forEach(
  29. value => output.push(value.join(''))
  30. );
  31. assert.deepEqual(output, [
  32. 'aA',
  33. 'aB',
  34. 'bB',
  35. 'bC',
  36. 'cC',
  37. 'cD',
  38. 'dD',
  39. ]);
  40. });
  41. });