Example #1
0
test('[reducer/notifications]', t => {
  t.plan(4);
  store.dispatch(notifyActions.send('test', 1000));
  const state = store.getState();
  t.equal(state.notifications.count(), 1, 'send a notification');
  t.equal(state.notifications.first(), 'test');

  const action = store.dispatch(notifyActions.send('test', 1000));
  action.then(data => {
    const setup = notifications(initialState, data);
    setTimeout(() => {
      t.equal(data.type, 'NOTIFICATION_CLEAR', 'clear a notification after 1 second');
      t.equal(setup.count(), 0);
    }, 1000);
  });
});
Example #2
0
  it('send a notification', () => {
    store.dispatch(notifyActions.send('test', 1000));
    const state = store.getState();
    expect(state.notifications.count()).to.eql(1);
    expect(state.notifications.first()).to.eql('test');

    it('clear a notification after 1 second', (done) => {
      const action = store.dispatch(notifyActions.send('test', 1000));
      action.then(data => {
        const setup = notifications(initialState, data);
        expect(data.type).to.eql('NOTIFICATION_CLEAR');
        expect(setup.count()).to.eql(0);
        done();
      });
    });
  });
Example #3
0
test('[reducer/sounds] edit', t => {
  t.plan(2);
  const newData = { tags: 'newTag' };
  const action = store.dispatch(soundActions.soundsEdit(currState().get('wind'), newData));
  t.equal(action.type, 'SOUNDS_EDIT');
  t.equal(currState().get('wind').tags, newData.tags);
});
Example #4
0
test('[reducer/sounds] volume', t => {
  t.plan(3);
  t.equal(currState().get('wind').volume, 0.5);
  const action = store.dispatch(soundActions.soundsVolume(currState().get('wind'), 0.25));
  t.equal(action.type, 'SOUNDS_VOLUME');
  t.equal(currState().get('wind').volume, 0.25);
});
Example #5
0
test('[reducer/sounds] init sounds', t => {
  t.plan(3);
  const action = store.dispatch(soundActions.soundsInit());
  action.then(data => {
    t.equal(data.type, 'SOUNDS_RECEIVED');
    t.equal(data.resp.length, 14);
    t.equal(currState().count(), 14);
    defaultState = currState();
  });
});
Example #6
0
  it('search Kakapo', (done) => {
    const action = store.dispatch(searchActions.searchKakapo());
    action.then(data => {
      expect(data.type).to.eql('SEARCH_KAKAPO');
      expect(data.items.length).to.eql(14);
      done();

      it('update the store with the new data', () => {
        const reducer = search(initialState, data);
        expect(reducer.get('kakapofavs').count()).to.eql(15);
      });
    });
  });
Example #7
0
  it('search YouTube for `oceans`', (done) => {
    const action = store.dispatch(searchActions.searchYoutube('oceans'));
    action.then(data => {
      expect(data.type).to.eql('SEARCH_YOUTUBE');
      expect(data.items.length).to.eql(2);
      done();

      it('update the store with the new data', () => {
        const reducer = search(initialState, data);
        expect(reducer.get('youtube').count()).to.eql(15);
      });
    });
  });
Example #8
0
const currState = () => store.getState().sounds;
Example #9
0
test('[reducer/sounds] clear', t => {
  t.plan(2);
  const action = store.dispatch(soundActions.resetSounds());
  t.equal(action.type, 'SOUNDS_RESET');
  t.deepEqual(currState().toJS(), defaultState.toJS());
});
Example #10
0
test('[reducer/sounds] remove', t => {
  t.plan(2);
  const action = store.dispatch(soundActions.soundsRemove(currState().get('wind')));
  t.equal(action.type, 'SOUNDS_REMOVE');
  t.equal(currState().get('wind'), undefined);
});
Example #11
0
test('[reducer/sounds] toggle play `off`', t => {
  t.plan(2);
  const action = store.dispatch(soundActions.soundsPlay(currState().get('wind')));
  t.equal(action.type, 'SOUNDS_PLAY');
  t.equal(currState().get('wind').playing, false);
});