of.js 882 B

1234567891011121314151617181920212223242526272829303132
  1. import assert from 'assert';
  2. import { testMethodProperty } from './properties.js';
  3. describe('of', () => {
  4. it('is a method on Observable', () => {
  5. testMethodProperty(Observable, 'of', {
  6. configurable: true,
  7. writable: true,
  8. length: 0,
  9. });
  10. });
  11. it('uses the this value if it is a function', () => {
  12. let usesThis = false;
  13. Observable.of.call(function() { usesThis = true; });
  14. assert.ok(usesThis);
  15. });
  16. it('uses Observable if the this value is not a function', () => {
  17. let result = Observable.of.call({}, 1, 2, 3, 4);
  18. assert.ok(result instanceof Observable);
  19. });
  20. it('delivers arguments to next in a job', async () => {
  21. let values = [];
  22. let turns = 0;
  23. Observable.of(1, 2, 3, 4).subscribe(v => values.push(v));
  24. assert.equal(values.length, 0);
  25. await null;
  26. assert.deepEqual(values, [1, 2, 3, 4]);
  27. });
  28. });