Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

History

History
History
78 lines (68 loc) 路 2.56 KB

File metadata and controls

78 lines (68 loc) 路 2.56 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import React from 'react';
import sinon from 'sinon';
import { mount } from 'enzyme';
import { EuiCodeEditor } from './code_editor';
import { keyCodes } from '../../services';
import {
findTestSubject,
requiredProps,
takeMountedSnapshot,
} from '../../test';
// Mock the htmlIdGenerator to generate predictable ids for snapshot tests
jest.mock('../../services/accessibility/html_id_generator', () => ({
htmlIdGenerator: () => { return () => 42; },
}));
describe('EuiCodeEditor', () => {
test('is rendered', () => {
const component = mount(<EuiCodeEditor {...requiredProps} />);
expect(takeMountedSnapshot(component)).toMatchSnapshot();
});
describe('props', () => {
describe('isReadOnly', () => {
test(`renders alternate hint text`, () => {
const component = mount(<EuiCodeEditor isReadOnly />);
expect(takeMountedSnapshot(component)).toMatchSnapshot();
});
});
});
describe('behavior', () => {
let component;
beforeEach(() => {
component = mount(<EuiCodeEditor/>);
});
describe('hint element', () => {
test('should be tabable', () => {
const hint = findTestSubject(component, 'codeEditorHint').getDOMNode();
expect(hint).toMatchSnapshot();
});
test('should be disabled when the ui ace box gains focus', () => {
const hint = findTestSubject(component, 'codeEditorHint');
hint.simulate('keyup', { keyCode: keyCodes.ENTER });
expect(findTestSubject(component, 'codeEditorHint').getDOMNode()).toMatchSnapshot();
});
test('should be enabled when the ui ace box loses focus', () => {
const hint = findTestSubject(component, 'codeEditorHint');
hint.simulate('keyup', { keyCode: keyCodes.ENTER });
component.instance().onBlurAce();
expect(findTestSubject(component, 'codeEditorHint').getDOMNode()).toMatchSnapshot();
});
});
describe('interaction', () => {
test('bluring the ace textbox should call a passed onBlur prop', () => {
const blurSpy = sinon.spy();
const el = mount(<EuiCodeEditor onBlur={blurSpy}/>);
el.instance().onBlurAce();
expect(blurSpy.called).toBe(true);
});
test('pressing escape in ace textbox will enable overlay', () => {
component.instance().onKeydownAce({
preventDefault: () => {},
stopPropagation: () => {},
keyCode: keyCodes.ESCAPE,
});
const hint = findTestSubject(component, 'codeEditorHint').getDOMNode();
expect(hint).toBe(document.activeElement);
});
});
});
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.