hunk.code_window:     expect(offHandler).to.equal(onHandler);
     });
     it('should pass through options to addEventListener', () => {
       let actualOptions;
       const expectedOptions = { capture: true, passive: true };
  
hunk.labels: keep keep add keep keep keep
hunk.after_edit:   it('should error on invalid event targets', () => {
       const obj = {
         addListener: () => {
           //noop
         }
       };
       const subscribe = () => Observable.fromEvent(<any>obj, 'click').subscribe();
       expect(subscribe).to.throw(TypeError, 'Invalid event target');
     });
  
hunk.file_path: spec/observables/fromEvent-spec.ts
hunk.type: add
file: import * as Rx from '../../dist/cjs/Rx';
  declare const {hot, cold, asDiagram, expectObservable, expectSubscriptions};
  
  /** @test {isEmpty} */
  describe('Observable.prototype.isEmpty', () => {
    asDiagram('isEmpty')('should return true if source is empty', () => {
      const source = hot('-----|');
      const subs =       '^    !';
      const expected =   '-----(T|)';
  
      expectObservable((<any>source).isEmpty()).toBe(expected, { T: true });
      expectSubscriptions(source.subscriptions).toBe(subs);
    });
  
    it('should return false if source emits element', () => {
      const source = hot('--a--^--b--|');
      const subs =            '^  !';
      const expected =        '---(F|)';
  
      expectObservable((<any>source).isEmpty()).toBe(expected, { F: false });
      expectSubscriptions(source.subscriptions).toBe(subs);
    });
  
    it('should raise error if source raise error', () => {
      const source = hot('--#');
      const subs =       '^ !';
      const expected =   '--#';
  
      expectObservable((<any>source).isEmpty()).toBe(expected);
      expectSubscriptions(source.subscriptions).toBe(subs);
    });
  
    it('should not completes if source never emits', () => {
      const source = cold('-');
      const subs =        '^';
      const expected =    '-';
  
      expectObservable((<any>source).isEmpty()).toBe(expected);
      expectSubscriptions(source.subscriptions).toBe(subs);
    });
  
    it('should return true if source is Observable.empty()', () => {
      const source = cold('|');
      const subs =        '(^!)';
      const expected =    '(T|)';
  
      expectObservable((<any>source).isEmpty()).toBe(expected, { T: true });
      expectSubscriptions(source.subscriptions).toBe(subs);
    });
  
    it('should allow unsubscribing explicitly and early', () => {
      const source = cold('-----------a--b--|');
      const unsub =       '      !           ';
      const subs =        '^     !           ';
      const expected =    '-------           ';
  
      expectObservable((<any>source).isEmpty(), unsub).toBe(expected);
      expectSubscriptions(source.subscriptions).toBe(subs);
    });
  
    it('should not break unsubscription chains when result is unsubscribed explicitly', () => {
      const source = cold('-----------a--b--|');
      const subs =        '^     !           ';
      const expected =    '-------           ';
      const unsub =       '      !           ';
  
      const result = (<any>source)
        .mergeMap((x: string) => Rx.Observable.of(x))
        .isEmpty()
        .mergeMap((x: string) => Rx.Observable.of(x));
  
      expectObservable(result, unsub).toBe(expected);
      expectSubscriptions(source.subscriptions).toBe(subs);
    });
  });