-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c639b2
commit 37147e1
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
x-pack/plugins/endpoint/public/applications/endpoint/store/reducers/app.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { coreMock } from '../../../../../../../../src/core/public/mocks'; | ||
import { createStore, Store } from 'redux'; | ||
import { endpointAppReducers, GlobalState } from './index'; | ||
import { AppDispatch } from '../actions/app'; | ||
|
||
describe('app Reducers', () => { | ||
const objectThatLooksLikeAppState = expect.objectContaining({ | ||
appBasePath: expect.stringMatching('/some/path'), | ||
coreStartServices: expect.objectContaining({ | ||
application: expect.anything(), | ||
chrome: expect.anything(), | ||
docLinks: expect.anything(), | ||
http: expect.anything(), | ||
i18n: expect.anything(), | ||
notifications: expect.anything(), | ||
overlays: expect.anything(), | ||
uiSettings: expect.anything(), | ||
savedObjects: expect.anything(), | ||
injectedMetadata: expect.anything(), | ||
}), | ||
}); | ||
|
||
let store: Store<GlobalState>; | ||
let dispatch: AppDispatch; | ||
|
||
beforeEach(() => { | ||
store = createStore(endpointAppReducers); | ||
dispatch = store.dispatch; | ||
dispatch({ | ||
type: 'appWillMount', | ||
payload: { | ||
appBasePath: '/some/path', | ||
coreStartServices: coreMock.createStart({ basePath: '/some/path' }), | ||
}, | ||
}); | ||
}); | ||
|
||
test('it stores kibana start/mount data on `appWillMount`', () => { | ||
expect(store.getState().app).toEqual(objectThatLooksLikeAppState); | ||
}); | ||
|
||
test('it resets the store on `appDidUnmount`', () => { | ||
dispatch({ | ||
type: 'appDidUnmount', | ||
}); | ||
|
||
expect(store.getState().app).toEqual({ | ||
appBasePath: '', | ||
coreStartServices: null, | ||
}); | ||
}); | ||
}); |