Commit dd0a470a authored by Martin Fahl's avatar Martin Fahl

adds addDialog reducer test

parent 5bf935b0
import reducer from './addDialog'
import * as types from '../constants/ActionTypes'
describe('addDialog reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(
{isOpen: false, name: "", quantity: 0}
)
})
it('should handle OPEN_ADD_DIALOG', () => {
expect(
reducer(
{
isOpen: false,
name: "",
quantity: 0
},
{
type: types.OPEN_ADD_DIALOG,
}
)
).toEqual(
{
isOpen: true,
name: "",
quantity: 0
}
)
expect(
reducer(
{
isOpen: true,
name: "Test",
quantity: 2
},
{
type: types.OPEN_ADD_DIALOG,
}
)
).toEqual(
{
isOpen: true,
name: "Test",
quantity: 2
}
)
expect(
reducer(
{
isOpen: false,
name: "Test",
quantity: 2
},
{
type: types.OPEN_ADD_DIALOG,
}
)
).toEqual(
{
isOpen: true,
name: "Test",
quantity: 2
}
)
})
it('should handle CLOSE_ADD_DIALOG', () => {
expect(
reducer(
{
isOpen: false,
name: "",
quantity: 0
},
{
type: types.CLOSE_ADD_DIALOG,
}
)
).toEqual(
{
isOpen: false,
name: "",
quantity: 0
}
)
expect(
reducer(
{
isOpen: true,
name: "Test",
quantity: 2
},
{
type: types.CLOSE_ADD_DIALOG,
}
)
).toEqual(
{
isOpen: false,
name: "",
quantity: 0
}
)
})
it('should handle UPDATE_ADD_DIALOG_NAME', () => {
expect(
reducer(
{
isOpen: true,
name: "",
quantity: 0
},
{
type: types.UPDATE_ADD_DIALOG_NAME,
name: "Axe"
}
)
).toEqual(
{
isOpen: true,
name: "Axe",
quantity: 0
}
)
expect(
reducer(
{
isOpen: true,
name: "Test",
quantity: 2
},
{
type: types.UPDATE_ADD_DIALOG_NAME,
name: "Axe"
}
)
).toEqual(
{
isOpen: true,
name: "Axe",
quantity: 2
}
)
})
it('should handle UPDATE_ADD_DIALOG_QUANTITY', () => {
expect(
reducer(
{
isOpen: true,
name: "",
quantity: 0
},
{
type: types.UPDATE_ADD_DIALOG_QUANTITY,
quantity: 25
}
)
).toEqual(
{
isOpen: true,
name: "",
quantity: 25
}
)
expect(
reducer(
{
isOpen: true,
name: "Test",
quantity: 2
},
{
type: types.UPDATE_ADD_DIALOG_QUANTITY,
quantity: 27
}
)
).toEqual(
{
isOpen: true,
name: "Test",
quantity: 27
}
)
})
})
\ No newline at end of file
import reducer from './filterTerm'
import * as actions from '../actions'
import * as types from '../constants/ActionTypes'
describe('filterTerm reducer', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment