import createReducer from 'bitbucket/internal/bbui/utils/create-reducer';

QUnit.module('utils-create-reducer');

const initialState = 'initial';
const reducer = createReducer(initialState, {
    ['HANDLED'](state, action) { // eslint-disable-line no-unused-vars
        return 'handled';
    },
});

QUnit.test('returns state for unhandled action', function(assert) {
    const newState = reducer(initialState, { type: 'UNHANDLED' });
    assert.equal(initialState, newState);
});

QUnit.test('calls a handled action', function(assert) {
    const newState = reducer(initialState, { type: 'HANDLED' });
    assert.equal(newState, 'handled');
});
