Skip to content

Commit

Permalink
Fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Oct 13, 2020
1 parent c84f994 commit 6173f6e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ describe('StepAboutRuleToggleDetails', () => {
.simulate('change', { target: { value: 'notes' } });

expect(wrapper.find('EuiButtonGroup[idSelected="notes"]').exists()).toBeTruthy();
expect(wrapper.find('Markdown h1').text()).toEqual('this is some markdown documentation');
expect(wrapper.find('.euiMarkdownFormat').text()).toEqual(
'this is some markdown documentation'
);
});
});
});

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

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 @@ -74,7 +74,9 @@ describe('AddNote', () => {
test('it renders the contents of the note', () => {
const wrapper = mount(<AddNote {...props} />);

expect(wrapper.find('[data-test-subj="add-a-note"]').first().text()).toEqual(note);
expect(
wrapper.find('[data-test-subj="add-a-note"] .euiMarkdownEditorDropZone').first().text()
).toEqual(note);
});

test('it invokes associateNote when the Add Note button is clicked', () => {
Expand Down Expand Up @@ -131,30 +133,4 @@ describe('AddNote', () => {

expect(updateNote).toBeCalled();
});

test('it does NOT display the markdown formatting hint when a note has NOT been entered', () => {
const testProps = {
...props,
newNote: '',
};
const wrapper = mount(<AddNote {...testProps} />);

expect(wrapper.find('[data-test-subj="markdown-hint"]').first()).toHaveStyleRule(
'visibility',
'hidden'
);
});

test('it displays the markdown formatting hint when a note has been entered', () => {
const testProps = {
...props,
newNote: 'We should see a formatting hint now',
};
const wrapper = mount(<AddNote {...testProps} />);

expect(wrapper.find('[data-test-subj="markdown-hint"]').first()).toHaveStyleRule(
'visibility',
'inline'
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import { mount, shallow } from 'enzyme';
import React from 'react';

import * as i18n from '../translations';

import { NewNote } from './new_note';

describe('NewNote', () => {
Expand All @@ -21,36 +19,11 @@ describe('NewNote', () => {
expect(wrapper).toMatchSnapshot();
});

test('it renders a tab labeled "Note"', () => {
const wrapper = mount(<NewNote noteInputHeight={200} note={note} updateNewNote={jest.fn()} />);

expect(wrapper.find('button[role="tab"]').first().text()).toEqual(i18n.NOTE);
});

test('it renders a tab labeled "Preview (Markdown)"', () => {
const wrapper = mount(<NewNote noteInputHeight={200} note={note} updateNewNote={jest.fn()} />);

expect(wrapper.find('button[role="tab"]').at(1).text()).toEqual(i18n.PREVIEW_MARKDOWN);
});

test('it renders the expected placeholder when a note is NOT provided', () => {
const wrapper = mount(<NewNote noteInputHeight={200} note={''} updateNewNote={jest.fn()} />);

expect(wrapper.find(`textarea[placeholder="${i18n.ADD_A_NOTE}"]`).exists()).toEqual(true);
});

test('it renders a text area containing the contents of a new (raw) note', () => {
const wrapper = mount(<NewNote noteInputHeight={200} note={note} updateNewNote={jest.fn()} />);

expect(wrapper.find('[data-test-subj="add-a-note"]').first().text()).toEqual(note);
});

test('it renders a markdown preview when the user clicks Preview (Markdown)', () => {
const wrapper = mount(<NewNote noteInputHeight={200} note={note} updateNewNote={jest.fn()} />);

// click the preview tab:
wrapper.find('button[role="tab"]').at(1).simulate('click');

expect(wrapper.find('[data-test-subj="markdown-root"]').first().text()).toEqual(note);
expect(
wrapper.find('[data-test-subj="add-a-note"] .euiMarkdownEditorDropZone').first().text()
).toEqual(note);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('NoteCards', () => {
wrapper
.find('[data-test-subj="note-card"]')
.find('[data-test-subj="note-card-body"]')
.find('[data-test-subj="markdown-root"]')
.find('.euiMarkdownFormat')
.first()
.text()
).toEqual(getNotesByIds(noteIds)[0].note);
Expand Down

0 comments on commit 6173f6e

Please sign in to comment.