From 5fac9ad9ac653dba89f5f53457c8d17959cef7cc Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Fri, 2 Sep 2016 16:13:51 +0200 Subject: use jest (#1202) --- .../account/projects/__tests__/ProjectCard-test.js | 103 +++---- .../account/projects/__tests__/Projects-test.js | 96 ++++--- .../__tests__/background-tasks-test.js | 301 ++++++++++----------- .../js/apps/background-tasks/components/Search.js | 2 +- .../js/apps/background-tasks/components/Stats.js | 14 +- .../apps/overview/components/__tests__/App-test.js | 53 +--- .../components/__tests__/EmptyOverview-test.js | 25 +- .../__tests__/QualityGateCondition-test.js | 61 ++--- .../components/__tests__/ActionsCell-test.js | 31 +-- .../components/__tests__/Defaults-test.js | 21 +- .../js/apps/projects/__tests__/projects-test.js | 48 ++-- .../apps/quality-profiles/__tests__/utils-test.js | 77 +++--- .../changelog/__tests__/Changelog-test.js | 79 +++--- .../changelog/__tests__/ChangelogSearch-test.js | 74 +++-- .../changelog/__tests__/ChangesList-test.js | 43 ++- .../changelog/__tests__/ParameterChange-test.js | 11 +- .../changelog/__tests__/SeverityChange-test.js | 13 +- .../compare/__tests__/ComparisonForm-test.js | 39 ++- .../compare/__tests__/ComparisonResults-test.js | 129 +++++---- .../components/__tests__/ProfileContainer-test.js | 114 ++++---- .../main/js/apps/settings/__tests__/utils-test.js | 27 +- .../settings/components/inputs/InputForPassword.js | 18 +- .../components/inputs/__tests__/Input-test.js | 58 ++-- .../inputs/__tests__/InputForBoolean-test.js | 91 +++---- .../inputs/__tests__/InputForNumber-test.js | 32 +-- .../inputs/__tests__/InputForPassword-test.js | 125 ++++----- .../__tests__/InputForSingleSelectList-test.js | 73 +++-- .../inputs/__tests__/InputForString-test.js | 32 +-- .../inputs/__tests__/InputForText-test.js | 59 ++-- .../inputs/__tests__/MultiValueInput-test.js | 104 +++---- .../inputs/__tests__/SimpleInput-test.js | 71 +++-- .../main/js/apps/system/__tests__/system-test.js | 141 ++++------ 32 files changed, 954 insertions(+), 1211 deletions(-) (limited to 'server/sonar-web/src/main/js/apps') diff --git a/server/sonar-web/src/main/js/apps/account/projects/__tests__/ProjectCard-test.js b/server/sonar-web/src/main/js/apps/account/projects/__tests__/ProjectCard-test.js index 7f2e5d579f5..8f85a86d722 100644 --- a/server/sonar-web/src/main/js/apps/account/projects/__tests__/ProjectCard-test.js +++ b/server/sonar-web/src/main/js/apps/account/projects/__tests__/ProjectCard-test.js @@ -19,76 +19,57 @@ */ import React from 'react'; import { shallow } from 'enzyme'; -import { expect } from 'chai'; import ProjectCard from '../ProjectCard'; import Level from '../../../../components/ui/Level'; const BASE = { id: 'id', key: 'key', name: 'name', links: [] }; -describe('My Account :: ProjectCard', () => { - it('should render key and name', () => { - const project = { ...BASE }; - const output = shallow( - - ); - expect(output.find('.account-project-key').text()).to.equal('key'); - expect(output.find('.account-project-name').text()).to.equal('name'); - }); +it('should render key and name', () => { + const project = { ...BASE }; + const output = shallow(); + expect(output.find('.account-project-key').text()).toBe('key'); + expect(output.find('.account-project-name').text()).toBe('name'); +}); - it('should render description', () => { - const project = { ...BASE, description: 'bla' }; - const output = shallow( - - ); - expect(output.find('.account-project-description').text()).to.equal('bla'); - }); +it('should render description', () => { + const project = { ...BASE, description: 'bla' }; + const output = shallow(); + expect(output.find('.account-project-description').text()).toBe('bla'); +}); - it('should not render optional fields', () => { - const project = { ...BASE }; - const output = shallow( - - ); - expect(output.find('.account-project-description')).to.have.length(0); - expect(output.find('.account-project-quality-gate')).to.have.length(0); - expect(output.find('.account-project-links')).to.have.length(0); - }); +it('should not render optional fields', () => { + const project = { ...BASE }; + const output = shallow(); + expect(output.find('.account-project-description').length).toBe(0); + expect(output.find('.account-project-quality-gate').length).toBe(0); + expect(output.find('.account-project-links').length).toBe(0); +}); - it('should render analysis date', () => { - const project = { ...BASE, lastAnalysisDate: '2016-05-17' }; - const output = shallow( - - ); - expect(output.find('.account-project-analysis').text()) - .to.contain('my_account.projects.analyzed_x'); - }); +it('should render analysis date', () => { + const project = { ...BASE, lastAnalysisDate: '2016-05-17' }; + const output = shallow(); + expect(output.find('.account-project-analysis').text()).toContain('my_account.projects.analyzed_x'); +}); - it('should not render analysis date', () => { - const project = { ...BASE }; - const output = shallow( - - ); - expect(output.find('.account-project-analysis').text()) - .to.contain('my_account.projects.never_analyzed'); - }); +it('should not render analysis date', () => { + const project = { ...BASE }; + const output = shallow(); + expect(output.find('.account-project-analysis').text()).toContain('my_account.projects.never_analyzed'); +}); - it('should render quality gate status', () => { - const project = { ...BASE, qualityGate: 'ERROR' }; - const output = shallow( - - ); - expect( - output.find('.account-project-quality-gate').find(Level).prop('level') - ).to.equal('ERROR'); - }); +it('should render quality gate status', () => { + const project = { ...BASE, qualityGate: 'ERROR' }; + const output = shallow( + + ); + expect(output.find('.account-project-quality-gate').find(Level).prop('level')).toBe('ERROR'); +}); - it('should render links', () => { - const project = { - ...BASE, - links: [{ name: 'n', type: 't', href: 'h' }] - }; - const output = shallow( - - ); - expect(output.find('.account-project-links').find('li')).to.have.length(1); - }); +it('should render links', () => { + const project = { + ...BASE, + links: [{ name: 'n', type: 't', href: 'h' }] + }; + const output = shallow(); + expect(output.find('.account-project-links').find('li').length).toBe(1); }); diff --git a/server/sonar-web/src/main/js/apps/account/projects/__tests__/Projects-test.js b/server/sonar-web/src/main/js/apps/account/projects/__tests__/Projects-test.js index 1908f929d7c..f3188d05e90 100644 --- a/server/sonar-web/src/main/js/apps/account/projects/__tests__/Projects-test.js +++ b/server/sonar-web/src/main/js/apps/account/projects/__tests__/Projects-test.js @@ -19,65 +19,61 @@ */ import React from 'react'; import { shallow } from 'enzyme'; -import { expect } from 'chai'; -import sinon from 'sinon'; import Projects from '../Projects'; import ProjectCard from '../ProjectCard'; import ListFooter from '../../../../components/controls/ListFooter'; -describe('My Account :: Projects', () => { - it('should render list of ProjectCards', () => { - const projects = [ - { id: 'id1', key: 'key1', name: 'name1', links: [] }, - { id: 'id2', key: 'key2', name: 'name2', links: [] } - ]; +it('should render list of ProjectCards', () => { + const projects = [ + { id: 'id1', key: 'key1', name: 'name1', links: [] }, + { id: 'id2', key: 'key2', name: 'name2', links: [] } + ]; - const output = shallow( - true} - loadMore={() => true}/> - ); + const output = shallow( + true} + loadMore={() => true}/> + ); - expect(output.find(ProjectCard)).to.have.length(2); - }); + expect(output.find(ProjectCard).length).toBe(2); +}); - it('should render ListFooter', () => { - const projects = [ - { id: 'id1', key: 'key1', name: 'name1', links: [] }, - { id: 'id2', key: 'key2', name: 'name2', links: [] } - ]; - const loadMore = sinon.stub().throws(); +it('should render ListFooter', () => { + const projects = [ + { id: 'id1', key: 'key1', name: 'name1', links: [] }, + { id: 'id2', key: 'key2', name: 'name2', links: [] } + ]; + const loadMore = jest.fn(); - const footer = shallow( - true} - loadMore={loadMore}/> - ).find(ListFooter); + const footer = shallow( + true} + loadMore={loadMore}/> + ).find(ListFooter); - expect(footer).to.have.length(1); - expect(footer.prop('count')).to.equal(2); - expect(footer.prop('total')).to.equal(5); - expect(footer.prop('loadMore')).to.equal(loadMore); - }); + expect(footer.length).toBe(1); + expect(footer.prop('count')).toBe(2); + expect(footer.prop('total')).toBe(5); + expect(footer.prop('loadMore')).toBe(loadMore); +}); - it('should render when no results', () => { - const output = shallow( - true} - loadMore={() => true}/> - ); +it('should render when no results', () => { + const output = shallow( + true} + loadMore={() => true}/> + ); - expect(output.find('.js-no-results')).to.have.length(1); - expect(output.find(ProjectCard)).to.have.length(0); - expect(output.find(ListFooter)).to.have.length(0); - }); + expect(output.find('.js-no-results').length).toBe(1); + expect(output.find(ProjectCard).length).toBe(0); + expect(output.find(ListFooter).length).toBe(0); }); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/__tests__/background-tasks-test.js b/server/sonar-web/src/main/js/apps/background-tasks/__tests__/background-tasks-test.js index ab0583a3c50..b8561256a60 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/__tests__/background-tasks-test.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/__tests__/background-tasks-test.js @@ -18,196 +18,167 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; -import ReactDOM from 'react-dom'; -import TestUtils from 'react-addons-test-utils'; -import chai, { expect } from 'chai'; -import sinon from 'sinon'; -import sinonChai from 'sinon-chai'; - +import { shallow } from 'enzyme'; import Stats from '../components/Stats'; import Search from '../components/Search'; import { STATUSES, CURRENTS, DEBOUNCE_DELAY, DEFAULT_FILTERS } from '../constants'; import { formatDuration } from '../utils'; +import { change, click } from '../../../../../../tests/utils'; + +const stub = jest.fn(); + +describe('Constants', () => { + it('should have STATUSES', () => { + expect(Object.keys(STATUSES).length).toBe(7); + }); + + it('should have CURRENTS', () => { + expect(Object.keys(CURRENTS).length).toBe(2); + }); +}); -chai.use(sinonChai); +describe('Search', () => { + const defaultProps = { + ...DEFAULT_FILTERS, + loading: false, + types: [], + onFilterUpdate: () => true, + onReload: () => true + }; + + it('should render search form', () => { + const component = shallow(); + expect(component.find('.js-search').length).toBe(1); + }); + + it('should not render search form', () => { + const component = shallow(); + expect(component.find('.js-search').length).toBe(0); + }); -describe('Background Tasks', function () { - describe('Constants', () => { - it('should have STATUSES', () => { - expect(STATUSES).to.be.a('object'); - expect(Object.keys(STATUSES).length).to.equal(7); + it('should search', (done) => { + const searchSpy = jest.fn(); + const component = shallow(); + const searchInput = component.find('.js-search'); + change(searchInput, 'some search query'); + setTimeout(() => { + expect(searchSpy).toBeCalledWith({ query: 'some search query' }); + done(); + }, DEBOUNCE_DELAY); + }); + + it('should reload', () => { + const reloadSpy = jest.fn(); + const component = shallow(); + const reloadButton = component.find('.js-reload'); + expect(reloadSpy).not.toBeCalled(); + click(reloadButton); + expect(reloadSpy).toBeCalled(); + }); +}); + +describe('Stats', () => { + describe('Pending', () => { + it('should show zero pending', () => { + const result = shallow(); + expect(result.find('.js-pending-count').text()).toContain('0'); }); - it('should have CURRENTS', () => { - expect(CURRENTS).to.be.a('object'); - expect(Object.keys(CURRENTS).length).to.equal(2); + it('should show 5 pending', () => { + const result = shallow(); + expect(result.find('.js-pending-count').text()).toContain('5'); + }); + + it('should not show cancel pending button', () => { + const result = shallow(); + expect(result.find('.js-cancel-pending').length).toBe(0); + }); + + it('should show cancel pending button', () => { + const result = shallow(); + expect(result.find('.js-cancel-pending').length).toBe(1); }); - }); - describe('Search', () => { - const defaultProps = { - ...DEFAULT_FILTERS, - loading: false, - types: [], - onFilterUpdate: () => true, - onReload: () => true - }; - - it('should render search form', () => { - const component = TestUtils.renderIntoDocument( - - ); - const searchBox = TestUtils.scryRenderedDOMComponentsWithClass(component, 'js-search'); - expect(searchBox).to.have.length(1); - }); - - it('should not render search form', () => { - const component = TestUtils.renderIntoDocument( - - ); - const searchBox = TestUtils.scryRenderedDOMComponentsWithClass(component, 'js-search'); - expect(searchBox).to.be.empty; - }); - - it('should search', (done) => { - const searchSpy = sinon.spy(); - const component = TestUtils.renderIntoDocument( - ); - const searchInput = ReactDOM.findDOMNode( - TestUtils.findRenderedDOMComponentWithClass(component, 'js-search')); - searchInput.value = 'some search query'; - TestUtils.Simulate.change(searchInput); - setTimeout(() => { - expect(searchSpy).to.have.been.calledWith({ query: 'some search query' }); - done(); - }, DEBOUNCE_DELAY); - }); - - it('should reload', () => { - const reloadSpy = sinon.spy(); - const component = TestUtils.renderIntoDocument( - - ); - const reloadButton = component.refs.reloadButton; - expect(reloadSpy).to.not.have.been.called; - TestUtils.Simulate.click(reloadButton); - expect(reloadSpy).to.have.been.called; + it('should trigger cancelling pending', () => { + const spy = jest.fn(); + const result = shallow(); + expect(spy).not.toBeCalled(); + click(result.find('.js-cancel-pending')); + expect(spy).toBeCalled(); }); }); - describe('Stats', () => { - describe('Pending', () => { - it('should show zero pending', () => { - const result = TestUtils.renderIntoDocument(); - const pendingCounter = result.refs.pendingCount; - expect(pendingCounter.textContent).to.contain('0'); - }); - - it('should show 5 pending', () => { - const result = TestUtils.renderIntoDocument(); - const pendingCounter = result.refs.pendingCount; - expect(pendingCounter.textContent).to.contain('5'); - }); - - it('should not show cancel pending button', () => { - const result = TestUtils.renderIntoDocument(); - const cancelPending = result.refs.cancelPending; - expect(cancelPending).to.not.be.ok; - }); - - it('should show cancel pending button', () => { - const result = TestUtils.renderIntoDocument(); - const cancelPending = result.refs.cancelPending; - expect(cancelPending).to.be.ok; - }); - - it('should trigger cancelling pending', () => { - const spy = sinon.spy(); - const result = TestUtils.renderIntoDocument(); - const cancelPending = result.refs.cancelPending; - expect(spy).to.not.have.been.called; - TestUtils.Simulate.click(cancelPending); - expect(spy).to.have.been.called; - }); - }); - - describe('Failures', () => { - it('should show zero failures', () => { - const result = TestUtils.renderIntoDocument(); - const failureCounter = result.refs.failureCount; - expect(failureCounter.textContent).to.contain('0'); - }); - - it('should show 5 failures', () => { - const result = TestUtils.renderIntoDocument(); - const failureCounter = result.refs.failureCount; - expect(failureCounter.textContent).to.contain('5'); - }); - - it('should not show link to failures', () => { - const result = TestUtils.renderIntoDocument(); - const failureCounter = result.refs.failureCount; - expect(failureCounter.tagName.toLowerCase()).to.not.equal('a'); - }); - - it('should show link to failures', () => { - const result = TestUtils.renderIntoDocument(); - const failureCounter = result.refs.failureCount; - expect(failureCounter.tagName.toLowerCase()).to.equal('a'); - }); - - it('should trigger filtering failures', () => { - const spy = sinon.spy(); - const result = TestUtils.renderIntoDocument(); - const failureCounter = result.refs.failureCount; - expect(spy).to.not.have.been.called; - TestUtils.Simulate.click(failureCounter); - expect(spy).to.have.been.called; - }); + describe('Failures', () => { + it('should show zero failures', () => { + const result = shallow(); + expect(result.find('.js-failures-count').text()).toContain('0'); + }); + + it('should show 5 failures', () => { + const result = shallow(); + expect(result.find('.js-failures-count').text()).toContain('5'); + }); + + it('should not show link to failures', () => { + const result = shallow(); + expect(result.find('.js-failures-count').is('a')).toBeFalsy(); + }); + + it('should show link to failures', () => { + const result = shallow(); + expect(result.find('.js-failures-count').is('a')).toBeTruthy(); + }); + + it('should trigger filtering failures', () => { + const spy = jest.fn(); + const result = shallow(); + expect(spy).not.toBeCalled(); + click(result.find('.js-failures-count')); + expect(spy).toBeCalled(); }); }); +}); - describe('Helpers', () => { - describe('#formatDuration()', () => { - it('should format 173ms', () => { - expect(formatDuration(173)).to.equal('173ms'); - }); +describe('Helpers', () => { + describe('#formatDuration()', () => { + it('should format 173ms', () => { + expect(formatDuration(173)).toBe('173ms'); + }); - it('should format 999ms', () => { - expect(formatDuration(999)).to.equal('999ms'); - }); + it('should format 999ms', () => { + expect(formatDuration(999)).toBe('999ms'); + }); - it('should format 1s', () => { - expect(formatDuration(1000)).to.equal('1s'); - }); + it('should format 1s', () => { + expect(formatDuration(1000)).toBe('1s'); + }); - it('should format 1s', () => { - expect(formatDuration(1001)).to.equal('1s'); - }); + it('should format 1s', () => { + expect(formatDuration(1001)).toBe('1s'); + }); - it('should format 2s', () => { - expect(formatDuration(1501)).to.equal('2s'); - }); + it('should format 2s', () => { + expect(formatDuration(1501)).toBe('2s'); + }); - it('should format 59s', () => { - expect(formatDuration(59000)).to.equal('59s'); - }); + it('should format 59s', () => { + expect(formatDuration(59000)).toBe('59s'); + }); - it('should format 1min', () => { - expect(formatDuration(60000)).to.equal('1min'); - }); + it('should format 1min', () => { + expect(formatDuration(60000)).toBe('1min'); + }); - it('should format 1min', () => { - expect(formatDuration(62757)).to.equal('1min'); - }); + it('should format 1min', () => { + expect(formatDuration(62757)).toBe('1min'); + }); - it('should format 4min', () => { - expect(formatDuration(224567)).to.equal('4min'); - }); + it('should format 4min', () => { + expect(formatDuration(224567)).toBe('4min'); + }); - it('should format 80min', () => { - expect(formatDuration(80 * 60 * 1000)).to.equal('80min'); - }); + it('should format 80min', () => { + expect(formatDuration(80 * 60 * 1000)).toBe('80min'); }); }); }); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Search.js b/server/sonar-web/src/main/js/apps/background-tasks/components/Search.js index bfffb1021e4..9dd234a6207 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Search.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Search.js @@ -151,7 +151,7 @@ export default class Search extends React.Component {
  • this.handleCancelChangeClick(e)}> {translate('cancel')} diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/Input-test.js b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/Input-test.js index dbe570ec878..d45fd7fe833 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/Input-test.js +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/Input-test.js @@ -18,43 +18,41 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; -import { expect } from 'chai'; import { shallow } from 'enzyme'; -import sinon from 'sinon'; import Input from '../Input'; import PrimitiveInput from '../PrimitiveInput'; import MultiValueInput from '../MultiValueInput'; import PropertySetInput from '../PropertySetInput'; import { TYPE_STRING, TYPE_PROPERTY_SET } from '../../../constants'; -describe('Settings :: Inputs :: Input', () => { - it('should render PrimitiveInput', () => { - const setting = { definition: { key: 'example', type: TYPE_STRING } }; - const onChange = sinon.spy(); - const input = shallow().find(PrimitiveInput); - expect(input).to.have.length(1); - expect(input.prop('setting')).to.equal(setting); - expect(input.prop('value')).to.equal('foo'); - expect(input.prop('onChange')).to.equal(onChange); - }); +it('should render PrimitiveInput', () => { + const setting = { definition: { key: 'example', type: TYPE_STRING } }; + const onChange = jest.fn(); + const input = shallow().find(PrimitiveInput); + expect(input.length).toBe(1); + expect(input.prop('setting')).toBe(setting); + expect(input.prop('value')).toBe('foo'); + expect(input.prop('onChange')).toBe(onChange); +}); - it('should render MultiValueInput', () => { - const setting = { definition: { key: 'example', type: TYPE_STRING, multiValues: true } }; - const onChange = sinon.spy(); - const input = shallow().find(MultiValueInput); - expect(input).to.have.length(1); - expect(input.prop('setting')).to.equal(setting); - expect(input.prop('value')).to.equal('foo'); - expect(input.prop('onChange')).to.equal(onChange); - }); +it('should render MultiValueInput', () => { + const setting = { definition: { key: 'example', type: TYPE_STRING, multiValues: true } }; + const value = ['foo', 'bar']; + const onChange = jest.fn(); + const input = shallow().find(MultiValueInput); + expect(input.length).toBe(1); + expect(input.prop('setting')).toBe(setting); + expect(input.prop('value')).toBe(value); + expect(input.prop('onChange')).toBe(onChange); +}); - it('should render PropertySetInput', () => { - const setting = { definition: { key: 'example', type: TYPE_PROPERTY_SET, fields: [] } }; - const onChange = sinon.spy(); - const input = shallow().find(PropertySetInput); - expect(input).to.have.length(1); - expect(input.prop('setting')).to.equal(setting); - expect(input.prop('value')).to.equal('foo'); - expect(input.prop('onChange')).to.equal(onChange); - }); +it('should render PropertySetInput', () => { + const setting = { definition: { key: 'example', type: TYPE_PROPERTY_SET, fields: [] } }; + const value = [{ foo: 'bar' }]; + const onChange = jest.fn(); + const input = shallow().find(PropertySetInput); + expect(input.length).toBe(1); + expect(input.prop('setting')).toBe(setting); + expect(input.prop('value')).toBe(value); + expect(input.prop('onChange')).toBe(onChange); }); diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForBoolean-test.js b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForBoolean-test.js index 2fc8b9bb9c5..9b0c51a9067 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForBoolean-test.js +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForBoolean-test.js @@ -18,60 +18,55 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; -import { expect } from 'chai'; import { shallow } from 'enzyme'; -import sinon from 'sinon'; import InputForBoolean from '../InputForBoolean'; import Toggle from '../../../../../components/controls/Toggle'; -describe('Settings :: Inputs :: InputForBoolean', () => { - it('should render Toggle', () => { - const onChange = sinon.spy(); - const toggle = shallow( - - ).find(Toggle); - expect(toggle).to.have.length(1); - expect(toggle.prop('name')).to.equal('foo'); - expect(toggle.prop('value')).to.equal(true); - expect(toggle.prop('onChange')).to.be.a('function'); - }); +it('should render Toggle', () => { + const onChange = jest.fn(); + const toggle = shallow( + + ).find(Toggle); + expect(toggle.length).toBe(1); + expect(toggle.prop('name')).toBe('foo'); + expect(toggle.prop('value')).toBe(true); + expect(toggle.prop('onChange')).toBeTruthy(); +}); - it('should render Toggle without value', () => { - const onChange = sinon.spy(); - const input = shallow( - - ); - const toggle = input.find(Toggle); - expect(toggle).to.have.length(1); - expect(toggle.prop('name')).to.equal('foo'); - expect(toggle.prop('value')).to.equal(false); - expect(toggle.prop('onChange')).to.be.a('function'); - expect(input.find('.note')).to.have.length(1); - }); +it('should render Toggle without value', () => { + const onChange = jest.fn(); + const input = shallow( + + ); + const toggle = input.find(Toggle); + expect(toggle.length).toBe(1); + expect(toggle.prop('name')).toBe('foo'); + expect(toggle.prop('value')).toBe(false); + expect(toggle.prop('onChange')).toBeTruthy(); + expect(input.find('.note').length).toBe(1); +}); - it('should call onChange', () => { - const onChange = sinon.spy(); - const input = shallow( - - ); - const toggle = input.find(Toggle); - expect(toggle).to.have.length(1); - expect(toggle.prop('onChange')).to.be.a('function'); +it('should call onChange', () => { + const onChange = jest.fn(); + const input = shallow( + + ); + const toggle = input.find(Toggle); + expect(toggle.length).toBe(1); + expect(toggle.prop('onChange')).toBeTruthy(); - toggle.prop('onChange')(false); + toggle.prop('onChange')(false); - expect(onChange.called).to.equal(true); - expect(onChange.lastCall.args).to.deep.equal([false]); - }); + expect(onChange).toBeCalledWith(false); }); diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForNumber-test.js b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForNumber-test.js index 3544898fa2e..c82a88dd084 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForNumber-test.js +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForNumber-test.js @@ -18,26 +18,22 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; -import { expect } from 'chai'; import { shallow } from 'enzyme'; -import sinon from 'sinon'; import InputForNumber from '../InputForNumber'; import SimpleInput from '../SimpleInput'; -describe('Settings :: Inputs :: InputForNumber', () => { - it('should render SimpleInput', () => { - const onChange = sinon.spy(); - const simpleInput = shallow( - - ).find(SimpleInput); - expect(simpleInput).to.have.length(1); - expect(simpleInput.prop('name')).to.equal('foo'); - expect(simpleInput.prop('value')).to.equal(17); - expect(simpleInput.prop('type')).to.equal('text'); - expect(simpleInput.prop('onChange')).to.be.a('function'); - }); +it('should render SimpleInput', () => { + const onChange = jest.fn(); + const simpleInput = shallow( + + ).find(SimpleInput); + expect(simpleInput.length).toBe(1); + expect(simpleInput.prop('name')).toBe('foo'); + expect(simpleInput.prop('value')).toBe(17); + expect(simpleInput.prop('type')).toBe('text'); + expect(simpleInput.prop('onChange')).toBeTruthy(); }); diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForPassword-test.js b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForPassword-test.js index 6e463644879..4c52fd60c22 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForPassword-test.js +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForPassword-test.js @@ -18,80 +18,69 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; -import { expect } from 'chai'; -import { shallow, mount } from 'enzyme'; -import sinon from 'sinon'; +import { shallow } from 'enzyme'; import InputForPassword from '../InputForPassword'; -import { click, submit } from '../../../../../../../../tests/utils'; +import { click, submit, change } from '../../../../../../../../tests/utils'; -describe('Settings :: Inputs :: InputForPassword', () => { - it('should render lock icon, but no form', () => { - const onChange = sinon.spy(); - const input = shallow( - - ); - expect(input.find('.icon-lock')).to.have.length(1); - expect(input.find('form')).to.have.length(0); - }); - - it('should open form', () => { - const onChange = sinon.spy(); - const input = shallow( - - ); - const button = input.find('button'); - expect(button).to.have.length(1); - - click(button); - expect(input.find('form')).to.have.length(1); - }); - - it('should close form', () => { - const onChange = sinon.spy(); - const input = shallow( - - ); - const button = input.find('button'); - expect(button).to.have.length(1); +it('should render lock icon, but no form', () => { + const onChange = jest.fn(); + const input = shallow( + + ); + expect(input.find('.icon-lock').length).toBe(1); + expect(input.find('form').length).toBe(0); +}); - click(button); - expect(input.find('form')).to.have.length(1); +it('should open form', () => { + const onChange = jest.fn(); + const input = shallow( + + ); + const button = input.find('button'); + expect(button.length).toBe(1); - click(input.find('form').find('a')); - expect(input.find('form')).to.have.length(0); - }); + click(button); + expect(input.find('form').length).toBe(1); +}); - it('should set value', () => { - const onChange = sinon.stub().returns(Promise.resolve()); - const input = mount( - - ); - const button = input.find('button'); - expect(button).to.have.length(1); +it('should close form', () => { + const onChange = jest.fn(); + const input = shallow( + + ); + const button = input.find('button'); + expect(button.length).toBe(1); - click(button); - const form = input.find('form'); - expect(form).to.have.length(1); + click(button); + expect(input.find('form').length).toBe(1); - input.ref('input').value = 'secret'; - submit(form); + click(input.find('form').find('a')); + expect(input.find('form').length).toBe(0); +}); - expect(onChange.called).to.equal(true); - }); +it('should set value', () => { + const onChange = jest.fn(() => Promise.resolve()); + const input = shallow( + + ); + click(input.find('button')); + change(input.find('.js-password-input'), 'secret'); + submit(input.find('form')); + expect(onChange).toBeCalledWith('secret'); }); diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForSingleSelectList-test.js b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForSingleSelectList-test.js index 2be66e0ad80..15057954ef8 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForSingleSelectList-test.js +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForSingleSelectList-test.js @@ -18,49 +18,44 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; -import { expect } from 'chai'; import { shallow } from 'enzyme'; -import sinon from 'sinon'; import Select from 'react-select'; import InputForSingleSelectList from '../InputForSingleSelectList'; -describe('Settings :: Inputs :: InputForSingleSelectList', () => { - it('should render Select', () => { - const onChange = sinon.spy(); - const select = shallow( - - ).find(Select); - expect(select).to.have.length(1); - expect(select.prop('name')).to.equal('foo'); - expect(select.prop('value')).to.equal('bar'); - expect(select.prop('options')).to.deep.equal([ - { value: 'foo', label: 'foo' }, - { value: 'bar', label: 'bar' }, - { value: 'baz', label: 'baz' } - ]); - expect(select.prop('onChange')).to.be.a('function'); - }); +it('should render Select', () => { + const onChange = jest.fn(); + const select = shallow( + + ).find(Select); + expect(select.length).toBe(1); + expect(select.prop('name')).toBe('foo'); + expect(select.prop('value')).toBe('bar'); + expect(select.prop('options')).toEqual([ + { value: 'foo', label: 'foo' }, + { value: 'bar', label: 'bar' }, + { value: 'baz', label: 'baz' } + ]); + expect(select.prop('onChange')).toBeTruthy(); +}); - it('should call onChange', () => { - const onChange = sinon.spy(); - const select = shallow( - - ).find(Select); - expect(select).to.have.length(1); - expect(select.prop('onChange')).to.be.a('function'); +it('should call onChange', () => { + const onChange = jest.fn(); + const select = shallow( + + ).find(Select); + expect(select.length).toBe(1); + expect(select.prop('onChange')).toBeTruthy(); - select.prop('onChange')({ value: 'baz', label: 'baz' }); - expect(onChange.called).to.equal(true); - expect(onChange.lastCall.args).to.deep.equal(['baz']); - }); + select.prop('onChange')({ value: 'baz', label: 'baz' }); + expect(onChange).toBeCalledWith('baz'); }); diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForString-test.js b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForString-test.js index 4fd3c7a4b39..31f2cbc5a43 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForString-test.js +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForString-test.js @@ -18,26 +18,22 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; -import { expect } from 'chai'; import { shallow } from 'enzyme'; -import sinon from 'sinon'; import InputForString from '../InputForString'; import SimpleInput from '../SimpleInput'; -describe('Settings :: Inputs :: InputForString', () => { - it('should render SimpleInput', () => { - const onChange = sinon.spy(); - const simpleInput = shallow( - - ).find(SimpleInput); - expect(simpleInput).to.have.length(1); - expect(simpleInput.prop('name')).to.equal('foo'); - expect(simpleInput.prop('value')).to.equal('bar'); - expect(simpleInput.prop('type')).to.equal('text'); - expect(simpleInput.prop('onChange')).to.be.a('function'); - }); +it('should render SimpleInput', () => { + const onChange = jest.fn(); + const simpleInput = shallow( + + ).find(SimpleInput); + expect(simpleInput.length).toBe(1); + expect(simpleInput.prop('name')).toBe('foo'); + expect(simpleInput.prop('value')).toBe('bar'); + expect(simpleInput.prop('type')).toBe('text'); + expect(simpleInput.prop('onChange')).toBeTruthy(); }); diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForText-test.js b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForText-test.js index 97ef6ec5fab..326f58058d5 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForText-test.js +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/InputForText-test.js @@ -18,43 +18,38 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; -import { expect } from 'chai'; import { shallow } from 'enzyme'; -import sinon from 'sinon'; import InputForText from '../InputForText'; import { change } from '../../../../../../../../tests/utils'; -describe('Settings :: Inputs :: InputForText', () => { - it('should render textarea', () => { - const onChange = sinon.spy(); - const textarea = shallow( - - ).find('textarea'); - expect(textarea).to.have.length(1); - expect(textarea.prop('name')).to.equal('foo'); - expect(textarea.prop('value')).to.equal('bar'); - expect(textarea.prop('onChange')).to.be.a('function'); - }); +it('should render textarea', () => { + const onChange = jest.fn(); + const textarea = shallow( + + ).find('textarea'); + expect(textarea.length).toBe(1); + expect(textarea.prop('name')).toBe('foo'); + expect(textarea.prop('value')).toBe('bar'); + expect(textarea.prop('onChange')).toBeTruthy(); +}); - it('should call onChange', () => { - const onChange = sinon.spy(); - const textarea = shallow( - - ).find('textarea'); - expect(textarea).to.have.length(1); - expect(textarea.prop('onChange')).to.be.a('function'); +it('should call onChange', () => { + const onChange = jest.fn(); + const textarea = shallow( + + ).find('textarea'); + expect(textarea.length).toBe(1); + expect(textarea.prop('onChange')).toBeTruthy(); - change(textarea, 'qux'); + change(textarea, 'qux'); - expect(onChange.called).to.equal(true); - expect(onChange.lastCall.args).to.deep.equal(['qux']); - }); + expect(onChange).toBeCalledWith('qux'); }); diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/MultiValueInput-test.js b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/MultiValueInput-test.js index 126a7a5a0ed..1e52f7a0018 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/MultiValueInput-test.js +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/MultiValueInput-test.js @@ -18,86 +18,54 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; -import { expect } from 'chai'; -import { shallow, mount } from 'enzyme'; -import sinon from 'sinon'; +import { shallow } from 'enzyme'; import MultiValueInput from '../MultiValueInput'; -import InputForString from '../InputForString'; -import { click, change } from '../../../../../../../../tests/utils'; +import PrimitiveInput from '../PrimitiveInput'; +import { click } from '../../../../../../../../tests/utils'; const definition = { multiValues: true }; const assertValues = (inputs, values) => { values.forEach((value, index) => { const input = inputs.at(index); - expect(input.prop('value')).to.equal(value); + expect(input.prop('value')).toBe(value); }); }; -describe('Settings :: Inputs :: MultiValueInput', () => { - it('should render one value', () => { - const multiValueInput = mount( - - ); - const stringInputs = multiValueInput.find(InputForString); - expect(stringInputs).to.have.length(1 + 1); - assertValues(stringInputs, ['foo', '']); - }); - - it('should render several values', () => { - const multiValueInput = mount( - - ); - const stringInputs = multiValueInput.find(InputForString); - expect(stringInputs).to.have.length(3 + 1); - assertValues(stringInputs, ['foo', 'bar', 'baz', '']); - }); - - it('should remove value', () => { - const onChange = sinon.spy(); - const multiValueInput = mount( - - ); - - click(multiValueInput.find('.js-remove-value').at(1)); - expect(onChange.called).to.equal(true); - expect(onChange.lastCall.args).to.deep.equal([['foo', 'baz']]); - }); +it('should render one value', () => { + const multiValueInput = shallow(); + const stringInputs = multiValueInput.find(PrimitiveInput); + expect(stringInputs.length).toBe(1 + 1); + assertValues(stringInputs, ['foo', '']); +}); - it('should change existing value', () => { - const onChange = sinon.spy(); - const multiValueInput = mount( - - ); +it('should render several values', () => { + const multiValueInput = shallow( + ); + const stringInputs = multiValueInput.find(PrimitiveInput); + expect(stringInputs.length).toBe(3 + 1); + assertValues(stringInputs, ['foo', 'bar', 'baz', '']); +}); - change(multiValueInput.find(InputForString).at(1).find('input'), 'qux'); - expect(onChange.called).to.equal(true); - expect(onChange.lastCall.args).to.deep.equal([['foo', 'qux', 'baz']]); - }); +it('should remove value', () => { + const onChange = jest.fn(); + const multiValueInput = shallow( + ); + click(multiValueInput.find('.js-remove-value').at(1)); + expect(onChange).toBeCalledWith(['foo', 'baz']); +}); - it('should add new value', () => { - const onChange = sinon.spy(); - const multiValueInput = mount( - - ); +it('should change existing value', () => { + const onChange = jest.fn(); + const multiValueInput = shallow( + ); + multiValueInput.find(PrimitiveInput).at(1).prop('onChange')('qux'); + expect(onChange).toBeCalledWith(['foo', 'qux', 'baz']); +}); - change(multiValueInput.find(InputForString).at(1).find('input'), 'bar'); - expect(onChange.called).to.equal(true); - expect(onChange.lastCall.args).to.deep.equal([['foo', 'bar']]); - }); +it('should add new value', () => { + const onChange = jest.fn(); + const multiValueInput = shallow(); + multiValueInput.find(PrimitiveInput).at(1).prop('onChange')('bar'); + expect(onChange).toBeCalledWith(['foo', 'bar']); }); diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/SimpleInput-test.js b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/SimpleInput-test.js index 679d5302eb9..1637dd18f30 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/SimpleInput-test.js +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/SimpleInput-test.js @@ -18,49 +18,44 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; -import { expect } from 'chai'; import { shallow } from 'enzyme'; -import sinon from 'sinon'; import SimpleInput from '../SimpleInput'; import { change } from '../../../../../../../../tests/utils'; -describe('Settings :: Inputs :: SimpleInput', () => { - it('should render input', () => { - const onChange = sinon.spy(); - const input = shallow( - - ).find('input'); - expect(input).to.have.length(1); - expect(input.prop('type')).to.equal('text'); - expect(input.prop('className')).to.include('input-large'); - expect(input.prop('name')).to.equal('foo'); - expect(input.prop('value')).to.equal('bar'); - expect(input.prop('onChange')).to.be.a('function'); - }); +it('should render input', () => { + const onChange = jest.fn(); + const input = shallow( + + ).find('input'); + expect(input.length).toBe(1); + expect(input.prop('type')).toBe('text'); + expect(input.prop('className')).toContain('input-large'); + expect(input.prop('name')).toBe('foo'); + expect(input.prop('value')).toBe('bar'); + expect(input.prop('onChange')).toBeTruthy(); +}); - it('should call onChange', () => { - const onChange = sinon.spy(); - const input = shallow( - - ).find('input'); - expect(input).to.have.length(1); - expect(input.prop('onChange')).to.be.a('function'); +it('should call onChange', () => { + const onChange = jest.fn(); + const input = shallow( + + ).find('input'); + expect(input.length).toBe(1); + expect(input.prop('onChange')).toBeTruthy(); - change(input, 'qux'); + change(input, 'qux'); - expect(onChange.called).to.equal(true); - expect(onChange.lastCall.args).to.deep.equal(['qux']); - }); + expect(onChange).toBeCalledWith('qux'); }); diff --git a/server/sonar-web/src/main/js/apps/system/__tests__/system-test.js b/server/sonar-web/src/main/js/apps/system/__tests__/system-test.js index fc31d9d0b8b..4e038d05b0a 100644 --- a/server/sonar-web/src/main/js/apps/system/__tests__/system-test.js +++ b/server/sonar-web/src/main/js/apps/system/__tests__/system-test.js @@ -18,101 +18,72 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; -import ReactDOM from 'react-dom'; -import TestUtils from 'react-addons-test-utils'; -import { expect } from 'chai'; - +import { shallow } from 'enzyme'; import ItemValue from '../item-value'; - -describe('System', function () { - - describe('Item Value', function () { - it('should render string', () => { - const result = TestUtils.renderIntoDocument(); - const content = ReactDOM.findDOMNode(TestUtils.findRenderedDOMComponentWithTag(result, 'code')); - expect(content.textContent).to.equal('/some/path/as/an/example'); - }); - - it('should render `true`', () => { - const result = TestUtils.renderIntoDocument(); - TestUtils.findRenderedDOMComponentWithClass(result, 'icon-check'); - }); - - it('should render `false`', () => { - const result = TestUtils.renderIntoDocument(); - TestUtils.findRenderedDOMComponentWithClass(result, 'icon-delete'); - }); - - it('should render object', () => { - const result = TestUtils.renderIntoDocument(); - TestUtils.findRenderedDOMComponentWithTag(result, 'table'); - expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'tr')).to.have.length(2); - }); - - it('should render `true` inside object', () => { - const result = TestUtils.renderIntoDocument(); - TestUtils.findRenderedDOMComponentWithTag(result, 'table'); - TestUtils.findRenderedDOMComponentWithClass(result, 'icon-check'); - }); - - it('should render object inside object', () => { - const result = TestUtils.renderIntoDocument( - ); - expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'table')).to.have.length(3); - expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'tr')).to.have.length(6); - }); +import ItemBoolean from '../item-boolean'; +import ItemObject from '../item-object'; +import ItemLogLevel from '../item-log-level'; + +describe('Item Value', function () { + it('should render string', () => { + const result = shallow(); + expect(result.find('code').text()).toBe('/some/path/as/an/example'); }); +}); - describe('Log Level', function () { - let previousFetch; - let fetchUrl; - let fetchOptions; +describe('ItemBoolean', () => { + it('should render `true`', () => { + const result = shallow(); + expect(result.find('.icon-check').length).toBe(1); + }); - before(function () { - previousFetch = window.fetch; - window.fetch = function (url, options) { - fetchUrl = url; - fetchOptions = options; - return Promise.resolve(); - }; - }); + it('should render `false`', () => { + const result = shallow(); + expect(result.find('.icon-delete').length).toBe(1); + }); +}); - after(function () { - window.fetch = previousFetch; - }); +describe('ItemObject', () => { + it('should render object', () => { + const result = shallow(); + expect(result.find('table').length).toBe(1); + expect(result.find('tr').length).toBe(2); + }); - it('should render select box', () => { - const result = TestUtils.renderIntoDocument(); - TestUtils.findRenderedDOMComponentWithTag(result, 'select'); - expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'option')).to.have.length(3); - }); + it('should render `true` inside object', () => { + const result = shallow(); + const itemValue = result.find(ItemValue); + expect(itemValue.length).toBe(1); + expect(itemValue.prop('value')).toBe(true); + }); - it('should set initial value', () => { - const result = TestUtils.renderIntoDocument(); - const select = ReactDOM.findDOMNode(TestUtils.findRenderedDOMComponentWithTag(result, 'select')); - expect(select.value).to.equal('DEBUG'); - }); + it('should render object inside object', () => { + const result = shallow(); + expect(result.find(ItemValue).length).toBe(2); + expect(result.find(ItemValue).at(0).prop('value')).toEqual({ docs: 1, shards: 5 }); + expect(result.find(ItemValue).at(1).prop('value')).toEqual({ docs: 68, shards: 5 }); + }); +}); - it('should render warning', () => { - const result = TestUtils.renderIntoDocument(); - TestUtils.findRenderedDOMComponentWithClass(result, 'alert'); - }); +describe('Log Level', function () { + it('should render select box', () => { + const result = shallow(); + expect(result.find('select').length).toBe(1); + expect(result.find('option').length).toBe(3); + }); - it('should not render warning', () => { - const result = TestUtils.renderIntoDocument(); - expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'alert')).to.be.empty; - }); + it('should set initial value', () => { + const result = shallow(); + expect(result.find('select').prop('value')).toBe('DEBUG'); + }); - // TODO replace with test with no WS call - it.skip('should change value', () => { - const result = TestUtils.renderIntoDocument(); - const select = ReactDOM.findDOMNode(TestUtils.findRenderedDOMComponentWithTag(result, 'select')); - select.value = 'TRACE'; - TestUtils.Simulate.change(select); - expect(fetchUrl).to.equal('/api/system/change_log_level'); - expect(fetchOptions.method).to.equal('POST'); - expect(fetchOptions.body).to.equal('level=TRACE'); - }); + it('should render warning', () => { + const result = shallow(); + expect(result.find('.alert').length).toBe(1); }); + it('should not render warning', () => { + const result = shallow(); + expect(result.find('.alert').length).toBe(0); + }); }); -- cgit v1.2.3