本文整理汇总了TypeScript中redux-mock-store.MockStoreEnhanced.getState方法的典型用法代码示例。如果您正苦于以下问题:TypeScript MockStoreEnhanced.getState方法的具体用法?TypeScript MockStoreEnhanced.getState怎么用?TypeScript MockStoreEnhanced.getState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redux-mock-store.MockStoreEnhanced
的用法示例。
在下文中一共展示了MockStoreEnhanced.getState方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('success', async () => {
store = mockStore({
...initialState,
catalog: {
...catalogInitialState,
searchResults: ['a', 'b', 'c'],
apiKey: 'a',
},
}) as any
await store.dispatch(Catalog.serialize() as any)
const state = store.getState()
expect(sessionStorage.setItem).toHaveBeenCalledTimes(2)
expect(sessionStorage.setItem).toHaveBeenCalledWith('searchCriteria', JSON.stringify(state.catalog.searchCriteria))
expect(sessionStorage.setItem).toHaveBeenCalledWith('searchResults', JSON.stringify(state.catalog.searchResults))
expect(localStorage.setItem).toHaveBeenCalledTimes(1)
expect(localStorage.setItem).toHaveBeenCalledWith('catalog_apiKey', state.catalog.apiKey)
expect(store.getActions()).toEqual([
{ type: CatalogActions.Serialized.type },
])
})
示例2: test
test('success', async () => {
await store.dispatch(Algorithms.serialize() as any)
expect(sessionStorage.setItem).toHaveBeenCalledTimes(1)
expect(sessionStorage.setItem).toHaveBeenCalledWith(
'algorithms_records',
JSON.stringify(store.getState().algorithms.records),
)
expect(store.getActions()).toEqual([
{ type: AlgorithmsActions.Serialized.type },
])
})
示例3: test
test('success', async () => {
await store.dispatch(ApiStatus.serialize() as any)
const state = store.getState()
expect(sessionStorage.setItem).toHaveBeenCalledTimes(2)
expect(sessionStorage.setItem).toHaveBeenCalledWith(
'geoserver',
JSON.stringify(state.apiStatus.geoserver),
)
expect(sessionStorage.setItem).toHaveBeenCalledWith(
'enabled_platforms_records',
JSON.stringify(state.apiStatus.enabledPlatforms),
)
expect(store.getActions()).toEqual([
{ type: ApiStatusActions.Serialized.type },
])
})