Example #1
0
  it('should update cellHighlighters', () => {
    const newHighlighterState = { ...highlighterStateMock, type: HIGHLIGHTER_TYPE.uniqueEntries };
    const action = new DataGridColumnAction(ADD_COLUMN_HIGHLIGHTER, {
      columnName: 'test',
      value: newHighlighterState
    });
    const newState = reducer(state, action);

    expect(newState)
      .to.have.property('cellHighlighters')
      .that.deep.equal([highlighterStateMock, newHighlighterState]);

    // Do not allow to add multiple instances of the same highlighter
    expect(reducer(newState, action))
      .to.have.property('cellHighlighters')
      .that.deep.equal([highlighterStateMock, newHighlighterState]);

    const removeHighlighterAction = new DataGridColumnAction(REMOVE_COLUMN_HIGHLIGHTER, {
      columnName: 'test',
      value: newHighlighterState
    });

    expect(reducer(state, removeHighlighterAction))
      .to.have.property('cellHighlighters')
      .that.deep.equal([highlighterStateMock]);

  });
Example #2
0
  it('should update columnsFrozen', () => {
    const action = new DataGridColumnAction(UPDATE_COLUMN_FROZEN, {
      columnName: 'test',
      value: true
    });

    expect(reducer(state, action))
      .to.have.property('columnsFrozen')
      .that.deep.equal({ 'test': true });

    const disableFrozenAction = new DataGridColumnAction(UPDATE_COLUMN_FROZEN, {
      columnName: 'test',
      value: false
    });

    expect(reducer(state, disableFrozenAction))
      .to.have.property('columnsFrozen')
      .that.deep.equal({ 'test': false });
  });
Example #3
0
  it('should update columnOrder', () => {
    const action = new DataGridColumnAction(UPDATE_COLUMN_ORDER, {
      columnName: 'test',
      value: { value: 1, region: 'body' }
    });

    expect(reducer(state, action))
      .to.have.property('columnOrder')
      .that.deep.equal(['column', 'test']);
  });
Example #4
0
  it('should update rendererForColumn', () => {
    const renderer = { type: RENDERER_TYPE.DataBars, includeText: true };
    const action = new DataGridColumnAction(UPDATE_COLUMN_RENDERER, {
      columnType: COLUMN_TYPES.body,
      columnName: 'test',
      value: { type: RENDERER_TYPE.DataBars, includeText: true }
    });

    expect(reducer(state, action))
      .to.have.nested.property('rendererForColumn.test')
      .that.deep.equal(renderer);
  });
Example #5
0
  it('should update columnsVisible', () => {
    const state = {...modelStateMock, columnOrder: ['test']};
    const action = new DataGridColumnAction(UPDATE_COLUMN_VISIBLE, {
      columnName: 'test',
      columnIndex: 0,
      value: false
    });

    expect(reducer(state, action)).to.have.property('columnsVisible').that.deep.equal({ 'test': false });

    const showColumnAction = new DataGridColumnAction(UPDATE_COLUMN_VISIBLE, {
      columnIndex: 0,
      columnName: 'test',
      value: true
    });

    expect(reducer(state, showColumnAction)).to.have.property('columnsVisible').that.deep.equal({ 'test': true });

    const showColumnsAction = new DataGridColumnAction(
      UPDATE_COLUMNS_VISIBLE,
      { value: { test: true, column: false } }
    );
    const newState = reducer(state, showColumnsAction);

    expect(newState).to.have.property('columnsVisible').that.deep.equal({ test: true, column: false });
    expect(newState).to.have.property('columnOrder').that.deep.equal(['test']);

    const showAllColumnsAction = new DataGridColumnAction(UPDATE_COLUMNS_VISIBLE, {
      value: { test: true, column: true }
    });
    const latestState = reducer(state, showAllColumnsAction);

    expect(latestState).to.have.property('columnsVisible').that.deep.equal({ test: true, column: true });
    expect(latestState).to.have.property('columnOrder').that.deep.equal(['test', 'column']);

  });