Commit 905a1445 authored by Martin Fahl's avatar Martin Fahl

adds action tests

parent e7928c3d
import * as actions from '.';
describe('actions', () => {
it('should create an action to add an item locally', () => {
const id = 'a23'
const name = 'test'
const quantity = 3
const expectedAction = {
type: actions.ITEM_ADDED,
id,
name,
quantity
}
expect(actions.itemAdded(id, name, quantity)).toEqual(expectedAction)
})
})
describe('actions', () => {
it('should create an action to update the filter', () => {
const filterTerm = 'Bananas'
const expectedAction = {
type: actions.UPDATE_FILTER,
filterTerm
}
expect(actions.updateFilter(filterTerm)).toEqual(expectedAction)
})
})
describe('actions', () => {
it('should create an action to delete an item locally', () => {
const id = 'aaaa-bbb23'
const expectedAction = {
type: actions.ITEM_DELETED,
id
}
expect(actions.itemDeleted(id)).toEqual(expectedAction)
})
})
describe('actions', () => {
it('should create an action to increment an item\'s quantity locally', () => {
const expectedAction = {
type: actions.INCREMENT,
}
expect(actions.increment()).toEqual(expectedAction)
})
})
describe('actions', () => {
it('should create an action to decrement an item\'s quantity locally', () => {
const expectedAction = {
type: actions.DECREMENT,
}
expect(actions.decrement()).toEqual(expectedAction)
})
})
describe('actions', () => {
it('should create an action to open the add dialog', () => {
const expectedAction = {
type: actions.OPEN_ADD_DIALOG,
}
expect(actions.openAddDialog()).toEqual(expectedAction)
})
})
describe('actions', () => {
it('should create an action to close the add dialog', () => {
const expectedAction = {
type: actions.CLOSE_ADD_DIALOG,
}
expect(actions.closeAddDialog()).toEqual(expectedAction)
})
})
describe('actions', () => {
it('should create an action to update the current name field for the add dialog', () => {
const name = 'Bananarama'
const expectedAction = {
type: actions.UPDATE_ADD_DIALOG_NAME,
name
}
expect(actions.updateAddDialogName(name)).toEqual(expectedAction)
})
})
describe('actions', () => {
it('should create an action to update the current quantity field for the add dialog', () => {
const quantity = 3452552253523
const expectedAction = {
type: actions.UPDATE_ADD_DIALOG_QUANTITY,
quantity
}
expect(actions.updateAddDialogQuantity(quantity)).toEqual(expectedAction)
})
})
describe('actions', () => {
it('should create an action to signal that the items have been loaded', () => {
const items = [{id: 1, name: "Hugo", quantity: 98},{id: 2, name: "Peter", quantity: 22}]
const expectedAction = {
type: actions.ITEMS_LOADED,
items
}
expect(actions.itemsLoaded(items)).toEqual(expectedAction)
})
})
\ No newline at end of file
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