From 9991b1f0c164464a4e729c1d933dfdb4e147e5a2 Mon Sep 17 00:00:00 2001 From: akameco Date: Sun, 10 Mar 2019 05:07:12 +0900 Subject: [PATCH] refactor(typescript): tests --- .../{actions.test.js => actions.test.ts} | 1 - .../{reducer.test.js => reducer.test.ts} | 10 +++++-- .../{reducer.test.js => reducer.test.ts} | 9 ++++--- .../{reducer.test.js => reducer.test.ts} | 13 ++++++--- .../{reducer.test.js => reducer.test.ts} | 3 +-- .../{reducer.test.js => reducer.test.ts} | 9 ++++--- .../{reducer.test.js => reducer.test.ts} | 9 ++++--- .../ColumnRecommended/tests/reducer.test.js | 7 ----- .../ColumnRecommended/tests/reducer.test.ts | 13 +++++++++ .../{reducer.test.js => reducer.test.ts} | 16 ++++++++--- .../{reducer.test.js => reducer.test.ts} | 14 +++++++--- .../{reducer.test.js => reducer.test.ts} | 15 ++++++----- .../{reducer.test.js => reducer.test.ts} | 9 ++++--- .../tests/__snapshots__/actions.test.js.snap | 15 ----------- app/containers/Notify/tests/actions.test.js | 10 ------- .../{reducer.test.js => reducer.test.ts} | 9 ++++--- .../{reducer.test.js => reducer.test.ts} | 27 ++++++++++++++----- .../{reducer.test.js => reducer.test.ts} | 13 ++++++--- 18 files changed, 121 insertions(+), 81 deletions(-) rename app/containers/BookmarkButton/tests/{actions.test.js => actions.test.ts} (97%) rename app/containers/Column/{reducer.test.js => reducer.test.ts} (92%) rename app/containers/ColumnBookmark/tests/{reducer.test.js => reducer.test.ts} (86%) rename app/containers/ColumnFollow/tests/{reducer.test.js => reducer.test.ts} (90%) rename app/containers/ColumnHistory/tests/{reducer.test.js => reducer.test.ts} (95%) rename app/containers/ColumnRanking/tests/{reducer.test.js => reducer.test.ts} (68%) rename app/containers/ColumnRankingR18/tests/{reducer.test.js => reducer.test.ts} (80%) delete mode 100644 app/containers/ColumnRecommended/tests/reducer.test.js create mode 100644 app/containers/ColumnRecommended/tests/reducer.test.ts rename app/containers/ColumnSearch/tests/{reducer.test.js => reducer.test.ts} (66%) rename app/containers/DrawerManager/tests/{reducer.test.js => reducer.test.ts} (68%) rename app/containers/Language/tests/{reducer.test.js => reducer.test.ts} (69%) rename app/containers/LoginModal/tests/{reducer.test.js => reducer.test.ts} (90%) delete mode 100644 app/containers/Notify/tests/__snapshots__/actions.test.js.snap delete mode 100644 app/containers/Notify/tests/actions.test.js rename app/containers/Table/tests/{reducer.test.js => reducer.test.ts} (84%) rename app/containers/UserDrawerContainer/tests/{reducer.test.js => reducer.test.ts} (61%) rename app/containers/UserPopoverContainer/tests/{reducer.test.js => reducer.test.ts} (68%) diff --git a/app/containers/BookmarkButton/tests/actions.test.js b/app/containers/BookmarkButton/tests/actions.test.ts similarity index 97% rename from app/containers/BookmarkButton/tests/actions.test.js rename to app/containers/BookmarkButton/tests/actions.test.ts index b9f6cd23..6ef5def2 100644 --- a/app/containers/BookmarkButton/tests/actions.test.js +++ b/app/containers/BookmarkButton/tests/actions.test.ts @@ -1,4 +1,3 @@ -// @flow import * as actions from '../actions' test('addBookmarkRequest', () => { diff --git a/app/containers/Column/reducer.test.js b/app/containers/Column/reducer.test.ts similarity index 92% rename from app/containers/Column/reducer.test.js rename to app/containers/Column/reducer.test.ts index b1c2cdda..bd950ea7 100644 --- a/app/containers/Column/reducer.test.js +++ b/app/containers/Column/reducer.test.ts @@ -1,4 +1,3 @@ -// @flow import { baseReducer as reducer } from './reducer' const baseActions = { @@ -18,7 +17,14 @@ const state = { test('default action', () => { expect( - reducer('base', baseActions, {}, { type: 'default action' }) + reducer( + 'base', + baseActions, + {}, + { + type: 'default action', + } + ) ).toMatchSnapshot() }) diff --git a/app/containers/ColumnBookmark/tests/reducer.test.js b/app/containers/ColumnBookmark/tests/reducer.test.ts similarity index 86% rename from app/containers/ColumnBookmark/tests/reducer.test.js rename to app/containers/ColumnBookmark/tests/reducer.test.ts index 77f21ea5..1821d9bb 100644 --- a/app/containers/ColumnBookmark/tests/reducer.test.js +++ b/app/containers/ColumnBookmark/tests/reducer.test.ts @@ -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', () => { diff --git a/app/containers/ColumnFollow/tests/reducer.test.js b/app/containers/ColumnFollow/tests/reducer.test.ts similarity index 90% rename from app/containers/ColumnFollow/tests/reducer.test.js rename to app/containers/ColumnFollow/tests/reducer.test.ts index 0ca9e149..eec46427 100644 --- a/app/containers/ColumnFollow/tests/reducer.test.js +++ b/app/containers/ColumnFollow/tests/reducer.test.ts @@ -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', () => { @@ -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() diff --git a/app/containers/ColumnHistory/tests/reducer.test.js b/app/containers/ColumnHistory/tests/reducer.test.ts similarity index 95% rename from app/containers/ColumnHistory/tests/reducer.test.js rename to app/containers/ColumnHistory/tests/reducer.test.ts index f3314331..ff23d54c 100644 --- a/app/containers/ColumnHistory/tests/reducer.test.js +++ b/app/containers/ColumnHistory/tests/reducer.test.ts @@ -1,4 +1,3 @@ -// @flow import reducer from '../reducer' import * as actions from '../actions' @@ -7,7 +6,7 @@ const ds = { } test('default action', () => { - // $FlowFixMe + // @ts-ignore expect(reducer(ds, 'default action')).toMatchSnapshot() }) diff --git a/app/containers/ColumnRanking/tests/reducer.test.js b/app/containers/ColumnRanking/tests/reducer.test.ts similarity index 68% rename from app/containers/ColumnRanking/tests/reducer.test.js rename to app/containers/ColumnRanking/tests/reducer.test.ts index 25121e9a..3863f488 100644 --- a/app/containers/ColumnRanking/tests/reducer.test.js +++ b/app/containers/ColumnRanking/tests/reducer.test.ts @@ -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', () => { diff --git a/app/containers/ColumnRankingR18/tests/reducer.test.js b/app/containers/ColumnRankingR18/tests/reducer.test.ts similarity index 80% rename from app/containers/ColumnRankingR18/tests/reducer.test.js rename to app/containers/ColumnRankingR18/tests/reducer.test.ts index cadbce48..88417676 100644 --- a/app/containers/ColumnRankingR18/tests/reducer.test.js +++ b/app/containers/ColumnRankingR18/tests/reducer.test.ts @@ -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', () => { diff --git a/app/containers/ColumnRecommended/tests/reducer.test.js b/app/containers/ColumnRecommended/tests/reducer.test.js deleted file mode 100644 index 061d9285..00000000 --- a/app/containers/ColumnRecommended/tests/reducer.test.js +++ /dev/null @@ -1,7 +0,0 @@ -// @flow -import reducer from '../reducer' - -test('default action', () => { - // $FlowFixMe - expect(reducer({}, { type: 'default action' })).toMatchSnapshot() -}) diff --git a/app/containers/ColumnRecommended/tests/reducer.test.ts b/app/containers/ColumnRecommended/tests/reducer.test.ts new file mode 100644 index 00000000..ac4a78f6 --- /dev/null +++ b/app/containers/ColumnRecommended/tests/reducer.test.ts @@ -0,0 +1,13 @@ +import reducer from '../reducer' + +test('default action', () => { + expect( + reducer( + {}, + { + // @ts-ignore + type: 'default action', + } + ) + ).toMatchSnapshot() +}) diff --git a/app/containers/ColumnSearch/tests/reducer.test.js b/app/containers/ColumnSearch/tests/reducer.test.ts similarity index 66% rename from app/containers/ColumnSearch/tests/reducer.test.js rename to app/containers/ColumnSearch/tests/reducer.test.ts index 96016235..d9edb14c 100644 --- a/app/containers/ColumnSearch/tests/reducer.test.js +++ b/app/containers/ColumnSearch/tests/reducer.test.ts @@ -1,4 +1,3 @@ -// @flow import reducer, { initialState } from '../reducer' import * as actions from '../actions' @@ -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', () => { @@ -23,6 +26,11 @@ test('setUsersIn', () => { test('reset ids', () => { expect( - reducer({ fate: defaultState }, actions.resetIds('fate')) + reducer( + { + fate: defaultState, + }, + actions.resetIds('fate') + ) ).toMatchSnapshot() }) diff --git a/app/containers/DrawerManager/tests/reducer.test.js b/app/containers/DrawerManager/tests/reducer.test.ts similarity index 68% rename from app/containers/DrawerManager/tests/reducer.test.js rename to app/containers/DrawerManager/tests/reducer.test.ts index fbb97f39..68c8a92e 100644 --- a/app/containers/DrawerManager/tests/reducer.test.js +++ b/app/containers/DrawerManager/tests/reducer.test.ts @@ -1,4 +1,3 @@ -// @flow import reducer from '../reducer' import * as actions from '../actions' @@ -8,8 +7,12 @@ 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', () => { @@ -17,6 +20,9 @@ test('OPEN_DRAWER', () => { }) test('CLOSE_DRAWER', () => { - const s = { open: true, userId: 1 } + const s = { + open: true, + userId: 1, + } expect(reducer(s, actions.closeDrawer())).toMatchSnapshot() }) diff --git a/app/containers/Language/tests/reducer.test.js b/app/containers/Language/tests/reducer.test.ts similarity index 69% rename from app/containers/Language/tests/reducer.test.js rename to app/containers/Language/tests/reducer.test.ts index 52977028..5d16fdf8 100644 --- a/app/containers/Language/tests/reducer.test.js +++ b/app/containers/Language/tests/reducer.test.ts @@ -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() }) diff --git a/app/containers/LoginModal/tests/reducer.test.js b/app/containers/LoginModal/tests/reducer.test.ts similarity index 90% rename from app/containers/LoginModal/tests/reducer.test.js rename to app/containers/LoginModal/tests/reducer.test.ts index 254e00d5..3e1596ef 100644 --- a/app/containers/LoginModal/tests/reducer.test.js +++ b/app/containers/LoginModal/tests/reducer.test.ts @@ -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', () => { diff --git a/app/containers/Notify/tests/__snapshots__/actions.test.js.snap b/app/containers/Notify/tests/__snapshots__/actions.test.js.snap deleted file mode 100644 index 22468e60..00000000 --- a/app/containers/Notify/tests/__snapshots__/actions.test.js.snap +++ /dev/null @@ -1,15 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`addNotify 1`] = ` -Object { - "type": "Notify/add", -} -`; - -exports[`addNotifyWithIllust 1`] = ` -Object { - "id": 1, - "title": "new illust", - "type": "Notify/ADD_NOTIFY_WITH_ILLUST", -} -`; diff --git a/app/containers/Notify/tests/actions.test.js b/app/containers/Notify/tests/actions.test.js deleted file mode 100644 index ec3ad3ca..00000000 --- a/app/containers/Notify/tests/actions.test.js +++ /dev/null @@ -1,10 +0,0 @@ -// @flow -import * as actions from '../actions' - -test('addNotify', () => { - expect(actions.addNotify()).toMatchSnapshot() -}) - -test('addNotifyWithIllust', () => { - expect(actions.addNotifyWithIllust('new illust', 1)).toMatchSnapshot() -}) diff --git a/app/containers/Table/tests/reducer.test.js b/app/containers/Table/tests/reducer.test.ts similarity index 84% rename from app/containers/Table/tests/reducer.test.js rename to app/containers/Table/tests/reducer.test.ts index 6946ff85..75697598 100644 --- a/app/containers/Table/tests/reducer.test.js +++ b/app/containers/Table/tests/reducer.test.ts @@ -1,4 +1,3 @@ -// @flow import reducer from '../reducer' import * as actions from '../actions' @@ -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', () => { diff --git a/app/containers/UserDrawerContainer/tests/reducer.test.js b/app/containers/UserDrawerContainer/tests/reducer.test.ts similarity index 61% rename from app/containers/UserDrawerContainer/tests/reducer.test.js rename to app/containers/UserDrawerContainer/tests/reducer.test.ts index 97fd0d9d..5fb9ce42 100644 --- a/app/containers/UserDrawerContainer/tests/reducer.test.js +++ b/app/containers/UserDrawerContainer/tests/reducer.test.ts @@ -1,11 +1,14 @@ -// @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', () => { @@ -13,14 +16,24 @@ test('CLOSE_DRAWER', () => { }) 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() }) diff --git a/app/containers/UserPopoverContainer/tests/reducer.test.js b/app/containers/UserPopoverContainer/tests/reducer.test.ts similarity index 68% rename from app/containers/UserPopoverContainer/tests/reducer.test.js rename to app/containers/UserPopoverContainer/tests/reducer.test.ts index b73fb367..f850bb74 100644 --- a/app/containers/UserPopoverContainer/tests/reducer.test.js +++ b/app/containers/UserPopoverContainer/tests/reducer.test.ts @@ -1,4 +1,3 @@ -// @flow import reducer from '../reducer' import * as actions from '../actions' @@ -7,8 +6,12 @@ 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', () => { @@ -16,6 +19,8 @@ test('POPOVER_SUCCESS', () => { }) test('CLEAR', () => { - const s = { illusts: [1, 2, 3] } + const s = { + illusts: [1, 2, 3], + } expect(reducer(s, actions.clear())).toMatchSnapshot() })