diff --git a/src/components/xy_chart/area.test.js b/src/components/xy_chart/area.test.js index 213699fa4a9..59a1b12020b 100644 --- a/src/components/xy_chart/area.test.js +++ b/src/components/xy_chart/area.test.js @@ -1,15 +1,16 @@ import React from 'react'; import { mount, render } from 'enzyme'; -import { patchRandom } from '../../test/patch_random'; +import { patchRandom, unpatchRandom } from '../../test/patch_random'; import EuiXYChart from './chart'; import { EuiArea } from './area'; import { benchmarkFunction } from '../../test/time_execution'; +beforeEach(patchRandom); +afterEach(unpatchRandom); + describe('EuiArea', () => { test('is rendered', () => { - const unpatchRandom = patchRandom(); - const component = mount( { ); expect(component).toMatchSnapshot(); - - unpatchRandom(); }); test('all props are rendered', () => { - const unpatchRandom = patchRandom(); - const component = mount( { ); expect(component).toMatchSnapshot(); - - unpatchRandom(); }); describe('performance', () => { diff --git a/src/components/xy_chart/bar.test.js b/src/components/xy_chart/bar.test.js index 39adce1cdd8..bfbd1b2310c 100644 --- a/src/components/xy_chart/bar.test.js +++ b/src/components/xy_chart/bar.test.js @@ -1,15 +1,16 @@ import React from 'react'; import { mount, render } from 'enzyme'; -import { patchRandom } from '../../test/patch_random'; +import { patchRandom, unpatchRandom } from '../../test/patch_random'; import EuiXYChart from './chart'; import EuiBar from './bar'; import { benchmarkFunction } from '../../test/time_execution'; +beforeEach(patchRandom); +afterEach(unpatchRandom); + describe('EuiBar', () => { test('is rendered', () => { - const unpatchRandom = patchRandom(); - const component = mount( { ); expect(component).toMatchSnapshot(); - - unpatchRandom(); }); test('all props are rendered', () => { - const unpatchRandom = patchRandom(); - const component = mount( { ); expect(component).toMatchSnapshot(); - - unpatchRandom(); }); describe('performance', () => { diff --git a/src/components/xy_chart/line.test.js b/src/components/xy_chart/line.test.js index 554f2d58d45..2ddcd554dc2 100644 --- a/src/components/xy_chart/line.test.js +++ b/src/components/xy_chart/line.test.js @@ -1,15 +1,16 @@ import React from 'react'; import { mount, render } from 'enzyme'; -import { patchRandom } from '../../test/patch_random'; +import { patchRandom, unpatchRandom } from '../../test/patch_random'; import { benchmarkFunction } from '../../test/time_execution'; import EuiXYChart from './chart'; import { EuiLine } from './line'; +beforeEach(patchRandom); +afterEach(unpatchRandom); + describe('EuiLine', () => { test('is rendered', () => { - const unpatchRandom = patchRandom(); - const component = mount( { ); expect(component).toMatchSnapshot(); - - unpatchRandom(); }); test('all props are rendered', () => { - const unpatchRandom = patchRandom(); - const component = mount( { ); expect(component).toMatchSnapshot(); - - unpatchRandom(); }); diff --git a/src/test/patch_random.js b/src/test/patch_random.js index 2803205b080..de18b8023de 100644 --- a/src/test/patch_random.js +++ b/src/test/patch_random.js @@ -1,10 +1,10 @@ +const _mathRandom = Math.random; + export function patchRandom() { - const _mathRandom = Math.random; let x = 0; Math.random = () => x += 0.00001; +} - // return a function to unpatch - return () => { - Math.random = _mathRandom; - }; +export function unpatchRandom() { + Math.random = _mathRandom; } diff --git a/yarn.lock b/yarn.lock index 053279f0854..73797c3f2ce 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3051,10 +3051,6 @@ es6-promise@^3.0.2: version "3.3.1" resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-3.3.1.tgz#a08cdde84ccdbf34d027a1451bc91d4bcd28a613" -es6-promise@^4.0.3: - version "4.2.4" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.4.tgz#dc4221c2b16518760bd8c39a52d8f356fc00ed29" - es6-set@~0.1.5: version "0.1.5" resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.5.tgz#d2b3ec5d4d800ced818db538d28974db0a73ccb1" @@ -3868,14 +3864,6 @@ fs-extra@^0.30.0: path-is-absolute "^1.0.0" rimraf "^2.2.8" -fs-extra@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-1.0.0.tgz#cd3ce5f7e7cb6145883fcae3191e9877f8587950" - dependencies: - graceful-fs "^4.1.2" - jsonfile "^2.1.0" - klaw "^1.0.0" - fs-extra@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-3.0.1.tgz#3794f378c58b342ea7dbbb23095109c4b3b62291" @@ -4391,13 +4379,6 @@ hash.js@^1.0.0, hash.js@^1.0.3: inherits "^2.0.3" minimalistic-assert "^1.0.0" -hasha@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/hasha/-/hasha-2.2.0.tgz#78d7cbfc1e6d66303fe79837365984517b2f6ee1" - dependencies: - is-stream "^1.0.1" - pinkie-promise "^2.0.0" - hawk@3.1.3, hawk@~3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" @@ -7368,20 +7349,6 @@ performance-now@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" -phantomjs-prebuilt@^2.1.16: - version "2.1.16" - resolved "https://registry.yarnpkg.com/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz#efd212a4a3966d3647684ea8ba788549be2aefef" - dependencies: - es6-promise "^4.0.3" - extract-zip "^1.6.5" - fs-extra "^1.0.0" - hasha "^2.2.0" - kew "^0.7.0" - progress "^1.1.8" - request "^2.81.0" - request-progress "^2.0.1" - which "^1.2.10" - pify@^2.0.0, pify@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" @@ -7839,10 +7806,6 @@ progress@2.0.0, progress@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" -progress@^1.1.8: - version "1.1.8" - resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" - promise-timeout@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/promise-timeout/-/promise-timeout-1.3.0.tgz#d1c78dd50a607d5f0a5207410252a3a0914e1014" @@ -8505,12 +8468,6 @@ replace-ext@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-1.0.0.tgz#de63128373fcbf7c3ccfa4de5a480c45a67958eb" -request-progress@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/request-progress/-/request-progress-2.0.1.tgz#5d36bb57961c673aa5b788dbc8141fdf23b44e08" - dependencies: - throttleit "^1.0.0" - request-promise-core@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.1.tgz#3eee00b2c5aa83239cfb04c5700da36f81cd08b6" @@ -9749,10 +9706,6 @@ throat@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a" -throttleit@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-1.0.0.tgz#9e785836daf46743145a5984b6268d828528ac6c" - through2@^2.0.0, through2@^2.0.1: version "2.0.3" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be" @@ -10377,6 +10330,7 @@ wdio-visual-regression-service@silne30/wdio-visual-regression-service#Add_Filena lodash "^4.13.1" node-resemble-js "0.0.5" nodeclient-spectre "^1.0.3" + phantomjs-prebuilt "^2.1.16" platform "^1.3.1" wdio-screenshot "^0.6.0"