Beispiel #1
0
  it('should emit rangeChange when selected start and end dates', (done) => {
    rangepicker.visibleDate = new Date(2018, 8, 17);
    showRangepicker();

    rangepicker.rangeChange
      .pipe(skip(1))
      .subscribe((range: NbCalendarRange<Date>) => {
        expect(range.start.getFullYear()).toEqual(2018);
        expect(range.end.getFullYear()).toEqual(2018);
        expect(range.start.getMonth()).toEqual(8);
        expect(range.end.getMonth()).toEqual(8);
        expect(range.start.getDate()).toEqual(1);
        expect(range.end.getDate()).toEqual(3);
        done();
      });

    // click on Sep 1
    const startCell = overlay.querySelectorAll('.day-cell')[6];
    (startCell as HTMLElement).click();
    // click on Sep 3
    const endCell = overlay.querySelectorAll('.day-cell')[8];
    (endCell as HTMLElement).click();

    fixture.detectChanges();
  }, 5000);
    it('should be able to filter snapshotChanges() types - added/modified', async (done) => {
      const ITEMS = 10;
      let { randomCollectionName, ref, stocks, names } = await collectionHarness(afs, ITEMS);
      const nextId = ref.doc('a').id;
      let count = 0;

      const sub = stocks.snapshotChanges(['added', 'modified']).pipe(skip(1),take(2)).subscribe(data => {
        count += 1;
        if (count == 1) {
          const change = data.filter(x => x.payload.doc.id === nextId)[0];
          expect(data.length).toEqual(ITEMS + 1);
          expect(change.payload.doc.data().price).toEqual(2);
          expect(change.type).toEqual('added');
          delayUpdate(stocks, names[0], { price: 2 });
        }
        if (count == 2) {
          const change = data.filter(x => x.payload.doc.id === names[0])[0];
          expect(data.length).toEqual(ITEMS + 1);
          expect(change.payload.doc.data().price).toEqual(2);
          expect(change.type).toEqual('modified');
        }
      }).add(() => {
        deleteThemAll(names, ref).then(done).catch(done.fail);
      });

      names = names.concat([nextId]);
      delayAdd(stocks, nextId, { price: 2 });
    });
Beispiel #3
0
  it('should allow going forward a route with type `goForward`', done => {
    function main(_sources: {history: Observable<Location>}) {
      return {
        history: of<HistoryInput | string>(
          '/test',
          '/other',
          {type: 'go', amount: -1},
          {type: 'goForward'}
        ),
      };
    }

    const {sources, run} = setup(main, {
      history: makeServerHistoryDriver(),
    });

    const expected = ['/test', '/other', '/test', '/other'];

    sources.history.pipe(skip(1)).subscribe({
      next(location: Location) {
        assert.strictEqual(location.pathname, expected.shift());
        if (expected.length === 0) {
          done();
        }
      },
      error: done,
      complete: () => {
        done('complete should not be called');
      },
    });
    run();
  });
    it('should get Gamma sidekick after creating and assigning one', (done: DoneFn) => {
      // Skip(1), the initial state in which Gamma has no sidekick
      // Note that BOTH dispatches complete synchronously, before the selector updates
      // so we only have to skip one.
      createHeroSidekickSelector$(3)
        .pipe(skip(1))
        .subscribe(sk => {
          expect(sk.name).toBe('Robin');
          done();
        });

      // create a new sidekick
      let action: EntityAction = eaFactory.create<Sidekick>('Sidekick', EntityOp.ADD_ONE, {
        id: 42,
        name: 'Robin'
      });
      store.dispatch(action);

      // assign new sidekick to Gamma
      action = eaFactory.create<Update<Hero>>('Hero', EntityOp.UPDATE_ONE, {
        id: 3,
        changes: { id: 3, sidekickFk: 42 }
      });
      store.dispatch(action);
    });
	resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Page<Item>> {
		this.store.dispatch(
			new FindItemsByPodcastsAndPageAction(route.params.id)
		);

		return this.store.pipe(select(selectPodcastItems), skip(1), take(1));
	}
Beispiel #6
0
  it('should unsubscribe scheduled actions after execution', () => {
    let subscribeSpy: any = null;
    const counts: number[] = [];

    const e1 =       cold('a|');
    const expected =      '--a-(a|)';
    const duration = time('-|');
    const result = e1.pipe(
      repeatWhen(notifications => {
        const delayed = notifications.pipe(delay(duration, rxTestScheduler));
        subscribeSpy = sinon.spy(delayed['source'], 'subscribe');
        return delayed;
      }),
      skip(1),
      take(2),
      tap({
        next() {
          const [[subscriber]] = subscribeSpy.args;
          counts.push(subscriber._subscriptions.length);
        },
        complete() {
          expect(counts).to.deep.equal([1, 1]);
        }
      })
    );

    expectObservable(result).toBe(expected);
  });
Beispiel #7
0
 it('should emit true when the socket establishes a connection with the ws server', done => {
     const brayns = new Client(host);
     brayns.ready.pipe(skip(1), take(1))
         .subscribe(ready => {
             expect(ready).toBe(true);
             done();
         });
 });
Beispiel #8
0
  it('should complete regardless of skip count if source is empty', () => {
    const e1 =  cold('|');
    const e1subs =   '(^!)';
    const expected = '|';

    expectObservable(e1.pipe(skip(3))).toBe(expected);
    expectSubscriptions(e1.subscriptions).toBe(e1subs);
  });
Beispiel #9
0
  it('should skip values before a total and raises error if source raises error', () => {
    const source = hot('--a--b--c--d--#');
    const subs =       '^             !';
    const expected =   '-----------d--#';

    expectObservable(source.pipe(skip(3))).toBe(expected);
    expectSubscriptions(source.subscriptions).toBe(subs);
  });
Beispiel #10
0
  asDiagram('skip(3)')('should skip values before a total', () => {
    const source = hot('--a--b--c--d--e--|');
    const subs =       '^                !';
    const expected =   '-----------d--e--|';

    expectObservable(source.pipe(skip(3))).toBe(expected);
    expectSubscriptions(source.subscriptions).toBe(subs);
  });