forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solutions] fix timeline tabs + layout (elastic#86581) (elas…
…tic#86596) * fix timeline tabs + fix screenreader * review * fix jest tests
- Loading branch information
Showing
32 changed files
with
409 additions
and
156 deletions.
There are no files selected for viewing
21 changes: 0 additions & 21 deletions
21
x-pack/plugins/security_solution/public/common/components/accessibility/helpers.test.ts
This file was deleted.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
x-pack/plugins/security_solution/public/common/components/accessibility/helpers.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,70 @@ | ||
/* | ||
* 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 { mount } from 'enzyme'; | ||
import React from 'react'; | ||
|
||
import { | ||
ariaIndexToArrayIndex, | ||
arrayIndexToAriaIndex, | ||
getNotesContainerClassName, | ||
getRowRendererClassName, | ||
isArrowRight, | ||
} from './helpers'; | ||
|
||
describe('helpers', () => { | ||
describe('ariaIndexToArrayIndex', () => { | ||
test('it returns the expected array index', () => { | ||
expect(ariaIndexToArrayIndex(1)).toEqual(0); | ||
}); | ||
}); | ||
|
||
describe('arrayIndexToAriaIndex', () => { | ||
test('it returns the expected aria index', () => { | ||
expect(arrayIndexToAriaIndex(0)).toEqual(1); | ||
}); | ||
}); | ||
|
||
describe('isArrowRight', () => { | ||
test('it returns true if the right arrow key was pressed', () => { | ||
let result = false; | ||
const onKeyDown = (keyboardEvent: React.KeyboardEvent) => { | ||
result = isArrowRight(keyboardEvent); | ||
}; | ||
|
||
const wrapper = mount(<div onKeyDown={onKeyDown} />); | ||
wrapper.find('div').simulate('keydown', { key: 'ArrowRight' }); | ||
wrapper.update(); | ||
|
||
expect(result).toBe(true); | ||
}); | ||
|
||
test('it returns false if another key was pressed', () => { | ||
let result = false; | ||
const onKeyDown = (keyboardEvent: React.KeyboardEvent) => { | ||
result = isArrowRight(keyboardEvent); | ||
}; | ||
|
||
const wrapper = mount(<div onKeyDown={onKeyDown} />); | ||
wrapper.find('div').simulate('keydown', { key: 'Enter' }); | ||
wrapper.update(); | ||
|
||
expect(result).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('getRowRendererClassName', () => { | ||
test('it returns the expected class name', () => { | ||
expect(getRowRendererClassName(2)).toBe('row-renderer-2'); | ||
}); | ||
}); | ||
|
||
describe('getNotesContainerClassName', () => { | ||
test('it returns the expected class name', () => { | ||
expect(getNotesContainerClassName(2)).toBe('notes-container-2'); | ||
}); | ||
}); | ||
}); |
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
40 changes: 40 additions & 0 deletions
40
...tion/public/common/components/accessibility/tooltip_with_keyboard_shortcut/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,40 @@ | ||
/* | ||
* 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 { mount } from 'enzyme'; | ||
import React from 'react'; | ||
|
||
import { TooltipWithKeyboardShortcut } from '.'; | ||
|
||
const props = { | ||
content: <div>{'To pay respect'}</div>, | ||
shortcut: 'F', | ||
showShortcut: true, | ||
}; | ||
|
||
describe('TooltipWithKeyboardShortcut', () => { | ||
test('it renders the provided content', () => { | ||
const wrapper = mount(<TooltipWithKeyboardShortcut {...props} />); | ||
|
||
expect(wrapper.find('[data-test-subj="content"]').text()).toBe('To pay respect'); | ||
}); | ||
|
||
test('it renders the additionalScreenReaderOnlyContext', () => { | ||
const wrapper = mount( | ||
<TooltipWithKeyboardShortcut {...props} additionalScreenReaderOnlyContext={'field.name'} /> | ||
); | ||
|
||
expect(wrapper.find('[data-test-subj="additionalScreenReaderOnlyContext"]').text()).toBe( | ||
'field.name' | ||
); | ||
}); | ||
|
||
test('it renders the expected shortcut', () => { | ||
const wrapper = mount(<TooltipWithKeyboardShortcut {...props} />); | ||
|
||
expect(wrapper.find('[data-test-subj="shortcut"]').first().text()).toBe('Press\u00a0F'); | ||
}); | ||
}); |
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
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
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
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
Oops, something went wrong.