|
1 | 1 | import { expect } from 'chai';
|
2 | 2 | import { Subject, Observable, AsyncSubject, Observer, of, config, Subscription, Subscriber, noop, operate } from 'rxjs';
|
3 |
| -import { AnonymousSubject } from 'rxjs/internal/Subject'; |
4 | 3 | import { delay } from 'rxjs/operators';
|
5 | 4 | import { TestScheduler } from 'rxjs/testing';
|
6 | 5 | import { observableMatcher } from './helpers/observableMatcher';
|
@@ -448,104 +447,6 @@ describe('Subject', () => {
|
448 | 447 | expect(subject.observed).to.equal(false);
|
449 | 448 | });
|
450 | 449 |
|
451 |
| - it('should have a static create function that works', () => { |
452 |
| - expect(Subject.create).to.be.a('function'); |
453 |
| - const source = of(1, 2, 3, 4, 5); |
454 |
| - const nexts: number[] = []; |
455 |
| - const output: any[] = []; |
456 |
| - |
457 |
| - let error: any; |
458 |
| - let complete = false; |
459 |
| - let outputComplete = false; |
460 |
| - |
461 |
| - const destination = { |
462 |
| - closed: false, |
463 |
| - next: function (x: number) { |
464 |
| - nexts.push(x); |
465 |
| - }, |
466 |
| - error: function (err: any) { |
467 |
| - error = err; |
468 |
| - this.closed = true; |
469 |
| - }, |
470 |
| - complete: function () { |
471 |
| - complete = true; |
472 |
| - this.closed = true; |
473 |
| - }, |
474 |
| - }; |
475 |
| - |
476 |
| - const sub: Subject<any> = Subject.create(destination, source); |
477 |
| - |
478 |
| - sub.subscribe({ |
479 |
| - next: function (x: number) { |
480 |
| - output.push(x); |
481 |
| - }, |
482 |
| - complete: () => { |
483 |
| - outputComplete = true; |
484 |
| - }, |
485 |
| - }); |
486 |
| - |
487 |
| - sub.next('a'); |
488 |
| - sub.next('b'); |
489 |
| - sub.next('c'); |
490 |
| - sub.complete(); |
491 |
| - |
492 |
| - expect(nexts).to.deep.equal(['a', 'b', 'c']); |
493 |
| - expect(complete).to.be.true; |
494 |
| - expect(error).to.be.a('undefined'); |
495 |
| - |
496 |
| - expect(output).to.deep.equal([1, 2, 3, 4, 5]); |
497 |
| - expect(outputComplete).to.be.true; |
498 |
| - }); |
499 |
| - |
500 |
| - it('should have a static create function that works also to raise errors', () => { |
501 |
| - expect(Subject.create).to.be.a('function'); |
502 |
| - const source = of(1, 2, 3, 4, 5); |
503 |
| - const nexts: number[] = []; |
504 |
| - const output: number[] = []; |
505 |
| - |
506 |
| - let error: any; |
507 |
| - let complete = false; |
508 |
| - let outputComplete = false; |
509 |
| - |
510 |
| - const destination = { |
511 |
| - closed: false, |
512 |
| - next: function (x: number) { |
513 |
| - nexts.push(x); |
514 |
| - }, |
515 |
| - error: function (err: any) { |
516 |
| - error = err; |
517 |
| - this.closed = true; |
518 |
| - }, |
519 |
| - complete: function () { |
520 |
| - complete = true; |
521 |
| - this.closed = true; |
522 |
| - }, |
523 |
| - }; |
524 |
| - |
525 |
| - const sub: Subject<any> = Subject.create(destination, source); |
526 |
| - |
527 |
| - sub.subscribe({ |
528 |
| - next: function (x: number) { |
529 |
| - output.push(x); |
530 |
| - }, |
531 |
| - complete: () => { |
532 |
| - outputComplete = true; |
533 |
| - }, |
534 |
| - }); |
535 |
| - |
536 |
| - sub.next('a'); |
537 |
| - sub.next('b'); |
538 |
| - sub.next('c'); |
539 |
| - sub.error('boom'); |
540 |
| - |
541 |
| - expect(nexts).to.deep.equal(['a', 'b', 'c']); |
542 |
| - expect(complete).to.be.false; |
543 |
| - expect(error).to.equal('boom'); |
544 |
| - |
545 |
| - expect(output).to.deep.equal([1, 2, 3, 4, 5]); |
546 |
| - expect(outputComplete).to.be.true; |
547 |
| - }); |
548 |
| - |
549 | 450 | it('should be an Observer which can be given to Observable.subscribe', (done) => {
|
550 | 451 | const source = of(1, 2, 3, 4, 5);
|
551 | 452 | const subject = new Subject<number>();
|
@@ -781,30 +682,3 @@ describe('Subject', () => {
|
781 | 682 | expect(results).to.deep.equal([1, 1, 2, 2, 'complete']);
|
782 | 683 | });
|
783 | 684 | });
|
784 |
| - |
785 |
| -describe('AnonymousSubject', () => { |
786 |
| - it('should be exposed', () => { |
787 |
| - expect(AnonymousSubject).to.be.a('function'); |
788 |
| - }); |
789 |
| - |
790 |
| - it('should not be eager', () => { |
791 |
| - let subscribed = false; |
792 |
| - |
793 |
| - const subject = Subject.create( |
794 |
| - null, |
795 |
| - new Observable((observer: Observer<any>) => { |
796 |
| - subscribed = true; |
797 |
| - const subscription = of('x').subscribe(observer); |
798 |
| - return () => { |
799 |
| - subscription.unsubscribe(); |
800 |
| - }; |
801 |
| - }) |
802 |
| - ); |
803 |
| - |
804 |
| - const observable = subject.asObservable(); |
805 |
| - expect(subscribed).to.be.false; |
806 |
| - |
807 |
| - observable.subscribe(); |
808 |
| - expect(subscribed).to.be.true; |
809 |
| - }); |
810 |
| -}); |
0 commit comments