Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
fix(actions-layout): remove flow types, update test, open -> toggle
Browse files Browse the repository at this point in the history
fix(actions-layout): remove flow types, update test, open -> toggle
  • Loading branch information
Metnew committed Feb 18, 2018
1 parent 61e93ec commit bad63f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 33 deletions.
18 changes: 3 additions & 15 deletions src/common/actions/layout/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
// @flow
export const UI_OPEN_SIDEBAR = 'UI_OPEN_SIDEBAR'
export const UI_CLOSE_SIDEBAR = 'UI_CLOSE_SIDEBAR'
export const UI_TOGGLE_SIDEBAR = 'UI_TOGGLE_SIDEBAR'
export const UI_WINDOW_RESIZE = 'UI_WINDOW_RESIZE'

export const CLOSE_SIDEBAR = () => ({
type: UI_CLOSE_SIDEBAR
})

export const OPEN_SIDEBAR = () => ({
type: UI_OPEN_SIDEBAR
export const TOGGLE_SIDEBAR = ({
type: UI_TOGGLE_SIDEBAR
})

export const WINDOW_RESIZE = (innerWidth: number) => ({
Expand All @@ -17,10 +12,3 @@ export const WINDOW_RESIZE = (innerWidth: number) => ({
innerWidth
}
})

export type UI_OPEN_SIDEBAR_TYPE = {type: 'UI_OPEN_SIDEBAR'}
export type UI_CLOSE_SIDEBAR_TYPE = {type: 'UI_CLOSE_SIDEBAR'}
export type UI_WINDOW_RESIZE_TYPE = {
type: 'UI_WINDOW_RESIZE',
payload: {innerWidth: number}
}
23 changes: 5 additions & 18 deletions src/common/actions/layout/index.test.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,22 @@
import configureMockStore from 'redux-mock-store'
import thunk from 'redux-thunk'
import {
UI_CLOSE_SIDEBAR,
CLOSE_SIDEBAR,
UI_OPEN_SIDEBAR,
OPEN_SIDEBAR,
UI_TOGGLE_SIDEBAR,
TOGGLE_SIDEBAR,
UI_WINDOW_RESIZE,
WINDOW_RESIZE
} from 'actions/layout'
const middlewares = [thunk]
const mockStore = configureMockStore(middlewares)

describe('Layout actions', () => {
it('creates UI_CLOSE_SIDEBAR after CLOSE_SIDEBAR was dispatched', () => {
it('creates UI_TOGGLE_SIDEBAR after TOGGLE_SIDEBAR was dispatched', () => {
const expectedAction = [{
type: UI_CLOSE_SIDEBAR
type: UI_TOGGLE_SIDEBAR
}]

const store = mockStore({})
store.dispatch(CLOSE_SIDEBAR())

expect(store.getActions()).toEqual(expectedAction)
})

it('creates UI_OPEN_SIDEBAR after OPEN_SIDEBAR was dispatched', () => {
const expectedAction = [{
type: UI_OPEN_SIDEBAR
}]

const store = mockStore({})
store.dispatch(OPEN_SIDEBAR())
store.dispatch(TOGGLE_SIDEBAR)

expect(store.getActions()).toEqual(expectedAction)
})
Expand Down

0 comments on commit bad63f8

Please sign in to comment.