Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3a0c9b2
Revert "Temporarily remove Layout from App Search plugin for 7.10 rel…
constancecchen Oct 6, 2020
53ace58
Added a Credentials route and link
JasonStoltz Oct 1, 2020
6c352b8
Added Credentials Page
JasonStoltz Oct 1, 2020
9434cc8
Added Credentials List
JasonStoltz Oct 1, 2020
09e7d93
Merge branch 'master' into JasonStoltz/credentials-view
JasonStoltz Oct 7, 2020
c010b8a
Implement feedback items:
JasonStoltz Oct 7, 2020
e659382
Remove unused imports
JasonStoltz Oct 7, 2020
2c9a99a
PR Feedback
JasonStoltz Oct 7, 2020
91c4ff8
Add reusable shallow unmount helper
cee-chen Oct 6, 2020
714da22
Simplify Kea test mocks
cee-chen Oct 6, 2020
4917cbb
Switch to ApiTokenTypes
JasonStoltz Oct 7, 2020
280b2f7
Apply suggestions from code review
JasonStoltz Oct 7, 2020
30c52a7
Use ApiTokenTypes for IApiToken
JasonStoltz Oct 7, 2020
343290e
PR Feedback
JasonStoltz Oct 7, 2020
9e6b0c4
We can lose these CSS classes...
JasonStoltz Oct 7, 2020
564737a
I think we can rewrite this return flow
JasonStoltz Oct 7, 2020
7caf342
Missed a ApiTokenTypes issue
JasonStoltz Oct 7, 2020
c52c139
Do we want to write a test file for this?
JasonStoltz Oct 7, 2020
593a3a2
PR Feedback
JasonStoltz Oct 7, 2020
53865ce
Super exciting proposal here
JasonStoltz Oct 7, 2020
5d0ab10
Feedback
JasonStoltz Oct 7, 2020
b82eb10
Update x-pack/plugins/enterprise_search/public/applications/__mocks__…
JasonStoltz Oct 7, 2020
f653187
Apply suggestions from code review
JasonStoltz Oct 7, 2020
a30f8d5
nit - may as well keep EUI imports together
JasonStoltz Oct 7, 2020
49570d4
Just an idea / me going all #microperf here
JasonStoltz Oct 7, 2020
f41a356
Remove shallow_usememo
JasonStoltz Oct 8, 2020
d2e21d7
Apply suggestions from code review
JasonStoltz Oct 8, 2020
a0ff646
More feedback
JasonStoltz Oct 8, 2020
bfd75d8
mockKea simplifying
cee-chen Oct 8, 2020
473c1d2
Merge branch 'master' into JasonStoltz/credentials-view
JasonStoltz Oct 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ jest.mock('react', () => ({
useEffect: jest.fn((fn) => fn()), // Calls on mount/every update - use mount for more complex behavior
}));

// Helper for calling the returned useEffect unmount handler
import { useEffect } from 'react';
export const unmountHandler = () => (useEffect as jest.Mock).mock.calls[0][0]()();

/**
* Example usage within a component test using shallow():
*
Expand All @@ -19,3 +23,14 @@ jest.mock('react', () => ({
*
* // ... etc.
*/
/**
* Example unmount() usage:
*
* import { onUnmount } from '../../../__mocks__/shallow_useeffect.mock';
*
* it('unmounts', () => {
* shallow(SomeComponent);
* unmountHandler();
* // expect something to have been done on unmount (NOTE: the component is not actually unmounted)
* });
*/
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/
import '../../../__mocks__/kea.mock';
import '../../../__mocks__/shallow_useeffect.mock';
import { unmountHandler } from '../../../__mocks__/shallow_useeffect.mock';

import React, { useEffect } from 'react';
import React from 'react';
import { shallow } from 'enzyme';
import { useValues, useActions } from 'kea';

Expand All @@ -15,8 +15,6 @@ import { EuiCopy, EuiPageContentBody } from '@elastic/eui';

import { externalUrl } from '../../../shared/enterprise_search_url';

const getUseEffectUnmountHandler = () => (useEffect as jest.Mock).mock.calls[0][0]();

describe('Credentials', () => {
const mockKea = ({ values = {}, actions = {} }) => {
const mergedValues = {
Expand Down Expand Up @@ -54,7 +52,6 @@ describe('Credentials', () => {
const resetCredentials = jest.fn();
mockKea({ actions: { resetCredentials } });
shallow(<Credentials />);
const unmountHandler = getUseEffectUnmountHandler();
unmountHandler();
expect(resetCredentials).toHaveBeenCalledTimes(1);
});
Expand Down