Skip to content

Commit

Permalink
refactor(typescript): tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akameco committed Mar 11, 2019
1 parent cbe4232 commit 9991b1f
Show file tree
Hide file tree
Showing 18 changed files with 121 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @flow
import * as actions from '../actions'

test('addBookmarkRequest', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @flow
import { baseReducer as reducer } from './reducer'

const baseActions = {
Expand All @@ -18,7 +17,14 @@ const state = {

test('default action', () => {
expect(
reducer('base', baseActions, {}, { type: 'default action' })
reducer(
'base',
baseActions,
{},
{
type: 'default action',
}
)
).toMatchSnapshot()
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
// @flow
import reducer from '../reducer'
import * as actions from '../actions'

const initialState = {}

test('snapshot initialState', () => {
// $FlowFixMe
expect(reducer(initialState, { type: 'default action' })).toMatchSnapshot()
expect(
reducer(initialState, {
// @ts-ignore
type: 'default action',
})
).toMatchSnapshot()
})

test('ADD_BOOKMARK_COLUMN_SUCCESS', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
// @flow
import reducer from '../reducer'
import * as actions from '../actions'

test('default action', () => {
// $FlowFixMe
expect(reducer({}, { type: 'default action' })).toMatchSnapshot()
expect(
reducer(
{},
{
// @ts-ignore
type: 'default action',
}
)
).toMatchSnapshot()
})

test('ADD_FOLLOW_COLUMN_SUCCESS', () => {
Expand Down Expand Up @@ -38,7 +44,6 @@ test('FETCH_NEXT_SUCCESS, FETCH_NEW_SUCCESS', () => {
expect(
reducer(first, actions.fetchNextSuccess('private', [4, 5]))
).toMatchSnapshot()

expect(
reducer(first, actions.fetchNewSuccess('private', [8]))
).toMatchSnapshot()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @flow
import reducer from '../reducer'
import * as actions from '../actions'

Expand All @@ -7,7 +6,7 @@ const ds = {
}

test('default action', () => {
// $FlowFixMe
// @ts-ignore
expect(reducer(ds, 'default action')).toMatchSnapshot()
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// @flow
import reducer, { initialState } from '../reducer'
import * as actions from '../actions'

test('default action', () => {
// $FlowFixMe
expect(reducer(initialState, { type: 'default action' })).toMatchSnapshot()
expect(
reducer(initialState, {
// @ts-ignore
type: 'default action',
})
).toMatchSnapshot()
})

test('ADD_COLUMN_SUCCESS', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// @flow
import reducer from '../reducer'
import * as actions from '../actions'

test('default action', () => {
// $FlowFixMe
expect(reducer(undefined, { type: 'default action' })).toMatchSnapshot()
expect(
reducer(undefined, {
// @ts-ignore
type: 'default action',
})
).toMatchSnapshot()
})

test('ADD_COLUMN_SUCCESS', () => {
Expand Down
7 changes: 0 additions & 7 deletions app/containers/ColumnRecommended/tests/reducer.test.js

This file was deleted.

13 changes: 13 additions & 0 deletions app/containers/ColumnRecommended/tests/reducer.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import reducer from '../reducer'

test('default action', () => {
expect(
reducer(
{},
{
// @ts-ignore
type: 'default action',
}
)
).toMatchSnapshot()
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @flow
import reducer, { initialState } from '../reducer'
import * as actions from '../actions'

Expand All @@ -11,8 +10,12 @@ const defaultState = {
}

test('default action', () => {
// $FlowFixMe
expect(reducer(initialState, { type: 'default action' })).toMatchSnapshot()
expect(
reducer(initialState, {
// @ts-ignore
type: 'default action',
})
).toMatchSnapshot()
})

test('setUsersIn', () => {
Expand All @@ -23,6 +26,11 @@ test('setUsersIn', () => {

test('reset ids', () => {
expect(
reducer({ fate: defaultState }, actions.resetIds('fate'))
reducer(
{
fate: defaultState,
},
actions.resetIds('fate')
)
).toMatchSnapshot()
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @flow
import reducer from '../reducer'
import * as actions from '../actions'

Expand All @@ -8,15 +7,22 @@ const df = {
}

test('default action', () => {
// $FlowFixMe
expect(reducer(df, { type: 'default action' })).toMatchSnapshot()
expect(
reducer(df, {
// @ts-ignore
type: 'default action',
})
).toMatchSnapshot()
})

test('OPEN_DRAWER', () => {
expect(reducer(df, actions.openDrawer(2))).toMatchSnapshot()
})

test('CLOSE_DRAWER', () => {
const s = { open: true, userId: 1 }
const s = {
open: true,
userId: 1,
}
expect(reducer(s, actions.closeDrawer())).toMatchSnapshot()
})
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
// @flow
import reducer from '../reducer'
import * as actions from '../actions'

test('default action', () => {
// $FlowFixMe
expect(reducer({}, { type: 'default action' })).toMatchSnapshot()
})

const ds = {
locale: 'ja',
}

test('default action', () => {
expect(
reducer(ds, {
// @ts-ignore
type: 'default action',
})
).toMatchSnapshot()
})

test(`changeLocale`, () => {
expect(reducer(ds, actions.changeLocale('en'))).toMatchSnapshot()
})
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// @flow
import reducer, { initialState } from '../reducer'
import * as actions from '../actions'

test('default action', () => {
// $FlowFixMe
expect(reducer(undefined, { type: 'default action' })).toMatchSnapshot()
expect(
reducer(undefined, {
// @ts-ignore
type: 'default action',
})
).toMatchSnapshot()
})

test('SET_AUTH', () => {
Expand Down
15 changes: 0 additions & 15 deletions app/containers/Notify/tests/__snapshots__/actions.test.js.snap

This file was deleted.

10 changes: 0 additions & 10 deletions app/containers/Notify/tests/actions.test.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @flow
import reducer from '../reducer'
import * as actions from '../actions'

Expand All @@ -8,8 +7,12 @@ const df = {
}

test('default action', () => {
// $FlowFixMe
expect(reducer(undefined, { type: 'default action' })).toMatchSnapshot()
expect(
reducer(undefined, {
// @ts-ignore
type: 'default action',
})
).toMatchSnapshot()
})

test('ADD_TABLE', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
// @flow
import * as manegerActions from 'containers/DrawerManager/actions'
import reducer, { initialState as ds } from '../reducer'
import * as actions from '../actions'

test('default action', () => {
// $FlowFixMe
expect(reducer(ds, { type: 'default action' })).toMatchSnapshot()
expect(
reducer(ds, {
// @ts-ignore
type: 'default action',
})
).toMatchSnapshot()
})

test('CLOSE_DRAWER', () => {
expect(reducer(ds, manegerActions.closeDrawer())).toMatchSnapshot()
})

test('ADD_DRAWER_USER', () => {
// $FlowFixMe
expect(reducer(ds, actions.addDrawerUser({ id: 123 }))).toMatchSnapshot()
expect(
reducer(
ds,
actions.addDrawerUser({
id: 123,
})
)
).toMatchSnapshot()
})

test('ADD_DRAWER_PROFILE', () => {
expect(
// $FlowFixMe
reducer(ds, actions.addDrawerProfile({ mock: 'mock' }))
reducer(
ds,
actions.addDrawerProfile({
mock: 'mock',
})
)
).toMatchSnapshot()
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @flow
import reducer from '../reducer'
import * as actions from '../actions'

Expand All @@ -7,15 +6,21 @@ const df = {
}

test('default action', () => {
// $FlowFixMe
expect(reducer(df, { type: 'default action' })).toMatchSnapshot()
expect(
reducer(df, {
// @ts-ignore
type: 'default action',
})
).toMatchSnapshot()
})

test('POPOVER_SUCCESS', () => {
expect(reducer(df, actions.popoverSuccess([1, 2, 3]))).toMatchSnapshot()
})

test('CLEAR', () => {
const s = { illusts: [1, 2, 3] }
const s = {
illusts: [1, 2, 3],
}
expect(reducer(s, actions.clear())).toMatchSnapshot()
})

0 comments on commit 9991b1f

Please sign in to comment.