Skip to content

Commit

Permalink
test: add mock for test cases
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <[email protected]>
  • Loading branch information
raintygao committed Aug 29, 2024
1 parent 8927431 commit d5e4853
Show file tree
Hide file tree
Showing 2 changed files with 284 additions and 1 deletion.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ describe('Intro component', () => {
onDeleteClick: () => undefined,
useUpdatedUX: false,
navigationUI: ({
HeaderControl: () => null,
HeaderControl: ({ controls }) => {
return controls?.[0].ariaLabel ?? controls?.[0].label ?? null;
},
} as unknown) as NavigationPublicPluginStart['ui'],
application: coreMock.createStart().application,
};
Expand Down Expand Up @@ -144,4 +146,30 @@ describe('Intro component', () => {
});
expect(mounted.exists(`a[data-test-subj='savedObjectEditViewInApp']`)).toBe(false);
});

it('renders correctly when use new UX', () => {
const mounted = mountHeader({
...defaultProps,
useUpdatedUX: true,
});
expect(mounted).toMatchSnapshot();
});

it('renders correctly when use new UX and canViewInApp is true', () => {
const mounted = mountHeader({
...defaultProps,
useUpdatedUX: true,
canViewInApp: true,
});
expect(mounted).toMatchSnapshot();
});

it('renders correctly when use new UX and canDelete is true', () => {
const mounted = mountHeader({
...defaultProps,
useUpdatedUX: true,
canDelete: true,
});
expect(mounted).toMatchSnapshot();
});
});

0 comments on commit d5e4853

Please sign in to comment.