-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
55f87c0
commit 45999c7
Showing
100 changed files
with
3,466 additions
and
182 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...k/legacy/plugins/siem/public/components/header_page_new/__snapshots__/index.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
224 changes: 224 additions & 0 deletions
224
x-pack/legacy/plugins/siem/public/components/header_page_new/index.test.tsx
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,224 @@ | ||
/* | ||
* 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 euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; | ||
import { shallow } from 'enzyme'; | ||
import React from 'react'; | ||
|
||
import { TestProviders } from '../../mock'; | ||
import { HeaderPage } from './index'; | ||
import { useMountAppended } from '../../utils/use_mount_appended'; | ||
|
||
describe('HeaderPage', () => { | ||
const mount = useMountAppended(); | ||
|
||
test('it renders', () => { | ||
const wrapper = shallow( | ||
<HeaderPage | ||
badgeOptions={{ beta: true, text: 'Beta', tooltip: 'Test tooltip' }} | ||
border | ||
subtitle="Test subtitle" | ||
subtitle2="Test subtitle 2" | ||
title="Test title" | ||
> | ||
<p>{'Test supplement'}</p> | ||
</HeaderPage> | ||
); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
test('it renders the title', () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<HeaderPage title="Test title" /> | ||
</TestProviders> | ||
); | ||
|
||
expect( | ||
wrapper | ||
.find('[data-test-subj="header-page-title"]') | ||
.first() | ||
.exists() | ||
).toBe(true); | ||
}); | ||
|
||
test('it renders the back link when provided', () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<HeaderPage backOptions={{ href: '#', text: 'Test link' }} title="Test title" /> | ||
</TestProviders> | ||
); | ||
|
||
expect( | ||
wrapper | ||
.find('.siemHeaderPage__linkBack') | ||
.first() | ||
.exists() | ||
).toBe(true); | ||
}); | ||
|
||
test('it DOES NOT render the back link when not provided', () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<HeaderPage title="Test title" /> | ||
</TestProviders> | ||
); | ||
|
||
expect( | ||
wrapper | ||
.find('.siemHeaderPage__linkBack') | ||
.first() | ||
.exists() | ||
).toBe(false); | ||
}); | ||
|
||
test('it renders the first subtitle when provided', () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<HeaderPage subtitle="Test subtitle" title="Test title" /> | ||
</TestProviders> | ||
); | ||
|
||
expect( | ||
wrapper | ||
.find('[data-test-subj="header-page-subtitle"]') | ||
.first() | ||
.exists() | ||
).toBe(true); | ||
}); | ||
|
||
test('it DOES NOT render the first subtitle when not provided', () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<HeaderPage title="Test title" /> | ||
</TestProviders> | ||
); | ||
|
||
expect( | ||
wrapper | ||
.find('[data-test-subj="header-section-subtitle"]') | ||
.first() | ||
.exists() | ||
).toBe(false); | ||
}); | ||
|
||
test('it renders the second subtitle when provided', () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<HeaderPage subtitle2="Test subtitle 2" title="Test title" /> | ||
</TestProviders> | ||
); | ||
|
||
expect( | ||
wrapper | ||
.find('[data-test-subj="header-page-subtitle-2"]') | ||
.first() | ||
.exists() | ||
).toBe(true); | ||
}); | ||
|
||
test('it DOES NOT render the second subtitle when not provided', () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<HeaderPage title="Test title" /> | ||
</TestProviders> | ||
); | ||
|
||
expect( | ||
wrapper | ||
.find('[data-test-subj="header-section-subtitle-2"]') | ||
.first() | ||
.exists() | ||
).toBe(false); | ||
}); | ||
|
||
test('it renders supplements when children provided', () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<HeaderPage title="Test title"> | ||
<p>{'Test supplement'}</p> | ||
</HeaderPage> | ||
</TestProviders> | ||
); | ||
|
||
expect( | ||
wrapper | ||
.find('[data-test-subj="header-page-supplements"]') | ||
.first() | ||
.exists() | ||
).toBe(true); | ||
}); | ||
|
||
test('it DOES NOT render supplements when children not provided', () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<HeaderPage title="Test title" /> | ||
</TestProviders> | ||
); | ||
|
||
expect( | ||
wrapper | ||
.find('[data-test-subj="header-page-supplements"]') | ||
.first() | ||
.exists() | ||
).toBe(false); | ||
}); | ||
|
||
test('it applies border styles when border is true', () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<HeaderPage border title="Test title" /> | ||
</TestProviders> | ||
); | ||
const siemHeaderPage = wrapper.find('.siemHeaderPage').first(); | ||
|
||
expect(siemHeaderPage).toHaveStyleRule('border-bottom', euiDarkVars.euiBorderThin); | ||
expect(siemHeaderPage).toHaveStyleRule('padding-bottom', euiDarkVars.paddingSizes.l); | ||
}); | ||
|
||
test('it DOES NOT apply border styles when border is false', () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<HeaderPage title="Test title" /> | ||
</TestProviders> | ||
); | ||
const siemHeaderPage = wrapper.find('.siemHeaderPage').first(); | ||
|
||
expect(siemHeaderPage).not.toHaveStyleRule('border-bottom', euiDarkVars.euiBorderThin); | ||
expect(siemHeaderPage).not.toHaveStyleRule('padding-bottom', euiDarkVars.paddingSizes.l); | ||
}); | ||
|
||
test('it renders as a draggable when arguments provided', () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<HeaderPage draggableArguments={{ field: 'neat', value: 'cool' }} title="Test title" /> | ||
</TestProviders> | ||
); | ||
|
||
expect( | ||
wrapper | ||
.find('[data-test-subj="header-page-draggable"]') | ||
.first() | ||
.exists() | ||
).toBe(true); | ||
}); | ||
|
||
test('it DOES NOT render as a draggable when arguments not provided', () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<HeaderPage title="Test title" /> | ||
</TestProviders> | ||
); | ||
|
||
expect( | ||
wrapper | ||
.find('[data-test-subj="header-page-draggable"]') | ||
.first() | ||
.exists() | ||
).toBe(false); | ||
}); | ||
}); |
Oops, something went wrong.