-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
66f585a
commit 3c639b2
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
x-pack/plugins/endpoint/public/applications/endpoint/store/selectors/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,62 @@ | ||
/* | ||
* 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 { endpointAppReducers, GlobalState } from '../reducers'; | ||
import { createStore, Store } from 'redux'; | ||
import { coreStartServices, appBasePath } from './app'; | ||
import { AppDispatch } from '../actions/app'; | ||
import { CoreStart } from 'kibana/public'; | ||
|
||
describe('app selectors', () => { | ||
let store: Store<GlobalState>; | ||
let dispatch: AppDispatch; | ||
const setupStore = () => { | ||
store = createStore(endpointAppReducers); | ||
dispatch = store.dispatch; | ||
}; | ||
|
||
describe('before `appWillMount` action', () => { | ||
let state: GlobalState; | ||
|
||
beforeEach(() => { | ||
setupStore(); | ||
state = store.getState(); | ||
}); | ||
|
||
test('coreStartServices is initially null', () => { | ||
expect(coreStartServices(state)).toBeNull(); | ||
}); | ||
|
||
test('appBasePath is initially empty string', () => { | ||
expect(appBasePath(state)).toEqual(''); | ||
}); | ||
}); | ||
|
||
describe('after `appWillMount` action', () => { | ||
let coreStartServicesMock: CoreStart; | ||
|
||
beforeEach(() => { | ||
setupStore(); | ||
coreStartServicesMock = coreMock.createStart({ basePath: '/some/path' }); | ||
dispatch({ | ||
type: 'appWillMount', | ||
payload: { | ||
appBasePath: '/some/path', | ||
coreStartServices: coreStartServicesMock, | ||
}, | ||
}); | ||
}); | ||
|
||
test('coreStartServices set to an object', () => { | ||
expect(coreStartServices(store.getState())).toEqual(coreStartServicesMock); | ||
}); | ||
|
||
test('appBasePath is set', () => { | ||
expect(appBasePath(store.getState())).toEqual('/some/path'); | ||
}); | ||
}); | ||
}); |
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