From dc16506da859bfe0dedb924d5d30fa41954cc600 Mon Sep 17 00:00:00 2001 From: Aleh Zasypkin Date: Tue, 22 May 2018 15:41:45 +0200 Subject: [PATCH] [6.x] Upgrade `sinon` (v1.17.3 --> v5.0.7). (#19293) --- package.json | 2 +- packages/kbn-datemath/test/index.js | 8 +- packages/kbn-ui-framework/package.json | 2 +- .../tool_bar/tool_bar_search_box.test.js | 4 +- packages/kbn-ui-framework/yarn.lock | 77 +++++++++---- src/cli/cluster/cluster_manager.test.js | 4 +- src/cli/cluster/worker.test.js | 4 +- src/cli_keystore/add.test.js | 2 +- src/cli_keystore/create.test.js | 2 +- src/cli_keystore/list.test.js | 2 +- src/cli_keystore/remove.test.js | 2 +- src/cli_plugin/install/cleanup.test.js | 15 +-- src/cli_plugin/install/rename.test.js | 6 +- .../console/server/__tests__/proxy_config.js | 4 +- .../__tests__/proxy_config_collection.js | 2 +- .../server/__tests__/proxy_route/body.js | 6 +- .../server/__tests__/proxy_route/headers.js | 7 +- .../server/__tests__/proxy_route/params.js | 7 +- .../__tests__/proxy_route/query_string.js | 7 +- .../lib/__tests__/create_clusters.js | 4 +- .../lib/__tests__/ensure_not_tribe.js | 2 +- .../lib/__tests__/health_check.js | 25 ++-- .../dashboard/__tests__/dashboard_context.js | 2 +- .../hacks/__tests__/hide_empty_tools.js | 4 +- .../server/lib/__tests__/manage_uuid.js | 1 - .../export/__tests__/collect_dashboards.js | 4 +- .../__tests__/collect_index_patterns.js | 4 +- .../lib/export/__tests__/collect_panels.js | 4 +- .../__tests__/collect_search_sources.js | 4 +- .../services/__tests__/executor_provider.js | 12 +- .../__tests__/region_map_visualization.js | 2 +- .../coordinate_maps_visualization.js | 2 +- src/dev/build/lib/__tests__/build.js | 4 +- src/dev/build/lib/__tests__/exec.js | 2 +- src/dev/build/lib/__tests__/runner.js | 2 +- .../build/tasks/nodejs/__tests__/download.js | 4 +- .../__tests__/download_node_builds_task.js | 6 +- .../__tests__/extract_node_builds_task.js | 2 +- .../verify_existing_node_builds_task.js | 6 +- .../bundles_route/__tests__/bundles_route.js | 4 +- .../__tests__/extend_config_service.js | 2 +- .../plugin_spec/__tests__/plugin_spec.js | 2 +- src/server/config/complete.test.js | 4 +- src/server/http/short_url_lookup.test.js | 2 +- .../index_patterns/service/lib/es_api.test.js | 8 +- .../field_capabilities.test.js | 8 +- .../field_caps_response.test.js | 2 +- .../service/lib/resolve_time_pattern.test.js | 2 +- src/server/keystore/keystore.test.js | 2 +- .../client/lib/search_dsl/search_dsl.test.js | 2 +- .../client/saved_objects_client.test.js | 6 +- .../saved_objects/routes/bulk_get.test.js | 2 +- .../saved_objects/routes/create.test.js | 2 +- .../saved_objects/routes/delete.test.js | 2 +- src/server/saved_objects/routes/find.test.js | 2 +- src/server/saved_objects/routes/get.test.js | 2 +- .../saved_objects/routes/update.test.js | 2 +- .../metrics_collector.test.js | 4 +- src/server/utils/prompt.test.js | 2 +- .../__tests__/field_formats_mixin.js | 4 +- .../__tests__/build_hierarchical_data.js | 2 +- .../agg_types/__tests__/buckets/_geo_hash.js | 4 +- src/ui/public/chrome/api/__tests__/xsrf.js | 2 +- .../public/courier/__tests__/saved_object.js | 12 +- .../fetch/request/__tests__/segmented.js | 2 +- src/ui/public/debounce/__tests__/debounce.js | 14 +-- .../directives/__tests__/fixed_scroll.js | 4 +- .../public/directives/__tests__/timepicker.js | 2 +- .../__tests__/filter_bar_click_handler.js | 2 +- .../__tests__/filter_manager.js | 8 +- src/ui/public/filters/__tests__/moment.js | 2 +- .../__tests__/index_patterns.js | 4 +- .../public/modals/__tests__/confirm_modal.js | 4 +- .../__tests__/find_object_by_title.js | 2 +- .../__tests__/saved_objects_client.js | 2 +- .../public/share/__tests__/url_shortener.js | 2 +- .../state_management/__tests__/state.js | 2 +- src/ui/public/test_harness/test_harness.js | 3 +- src/ui/public/timepicker/__tests__/toggle.js | 4 +- src/ui/public/utils/__tests__/scanner.js | 2 +- src/ui/public/vis/__tests__/_agg_configs.js | 4 +- .../vis/__tests__/map/service_settings.js | 2 +- .../tooltip/__tests__/positioning.js | 2 +- .../visualize/loader/__tests__/loader.js | 4 +- .../ui_settings_mixin_integration.js | 2 +- .../__tests__/ui_settings_service.js | 2 +- .../create_or_upgrade_saved_config.js | 2 +- .../streams/__tests__/intersperse_stream.js | 2 +- x-pack/package.json | 3 +- .../csv/server/__tests__/execute_job.js | 3 +- .../__tests__/authorized_user_pre_routing.js | 2 +- .../server/lib/__tests__/validate_config.js | 2 +- .../esqueue/__tests__/helpers/create_index.js | 2 +- .../server/lib/esqueue/__tests__/job.js | 4 +- .../server/lib/esqueue/__tests__/worker.js | 20 ++-- .../server/lib/__tests__/auth_redirect.js | 9 +- .../server/lib/__tests__/validate_config.js | 4 +- .../authentication/__tests__/authenticator.js | 2 +- .../lib/authentication/__tests__/session.js | 6 +- .../routes/api/v1/__tests__/authenticate.js | 54 +++++++-- .../server/routes/api/v1/__tests__/users.js | 2 +- .../models/watch/__tests__/base_watch.js | 6 +- .../models/watch/__tests__/json_watch.js | 10 +- .../watch/__tests__/monitoring_watch.js | 6 +- .../models/watch/__tests__/threshold_watch.js | 26 ++--- .../server/models/watch/__tests__/watch.js | 4 +- .../__tests__/check_xpack_info_change.js | 4 +- .../server/lib/__tests__/setup_xpack_main.js | 8 +- .../server/lib/__tests__/xpack_info.js | 8 +- .../routes/api/v1/__tests__/xpack_info.js | 7 +- x-pack/yarn.lock | 107 +++++++++--------- yarn.lock | 75 ++++++++---- 112 files changed, 444 insertions(+), 354 deletions(-) diff --git a/package.json b/package.json index d2ecaf87af0d7..7ae7ded7c40b8 100644 --- a/package.json +++ b/package.json @@ -293,7 +293,7 @@ "prettier": "^1.12.1", "proxyquire": "1.7.11", "simple-git": "1.37.0", - "sinon": "1.17.3", + "sinon": "^5.0.7", "source-map": "0.5.6", "source-map-support": "0.2.10", "strip-ansi": "^3.0.1", diff --git a/packages/kbn-datemath/test/index.js b/packages/kbn-datemath/test/index.js index 4b13c27a2257b..18ea693413e18 100644 --- a/packages/kbn-datemath/test/index.js +++ b/packages/kbn-datemath/test/index.js @@ -355,8 +355,8 @@ describe('dateMath', function() { dateMath.parse('now', { momentInstance: m1 }); expect(m1Spy.called).to.be(true); expect(m2Spy.called).to.be(false); - m1Spy.reset(); - m2Spy.reset(); + m1Spy.resetHistory(); + m2Spy.resetHistory(); dateMath.parse('now', { momentInstance: m2 }); expect(m1Spy.called).to.be(false); expect(m2Spy.called).to.be(true); @@ -371,8 +371,8 @@ describe('dateMath', function() { dateMath.parse('now', { momentInstance: m }); expect(momentSpy.called).to.be(false); expect(cloneSpy.called).to.be(true); - momentSpy.reset(); - cloneSpy.reset(); + momentSpy.resetHistory(); + cloneSpy.resetHistory(); dateMath.parse('now'); expect(momentSpy.called).to.be(true); expect(cloneSpy.called).to.be(false); diff --git a/packages/kbn-ui-framework/package.json b/packages/kbn-ui-framework/package.json index 3b6826c45ef4f..9c752ae7849c0 100644 --- a/packages/kbn-ui-framework/package.json +++ b/packages/kbn-ui-framework/package.json @@ -65,7 +65,7 @@ "redux": "3.7.2", "redux-thunk": "2.2.0", "sass-loader": "6.0.6", - "sinon": "1.17.2", + "sinon": "^5.0.7", "style-loader": "0.19.0", "webpack": "3.6.0", "webpack-dev-server": "2.9.1", diff --git a/packages/kbn-ui-framework/src/components/tool_bar/tool_bar_search_box.test.js b/packages/kbn-ui-framework/src/components/tool_bar/tool_bar_search_box.test.js index 7f54bb3bb4e69..610a94ba13f9a 100644 --- a/packages/kbn-ui-framework/src/components/tool_bar/tool_bar_search_box.test.js +++ b/packages/kbn-ui-framework/src/components/tool_bar/tool_bar_search_box.test.js @@ -7,7 +7,7 @@ import { KuiToolBarSearchBox, } from './tool_bar_search_box'; -const onFilter = sinon.spy(); +const onFilter = sinon.stub(); test('renders KuiToolBarSearchBox', () => { const component = ; @@ -17,7 +17,7 @@ test('renders KuiToolBarSearchBox', () => { describe('onFilter', () => { test('is called on change event, with the value entered', () => { const searchBox = mount(); - onFilter.reset(); + onFilter.resetHistory(); const event = { target: { value: 'a' } }; searchBox.find('input').simulate('change', event); sinon.assert.calledWith(onFilter, 'a'); diff --git a/packages/kbn-ui-framework/yarn.lock b/packages/kbn-ui-framework/yarn.lock index a26924373babb..e3bd267f93b4e 100644 --- a/packages/kbn-ui-framework/yarn.lock +++ b/packages/kbn-ui-framework/yarn.lock @@ -27,6 +27,12 @@ version "0.0.0" uid "" +"@sinonjs/formatio@^2.0.0": + version "2.0.0" + resolved "http://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz#84db7e9eb5531df18a8c5e0bfb6e449e55e654b2" + dependencies: + samsam "1.3.0" + "@zeit/check-updates@1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@zeit/check-updates/-/check-updates-1.1.0.tgz#d0f65026a36f27cd1fd54c647d8294447c1d2d8b" @@ -2085,7 +2091,7 @@ diff@^2.1.2: version "2.2.3" resolved "https://registry.yarnpkg.com/diff/-/diff-2.2.3.tgz#60eafd0d28ee906e4e8ff0a52c1229521033bf99" -diff@^3.3.1: +diff@^3.1.0, diff@^3.3.1: version "3.5.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" @@ -2773,12 +2779,6 @@ form-data@~2.3.1: combined-stream "1.0.6" mime-types "^2.1.12" -formatio@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/formatio/-/formatio-1.1.1.tgz#5ed3ccd636551097383465d996199100e86161e9" - dependencies: - samsam "~1.1" - forwarded@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" @@ -4027,6 +4027,10 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" +just-extend@^1.1.27: + version "1.1.27" + resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-1.1.27.tgz#ec6e79410ff914e472652abfa0e603c03d60e905" + keymirror@0.1.1, keymirror@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/keymirror/-/keymirror-0.1.1.tgz#918889ea13f8d0a42e7c557250eee713adc95c35" @@ -4215,9 +4219,9 @@ loglevel@^1.4.1: version "1.6.1" resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.1.tgz#e0fc95133b6ef276cdc8887cdaf24aa6f156f8fa" -lolex@1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.3.2.tgz#7c3da62ffcb30f0f5a80a2566ca24e45d8a01f31" +lolex@^2.2.0, lolex@^2.3.2: + version "2.5.0" + resolved "https://registry.yarnpkg.com/lolex/-/lolex-2.5.0.tgz#69d6a667607738564daf108f63240ae8cbd28fb4" longest@^1.0.1: version "1.0.1" @@ -4562,6 +4566,16 @@ neo-async@^2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.5.0.tgz#76b1c823130cca26acfbaccc8fbaf0a2fa33b18f" +nise@^1.2.0: + version "1.3.3" + resolved "https://registry.yarnpkg.com/nise/-/nise-1.3.3.tgz#c17a850066a8a1dfeb37f921da02441afc4a82ba" + dependencies: + "@sinonjs/formatio" "^2.0.0" + just-extend "^1.1.27" + lolex "^2.3.2" + path-to-regexp "^1.7.0" + text-encoding "^0.6.4" + no-case@^2.2.0: version "2.3.2" resolved "https://registry.yarnpkg.com/no-case/-/no-case-2.3.2.tgz#60b813396be39b3f1288a4c1ed5d1e7d28b464ac" @@ -6089,13 +6103,9 @@ safe-regex@^1.1.0: dependencies: ret "~0.1.10" -samsam@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.2.tgz#bec11fdc83a9fda063401210e40176c3024d1567" - -samsam@~1.1: - version "1.1.3" - resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.3.tgz#9f5087419b4d091f232571e7fa52e90b0f552621" +samsam@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.3.0.tgz#8d1d9350e25622da30de3e44ba692b5221ab7c50" sass-graph@^2.1.1: version "2.2.4" @@ -6341,14 +6351,17 @@ signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" -sinon@1.17.2: - version "1.17.2" - resolved "https://registry.yarnpkg.com/sinon/-/sinon-1.17.2.tgz#c1ea67b84a1e7b3350f6c4713efacef8e4ae8b71" +sinon@^5.0.7: + version "5.0.7" + resolved "https://registry.yarnpkg.com/sinon/-/sinon-5.0.7.tgz#3bded6a73613ccc9e512e20246ced69a27c27dab" dependencies: - formatio "1.1.1" - lolex "1.3.2" - samsam "1.1.2" - util ">=0.10.3 <1" + "@sinonjs/formatio" "^2.0.0" + diff "^3.1.0" + lodash.get "^4.4.2" + lolex "^2.2.0" + nise "^1.2.0" + supports-color "^5.1.0" + type-detect "^4.0.5" slash@^1.0.0: version "1.0.0" @@ -6709,6 +6722,12 @@ supports-color@^4.0.0, supports-color@^4.2.1: dependencies: has-flag "^2.0.0" +supports-color@^5.1.0: + version "5.4.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.4.0.tgz#1c6b337402c2137605efe19f10fec390f6faab54" + dependencies: + has-flag "^3.0.0" + supports-color@^5.2.0, supports-color@^5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.3.0.tgz#5b24ac15db80fa927cf5227a4a33fd3c4c7676c0" @@ -6788,6 +6807,10 @@ term-size@^1.2.0: dependencies: execa "^0.7.0" +text-encoding@^0.6.4: + version "0.6.4" + resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19" + text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" @@ -6918,6 +6941,10 @@ twig@^0.8.2: minimatch "3.0.x" walk "2.3.x" +type-detect@^4.0.5: + version "4.0.8" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" + type-is@~1.6.15: version "1.6.16" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.16.tgz#f89ce341541c672b25ee7ae3c73dee3b2be50194" @@ -7109,7 +7136,7 @@ util-deprecate@^1.0.2, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" -util@0.10.3, "util@>=0.10.3 <1", util@^0.10.3: +util@0.10.3, util@^0.10.3: version "0.10.3" resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" dependencies: diff --git a/src/cli/cluster/cluster_manager.test.js b/src/cli/cluster/cluster_manager.test.js index 6c5d394656bc4..fbdeb50153dbe 100644 --- a/src/cli/cluster/cluster_manager.test.js +++ b/src/cli/cluster/cluster_manager.test.js @@ -6,10 +6,10 @@ import ClusterManager from './cluster_manager'; import Worker from './worker'; describe('CLI cluster manager', function () { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); beforeEach(function () { - sandbox.stub(cluster, 'fork', function () { + sandbox.stub(cluster, 'fork').callsFake(() => { return { process: { kill: sinon.stub(), diff --git a/src/cli/cluster/worker.test.js b/src/cli/cluster/worker.test.js index 61a5b51909b15..4664d0e36b32f 100644 --- a/src/cli/cluster/worker.test.js +++ b/src/cli/cluster/worker.test.js @@ -32,10 +32,10 @@ function setup(opts = {}) { } describe('CLI cluster manager', function () { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); beforeEach(function () { - sandbox.stub(cluster, 'fork', () => new MockClusterFork()); + sandbox.stub(cluster, 'fork').callsFake(() => new MockClusterFork()); }); afterEach(async function () { diff --git a/src/cli_keystore/add.test.js b/src/cli_keystore/add.test.js index 3282a9d4e949e..28d62fbcf9c6d 100644 --- a/src/cli_keystore/add.test.js +++ b/src/cli_keystore/add.test.js @@ -9,7 +9,7 @@ import * as prompt from '../server/utils/prompt'; describe('Kibana keystore', () => { describe('add', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); const keystoreData = '1:IxR0geiUTMJp8ueHDkqeUJ0I9eEw4NJPXIJi22UDyfGfJSy4mH' + 'BBuGPkkAix/x/YFfIxo4tiKGdJ2oVTtU8LgKDkVoGdL+z7ylY4n3myatt6osqhI4lzJ9M' diff --git a/src/cli_keystore/create.test.js b/src/cli_keystore/create.test.js index b1a04f9e09660..6bfd0c6aad773 100644 --- a/src/cli_keystore/create.test.js +++ b/src/cli_keystore/create.test.js @@ -8,7 +8,7 @@ import * as prompt from '../server/utils/prompt'; describe('Kibana keystore', () => { describe('create', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); const keystoreData = '1:IxR0geiUTMJp8ueHDkqeUJ0I9eEw4NJPXIJi22UDyfGfJSy4mH' + 'BBuGPkkAix/x/YFfIxo4tiKGdJ2oVTtU8LgKDkVoGdL+z7ylY4n3myatt6osqhI4lzJ9M' diff --git a/src/cli_keystore/list.test.js b/src/cli_keystore/list.test.js index 4ac7163a1c06b..6105867398758 100644 --- a/src/cli_keystore/list.test.js +++ b/src/cli_keystore/list.test.js @@ -7,7 +7,7 @@ import Logger from '../cli_plugin/lib/logger'; describe('Kibana keystore', () => { describe('list', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); const keystoreData = '1:IxR0geiUTMJp8ueHDkqeUJ0I9eEw4NJPXIJi22UDyfGfJSy4mH' + 'BBuGPkkAix/x/YFfIxo4tiKGdJ2oVTtU8LgKDkVoGdL+z7ylY4n3myatt6osqhI4lzJ9M' diff --git a/src/cli_keystore/remove.test.js b/src/cli_keystore/remove.test.js index 020b6e6f021b2..3773709ebb03c 100644 --- a/src/cli_keystore/remove.test.js +++ b/src/cli_keystore/remove.test.js @@ -6,7 +6,7 @@ import { remove } from './remove'; describe('Kibana keystore', () => { describe('remove', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); const keystoreData = '1:IxR0geiUTMJp8ueHDkqeUJ0I9eEw4NJPXIJi22UDyfGfJSy4mH' + 'BBuGPkkAix/x/YFfIxo4tiKGdJ2oVTtU8LgKDkVoGdL+z7ylY4n3myatt6osqhI4lzJ9M' diff --git a/src/cli_plugin/install/cleanup.test.js b/src/cli_plugin/install/cleanup.test.js index 76e115e94d1d1..ab6c5ccf30918 100644 --- a/src/cli_plugin/install/cleanup.test.js +++ b/src/cli_plugin/install/cleanup.test.js @@ -34,7 +34,7 @@ describe('kibana cli', function () { it('should resolve if the working path does not exist', function () { sinon.stub(rimraf, 'sync'); - sinon.stub(fs, 'statSync', function () { + sinon.stub(fs, 'statSync').callsFake(() => { const error = new Error('ENOENT'); error.code = 'ENOENT'; throw error; @@ -49,10 +49,7 @@ describe('kibana cli', function () { it('should rethrow any exception except ENOENT from fs.statSync', function () { sinon.stub(rimraf, 'sync'); - sinon.stub(fs, 'statSync', function () { - const error = new Error('An Unhandled Error'); - throw error; - }); + sinon.stub(fs, 'statSync').throws(new Error('An Unhandled Error')); errorStub = sinon.stub(); return cleanPrevious(settings, logger) @@ -75,9 +72,7 @@ describe('kibana cli', function () { it('should rethrow any exception from rimraf.sync', function () { sinon.stub(fs, 'statSync'); - sinon.stub(rimraf, 'sync', function () { - throw new Error('I am an error thrown by rimraf'); - }); + sinon.stub(rimraf, 'sync').throws(new Error('I am an error thrown by rimraf')); errorStub = sinon.stub(); return cleanPrevious(settings, logger) @@ -114,9 +109,7 @@ describe('kibana cli', function () { }); it('should swallow any errors thrown by rimraf.sync', function () { - sinon.stub(rimraf, 'sync', function () { - throw new Error('Something bad happened.'); - }); + sinon.stub(rimraf, 'sync').throws(new Error('Something bad happened.')); expect(() => cleanArtifacts(settings)).not.toThrow(); }); diff --git a/src/cli_plugin/install/rename.test.js b/src/cli_plugin/install/rename.test.js index 3e2fb633a709e..b57eda122fc65 100644 --- a/src/cli_plugin/install/rename.test.js +++ b/src/cli_plugin/install/rename.test.js @@ -15,7 +15,7 @@ describe('plugin folder rename', function () { }); it('should rethrow any exceptions', function () { - renameStub = sinon.stub(fs, 'rename', function (from, to, cb) { + renameStub = sinon.stub(fs, 'rename').callsFake((from, to, cb) => { cb({ code: 'error' }); @@ -29,7 +29,7 @@ describe('plugin folder rename', function () { }); it('should resolve if there are no errors', function () { - renameStub = sinon.stub(fs, 'rename', function (from, to, cb) { + renameStub = sinon.stub(fs, 'rename').callsFake((from, to, cb) => { cb(); }); @@ -55,7 +55,7 @@ describe('plugin folder rename', function () { }); it('should retry on Windows EPERM errors for up to 3 seconds', function () { - renameStub = sinon.stub(fs, 'rename', function (from, to, cb) { + renameStub = sinon.stub(fs, 'rename').callsFake((from, to, cb) => { cb({ code: 'EPERM' }); diff --git a/src/core_plugins/console/server/__tests__/proxy_config.js b/src/core_plugins/console/server/__tests__/proxy_config.js index 9174d92e275d0..f25ff8db8678b 100644 --- a/src/core_plugins/console/server/__tests__/proxy_config.js +++ b/src/core_plugins/console/server/__tests__/proxy_config.js @@ -18,9 +18,7 @@ const parsedLocalEs = parseUrl('https://localhost:5601/search'); describe('ProxyConfig', function () { beforeEach(function () { - sinon.stub(fs, 'readFileSync', function (path) { - return { path }; - }); + sinon.stub(fs, 'readFileSync').callsFake((path) => ({ path })); }); afterEach(function () { diff --git a/src/core_plugins/console/server/__tests__/proxy_config_collection.js b/src/core_plugins/console/server/__tests__/proxy_config_collection.js index 2f4ecf222abd0..4777d42852a3c 100644 --- a/src/core_plugins/console/server/__tests__/proxy_config_collection.js +++ b/src/core_plugins/console/server/__tests__/proxy_config_collection.js @@ -9,7 +9,7 @@ import { ProxyConfigCollection } from '../proxy_config_collection'; describe('ProxyConfigCollection', function () { beforeEach(function () { - sinon.stub(fs, 'readFileSync', () => new Buffer(0)); + sinon.stub(fs, 'readFileSync').callsFake(() => new Buffer(0)); }); afterEach(function () { diff --git a/src/core_plugins/console/server/__tests__/proxy_route/body.js b/src/core_plugins/console/server/__tests__/proxy_route/body.js index 6be331d38bada..f285fb171c915 100644 --- a/src/core_plugins/console/server/__tests__/proxy_route/body.js +++ b/src/core_plugins/console/server/__tests__/proxy_route/body.js @@ -8,14 +8,13 @@ import { createProxyRoute } from '../../'; import { createWreckResponseStub } from './stubs'; describe('Console Proxy Route', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); const teardowns = []; let request; beforeEach(() => { - teardowns.push(() => sandbox.restore()); request = async (method, path, response) => { - sandbox.stub(Wreck, 'request', createWreckResponseStub(response)); + sandbox.stub(Wreck, 'request').callsFake(createWreckResponseStub(response)); const server = new Server(); @@ -37,6 +36,7 @@ describe('Console Proxy Route', () => { }); afterEach(async () => { + sandbox.restore(); await Promise.all(teardowns.splice(0).map(fn => fn())); }); diff --git a/src/core_plugins/console/server/__tests__/proxy_route/headers.js b/src/core_plugins/console/server/__tests__/proxy_route/headers.js index 30cbcc6cb7c52..f09bb34a47e86 100644 --- a/src/core_plugins/console/server/__tests__/proxy_route/headers.js +++ b/src/core_plugins/console/server/__tests__/proxy_route/headers.js @@ -10,14 +10,12 @@ import { createProxyRoute } from '../../'; import { createWreckResponseStub } from './stubs'; describe('Console Proxy Route', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); const teardowns = []; let setup; beforeEach(() => { - teardowns.push(() => sandbox.restore()); - - sandbox.stub(Wreck, 'request', createWreckResponseStub()); + sandbox.stub(Wreck, 'request').callsFake(createWreckResponseStub()); setup = () => { const server = new Server(); @@ -34,6 +32,7 @@ describe('Console Proxy Route', () => { }); afterEach(async () => { + sandbox.restore(); await Promise.all(teardowns.splice(0).map(fn => fn())); }); diff --git a/src/core_plugins/console/server/__tests__/proxy_route/params.js b/src/core_plugins/console/server/__tests__/proxy_route/params.js index dd95b85bf018a..1801f6db13e35 100644 --- a/src/core_plugins/console/server/__tests__/proxy_route/params.js +++ b/src/core_plugins/console/server/__tests__/proxy_route/params.js @@ -10,14 +10,12 @@ import { createProxyRoute } from '../../'; import { createWreckResponseStub } from './stubs'; describe('Console Proxy Route', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); const teardowns = []; let setup; beforeEach(() => { - teardowns.push(() => sandbox.restore()); - - sandbox.stub(Wreck, 'request', createWreckResponseStub()); + sandbox.stub(Wreck, 'request').callsFake(createWreckResponseStub()); setup = () => { const server = new Server(); @@ -28,6 +26,7 @@ describe('Console Proxy Route', () => { }); afterEach(async () => { + sandbox.restore(); await Promise.all(teardowns.splice(0).map(fn => fn())); }); diff --git a/src/core_plugins/console/server/__tests__/proxy_route/query_string.js b/src/core_plugins/console/server/__tests__/proxy_route/query_string.js index 1f0229e228e40..cdf2927c8e117 100644 --- a/src/core_plugins/console/server/__tests__/proxy_route/query_string.js +++ b/src/core_plugins/console/server/__tests__/proxy_route/query_string.js @@ -8,14 +8,12 @@ import { createProxyRoute } from '../../'; import { createWreckResponseStub } from './stubs'; describe('Console Proxy Route', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); const teardowns = []; let request; beforeEach(() => { - teardowns.push(() => sandbox.restore()); - - sandbox.stub(Wreck, 'request', createWreckResponseStub()); + sandbox.stub(Wreck, 'request').callsFake(createWreckResponseStub()); request = async (method, path) => { const server = new Server(); @@ -38,6 +36,7 @@ describe('Console Proxy Route', () => { }); afterEach(async () => { + sandbox.restore(); await Promise.all(teardowns.splice(0).map(fn => fn())); }); diff --git a/src/core_plugins/elasticsearch/lib/__tests__/create_clusters.js b/src/core_plugins/elasticsearch/lib/__tests__/create_clusters.js index 7f621057c27af..9eb1038480687 100644 --- a/src/core_plugins/elasticsearch/lib/__tests__/create_clusters.js +++ b/src/core_plugins/elasticsearch/lib/__tests__/create_clusters.js @@ -52,10 +52,10 @@ describe('plugins/elasticsearch', function () { }); describe('server stop', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); beforeEach(() => { - sandbox.stub(ClusterNS, 'Cluster', function () { + sandbox.stub(ClusterNS, 'Cluster').callsFake(function () { this.stub = true; this.close = sinon.stub(); }); diff --git a/src/core_plugins/elasticsearch/lib/__tests__/ensure_not_tribe.js b/src/core_plugins/elasticsearch/lib/__tests__/ensure_not_tribe.js index c094655ea0faa..2c0710ad2232b 100644 --- a/src/core_plugins/elasticsearch/lib/__tests__/ensure_not_tribe.js +++ b/src/core_plugins/elasticsearch/lib/__tests__/ensure_not_tribe.js @@ -4,7 +4,7 @@ import sinon from 'sinon'; import { ensureNotTribe } from '../ensure_not_tribe'; describe('plugins/elasticsearch ensureNotTribe', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); afterEach(() => sandbox.restore()); const stubcallWithInternalUser = (nodesInfoResp = { nodes: {} }) => { diff --git a/src/core_plugins/elasticsearch/lib/__tests__/health_check.js b/src/core_plugins/elasticsearch/lib/__tests__/health_check.js index 45722950c3920..465e3778d1af6 100644 --- a/src/core_plugins/elasticsearch/lib/__tests__/health_check.js +++ b/src/core_plugins/elasticsearch/lib/__tests__/health_check.js @@ -15,19 +15,18 @@ const esUrl = esTestConfig.getUrl(); describe('plugins/elasticsearch', () => { describe('lib/health_check', function () { - this.timeout(3000); - let health; let plugin; let cluster; let server; - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); function getTimerCount() { return Object.keys(sandbox.clock.timers || {}).length; } beforeEach(() => { + sandbox.useFakeTimers(); const COMPATIBLE_VERSION_NUMBER = '5.0.0'; // Stub the Kibana version instead of drawing from package.json. @@ -90,8 +89,6 @@ describe('plugins/elasticsearch', () => { afterEach(() => sandbox.restore()); it('should stop when cluster is shutdown', () => { - sandbox.useFakeTimers(); - // ensure that health.start() is responsible for the timer we are observing expect(getTimerCount()).to.be(0); health.start(); @@ -127,13 +124,19 @@ describe('plugins/elasticsearch', () => { }); }); - it('should set the cluster red if the ping fails, then to green', function () { + it('should set the cluster red if the ping fails, then to green', async () => { const ping = cluster.callWithInternalUser.withArgs('ping'); ping.onCall(0).returns(Promise.reject(new NoConnections())); ping.onCall(1).returns(Promise.resolve()); - return health.run() - .then(function () { + const healthRunPromise = health.run(); + + // Exhaust micro-task queue, to make sure that next health check is rescheduled. + await Promise.resolve(); + sandbox.clock.runAll(); + + return healthRunPromise + .then(() => { sinon.assert.calledOnce(plugin.status.yellow); sinon.assert.calledWithExactly(plugin.status.yellow, 'Waiting for Elasticsearch'); @@ -157,7 +160,11 @@ describe('plugins/elasticsearch', () => { setImmediate(handler); }); - return health.waitUntilReady().then(function () { + const waitUntilReadyPromise = health.waitUntilReady(); + + sandbox.clock.runAll(); + + return waitUntilReadyPromise.then(function () { sinon.assert.calledOnce(plugin.status.once); }); }); diff --git a/src/core_plugins/kibana/public/dashboard/__tests__/dashboard_context.js b/src/core_plugins/kibana/public/dashboard/__tests__/dashboard_context.js index 6081ceb5020cb..a572a19d57503 100644 --- a/src/core_plugins/kibana/public/dashboard/__tests__/dashboard_context.js +++ b/src/core_plugins/kibana/public/dashboard/__tests__/dashboard_context.js @@ -67,7 +67,7 @@ describe('Dashboard Context', () => { }); afterEach(() => { - getAppState.reset(); + getAppState.resetHistory(); }); it('should add a valid filter to must', () => { diff --git a/src/core_plugins/kibana/public/dev_tools/hacks/__tests__/hide_empty_tools.js b/src/core_plugins/kibana/public/dev_tools/hacks/__tests__/hide_empty_tools.js index e6d3a5be172dc..01f6b9bc94e31 100644 --- a/src/core_plugins/kibana/public/dev_tools/hacks/__tests__/hide_empty_tools.js +++ b/src/core_plugins/kibana/public/dev_tools/hacks/__tests__/hide_empty_tools.js @@ -21,9 +21,7 @@ describe('hide dev tools', function () { beforeEach(function () { navlinks = {}; - sinon.stub(chrome, 'getNavLinkById', function () { - return navlinks; - }); + sinon.stub(chrome, 'getNavLinkById').returns(navlinks); }); it('should hide the app if there are no dev tools', function () { diff --git a/src/core_plugins/kibana/server/lib/__tests__/manage_uuid.js b/src/core_plugins/kibana/server/lib/__tests__/manage_uuid.js index 216292c6c4de5..298cd7079fec7 100644 --- a/src/core_plugins/kibana/server/lib/__tests__/manage_uuid.js +++ b/src/core_plugins/kibana/server/lib/__tests__/manage_uuid.js @@ -20,7 +20,6 @@ describe('core_plugins/kibana/server/lib', function () { // clear uuid stuff from previous test runs beforeEach(function () { kbnServer.server.log = sinon.stub(); - kbnServer.server.log.reset(); config = kbnServer.server.config(); }); diff --git a/src/core_plugins/kibana/server/lib/export/__tests__/collect_dashboards.js b/src/core_plugins/kibana/server/lib/export/__tests__/collect_dashboards.js index 14e28bba70045..c9efe97eadb94 100644 --- a/src/core_plugins/kibana/server/lib/export/__tests__/collect_dashboards.js +++ b/src/core_plugins/kibana/server/lib/export/__tests__/collect_dashboards.js @@ -6,7 +6,7 @@ import { expect } from 'chai'; describe('collectDashboards(req, ids)', () => { let collectPanelsStub; - const savedObjectsClient = { bulkGet: sinon.mock() }; + const savedObjectsClient = { bulkGet: sinon.stub() }; const ids = ['dashboard-01', 'dashboard-02']; @@ -32,7 +32,7 @@ describe('collectDashboards(req, ids)', () => { afterEach(() => { collectPanelsStub.restore(); - savedObjectsClient.bulkGet.reset(); + savedObjectsClient.bulkGet.resetHistory(); }); it('should request all dashboards', async () => { diff --git a/src/core_plugins/kibana/server/lib/export/__tests__/collect_index_patterns.js b/src/core_plugins/kibana/server/lib/export/__tests__/collect_index_patterns.js index fe07e9d8d5519..918a5bf9b491e 100644 --- a/src/core_plugins/kibana/server/lib/export/__tests__/collect_index_patterns.js +++ b/src/core_plugins/kibana/server/lib/export/__tests__/collect_index_patterns.js @@ -32,7 +32,7 @@ describe('collectIndexPatterns(req, panels)', () => { } ]; - const savedObjectsClient = { bulkGet: sinon.mock() }; + const savedObjectsClient = { bulkGet: sinon.stub() }; beforeEach(() => { savedObjectsClient.bulkGet.returns(Promise.resolve({ @@ -43,7 +43,7 @@ describe('collectIndexPatterns(req, panels)', () => { }); afterEach(() => { - savedObjectsClient.bulkGet.reset(); + savedObjectsClient.bulkGet.resetHistory(); }); it('should request all index patterns', async () => { diff --git a/src/core_plugins/kibana/server/lib/export/__tests__/collect_panels.js b/src/core_plugins/kibana/server/lib/export/__tests__/collect_panels.js index f48ddb1229b08..0f9e8310aeb8f 100644 --- a/src/core_plugins/kibana/server/lib/export/__tests__/collect_panels.js +++ b/src/core_plugins/kibana/server/lib/export/__tests__/collect_panels.js @@ -9,7 +9,7 @@ describe('collectPanels(req, dashboard)', () => { let collectIndexPatternsStub; let dashboard; - const savedObjectsClient = { bulkGet: sinon.mock() }; + const savedObjectsClient = { bulkGet: sinon.stub() }; beforeEach(() => { dashboard = { @@ -36,7 +36,7 @@ describe('collectPanels(req, dashboard)', () => { afterEach(() => { collectSearchSourcesStub.restore(); collectIndexPatternsStub.restore(); - savedObjectsClient.bulkGet.reset(); + savedObjectsClient.bulkGet.resetHistory(); }); it('should request each panel in the panelJSON', async () => { diff --git a/src/core_plugins/kibana/server/lib/export/__tests__/collect_search_sources.js b/src/core_plugins/kibana/server/lib/export/__tests__/collect_search_sources.js index 22ecf8f3b5000..f50c6c04541a2 100644 --- a/src/core_plugins/kibana/server/lib/export/__tests__/collect_search_sources.js +++ b/src/core_plugins/kibana/server/lib/export/__tests__/collect_search_sources.js @@ -3,7 +3,7 @@ import * as deps from '../collect_index_patterns'; import { collectSearchSources } from '../collect_search_sources'; import { expect } from 'chai'; describe('collectSearchSources(req, panels)', () => { - const savedObjectsClient = { bulkGet: sinon.mock() }; + const savedObjectsClient = { bulkGet: sinon.stub() }; let panels; let collectIndexPatternsStub; @@ -26,7 +26,7 @@ describe('collectSearchSources(req, panels)', () => { afterEach(() => { collectIndexPatternsStub.restore(); - savedObjectsClient.bulkGet.reset(); + savedObjectsClient.bulkGet.resetHistory(); }); it('should request all search sources', async () => { diff --git a/src/core_plugins/metrics/public/services/__tests__/executor_provider.js b/src/core_plugins/metrics/public/services/__tests__/executor_provider.js index 36875a3f7fc0c..9081e885e57a2 100644 --- a/src/core_plugins/metrics/public/services/__tests__/executor_provider.js +++ b/src/core_plugins/metrics/public/services/__tests__/executor_provider.js @@ -17,8 +17,8 @@ describe('$executor service', () => { $timeout.cancel = (id) => clearTimeout(id); timefilter = new EventEmitter(); - onSpy = sinon.spy((...args) => timefilter.addListener(...args)); - offSpy = sinon.spy((...args) => timefilter.removeListener(...args)); + onSpy = sinon.stub().callsFake((...args) => timefilter.addListener(...args)); + offSpy = sinon.stub().callsFake((...args) => timefilter.removeListener(...args)); timefilter.on = onSpy; timefilter.off = offSpy; @@ -59,13 +59,17 @@ describe('$executor service', () => { it('should execute function if ingorePause is passed (interval set to 1000ms)', (done) => { timefilter.refreshInterval.value = 1000; - executor.register({ execute: () => done() }); + executor.register({ + execute: () => Promise.resolve().then(done) + }); executor.start({ ignorePaused: true }); }); it('should execute function if timefilter is not paused and interval set to 1000ms', (done) => { timefilter.refreshInterval.value = 1000; - executor.register({ execute: () => done() }); + executor.register({ + execute: () => Promise.resolve().then(done) + }); executor.start(); }); diff --git a/src/core_plugins/region_map/public/__tests__/region_map_visualization.js b/src/core_plugins/region_map/public/__tests__/region_map_visualization.js index 377ff8992a783..a3a558977047a 100644 --- a/src/core_plugins/region_map/public/__tests__/region_map_visualization.js +++ b/src/core_plugins/region_map/public/__tests__/region_map_visualization.js @@ -125,7 +125,7 @@ describe('RegionMapsVisualizationTests', function () { }; const serviceSettings = $injector.get('serviceSettings'); - sinon.stub(serviceSettings, '_getManifest', function (url) { + sinon.stub(serviceSettings, '_getManifest').callsFake((url) => { let contents = null; if (url.startsWith(tmsManifestUrl)) { contents = tmsManifest; diff --git a/src/core_plugins/tile_map/public/__tests__/coordinate_maps_visualization.js b/src/core_plugins/tile_map/public/__tests__/coordinate_maps_visualization.js index 0355483460491..2d1c96a5bfbb1 100644 --- a/src/core_plugins/tile_map/public/__tests__/coordinate_maps_visualization.js +++ b/src/core_plugins/tile_map/public/__tests__/coordinate_maps_visualization.js @@ -77,7 +77,7 @@ describe('CoordinateMapsVisualizationTest', function () { const serviceSettings = $injector.get('serviceSettings'); - sinon.stub(serviceSettings, '_getManifest', function (url) { + sinon.stub(serviceSettings, '_getManifest').callsFake((url) => { let contents = null; if (url.startsWith(tmsManifestUrl)) { contents = tmsManifest; diff --git a/src/dev/build/lib/__tests__/build.js b/src/dev/build/lib/__tests__/build.js index 2be1d2bafbafe..a83ee881b1683 100644 --- a/src/dev/build/lib/__tests__/build.js +++ b/src/dev/build/lib/__tests__/build.js @@ -92,7 +92,7 @@ describe('dev/build/lib/build', () => { }); describe('#getPlatformArchivePath()', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); const config = { resolveFromRepo: sandbox.stub(), @@ -110,7 +110,7 @@ describe('dev/build/lib/build', () => { }; beforeEach(() => { - sandbox.reset(); + sandbox.resetHistory(); }); it('uses config.resolveFromRepo(), config.getBuildVersion, and platform.getBuildName() to create path', () => { diff --git a/src/dev/build/lib/__tests__/exec.js b/src/dev/build/lib/__tests__/exec.js index c23a14b19c830..93efdabb44085 100644 --- a/src/dev/build/lib/__tests__/exec.js +++ b/src/dev/build/lib/__tests__/exec.js @@ -7,7 +7,7 @@ import { createToolingLog } from '../../../tooling_log'; import { exec } from '../exec'; describe('dev/build/lib/exec', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); afterEach(() => sandbox.reset()); const log = createToolingLog('verbose'); diff --git a/src/dev/build/lib/__tests__/runner.js b/src/dev/build/lib/__tests__/runner.js index 4eb7d1aad9908..e9aee8731b8e9 100644 --- a/src/dev/build/lib/__tests__/runner.js +++ b/src/dev/build/lib/__tests__/runner.js @@ -6,7 +6,7 @@ import { createRunner } from '../runner'; import { isErrorLogged, markErrorLogged } from '../errors'; describe('dev/build/lib/runner', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); const config = {}; diff --git a/src/dev/build/tasks/nodejs/__tests__/download.js b/src/dev/build/tasks/nodejs/__tests__/download.js index 28bbc2bc92bfa..6358d132453b1 100644 --- a/src/dev/build/tasks/nodejs/__tests__/download.js +++ b/src/dev/build/tasks/nodejs/__tests__/download.js @@ -19,7 +19,7 @@ after(async () => { }); describe('src/dev/build/tasks/nodejs/download', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); afterEach(() => sandbox.reset()); const log = createToolingLog('verbose'); @@ -177,7 +177,7 @@ describe('src/dev/build/tasks/nodejs/download', () => { describe('sha256 option not supplied', () => { before(() => { - sinon.spy(Wreck, 'request'); + sinon.stub(Wreck, 'request'); }); after(() => { Wreck.request.restore(); diff --git a/src/dev/build/tasks/nodejs/__tests__/download_node_builds_task.js b/src/dev/build/tasks/nodejs/__tests__/download_node_builds_task.js index 8aaf86eadc0b0..1370c7cda9f87 100644 --- a/src/dev/build/tasks/nodejs/__tests__/download_node_builds_task.js +++ b/src/dev/build/tasks/nodejs/__tests__/download_node_builds_task.js @@ -7,7 +7,7 @@ import * as DownloadNS from '../download'; import { DownloadNodeBuildsTask } from '../download_node_builds_task'; describe('src/dev/build/tasks/nodejs/download_node_builds_task', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); afterEach(() => { sandbox.restore(); }); @@ -24,7 +24,7 @@ describe('src/dev/build/tasks/nodejs/download_node_builds_task', () => { getNodeVersion: () => 'nodeVersion', }; - sandbox.stub(NodeDownloadInfoNS, 'getNodeDownloadInfo', function (config, platform) { + sandbox.stub(NodeDownloadInfoNS, 'getNodeDownloadInfo').callsFake((config, platform) => { return { url: `${platform.getName()}:url`, downloadPath: `${platform.getName()}:downloadPath`, @@ -37,7 +37,7 @@ describe('src/dev/build/tasks/nodejs/download_node_builds_task', () => { 'bar:downloadName': 'bar:sha256', }); - sandbox.stub(DownloadNS, 'download', function ({ url }) { + sandbox.stub(DownloadNS, 'download').callsFake(({ url }) => { if (url === failOnUrl) { throw new Error('Download failed for reasons'); } diff --git a/src/dev/build/tasks/nodejs/__tests__/extract_node_builds_task.js b/src/dev/build/tasks/nodejs/__tests__/extract_node_builds_task.js index 70795e54ff5b3..6e79e84acff3d 100644 --- a/src/dev/build/tasks/nodejs/__tests__/extract_node_builds_task.js +++ b/src/dev/build/tasks/nodejs/__tests__/extract_node_builds_task.js @@ -6,7 +6,7 @@ import * as FsNS from '../../../lib/fs'; import { ExtractNodeBuildsTask } from '../extract_node_builds_task'; describe('src/dev/build/tasks/node_extract_node_builds_task', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); afterEach(() => { sandbox.restore(); }); diff --git a/src/dev/build/tasks/nodejs/__tests__/verify_existing_node_builds_task.js b/src/dev/build/tasks/nodejs/__tests__/verify_existing_node_builds_task.js index 11d0301f8dd27..1553492fb3c66 100644 --- a/src/dev/build/tasks/nodejs/__tests__/verify_existing_node_builds_task.js +++ b/src/dev/build/tasks/nodejs/__tests__/verify_existing_node_builds_task.js @@ -7,7 +7,7 @@ import * as FsNS from '../../../lib/fs'; import { VerifyExistingNodeBuildsTask } from '../verify_existing_node_builds_task'; describe('src/dev/build/tasks/nodejs/verify_existing_node_builds_task', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); afterEach(() => { sandbox.restore(); }); @@ -24,7 +24,7 @@ describe('src/dev/build/tasks/nodejs/verify_existing_node_builds_task', () => { getNodeVersion: () => 'nodeVersion', }; - sandbox.stub(NodeDownloadInfoNS, 'getNodeDownloadInfo', function (config, platform) { + sandbox.stub(NodeDownloadInfoNS, 'getNodeDownloadInfo').callsFake((config, platform) => { return { url: `${platform.getName()}:url`, downloadPath: `${platform.getName()}:downloadPath`, @@ -37,7 +37,7 @@ describe('src/dev/build/tasks/nodejs/verify_existing_node_builds_task', () => { 'bar:downloadName': 'bar:sha256', }); - sandbox.stub(FsNS, 'getFileHash', function (path) { + sandbox.stub(FsNS, 'getFileHash').callsFake((path) => { switch (path) { case 'foo:downloadPath': return 'foo:sha256'; diff --git a/src/optimize/bundles_route/__tests__/bundles_route.js b/src/optimize/bundles_route/__tests__/bundles_route.js index a38f5a28a1789..d31f9c9d45aa3 100644 --- a/src/optimize/bundles_route/__tests__/bundles_route.js +++ b/src/optimize/bundles_route/__tests__/bundles_route.js @@ -19,7 +19,7 @@ function replaceAll(source, replace, replaceWith) { } describe('optimizer/bundle route', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); function createServer(options = {}) { const { @@ -262,7 +262,7 @@ describe('optimizer/bundle route', () => { }); sinon.assert.calledOnce(createHash); - createHash.reset(); + createHash.resetHistory(); expect(resp1.statusCode).to.be(200); const resp2 = await server.inject({ diff --git a/src/plugin_discovery/plugin_config/__tests__/extend_config_service.js b/src/plugin_discovery/plugin_config/__tests__/extend_config_service.js index a9f0cc966d650..241cfcec8e6b3 100644 --- a/src/plugin_discovery/plugin_config/__tests__/extend_config_service.js +++ b/src/plugin_discovery/plugin_config/__tests__/extend_config_service.js @@ -8,7 +8,7 @@ import * as SchemaNS from '../schema'; import * as SettingsNS from '../settings'; describe('plugin discovery/extend config service', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); afterEach(() => sandbox.restore()); const pluginSpec = new PluginPack({ diff --git a/src/plugin_discovery/plugin_spec/__tests__/plugin_spec.js b/src/plugin_discovery/plugin_spec/__tests__/plugin_spec.js index 2550e30c6501c..9d0bc0a86ec66 100644 --- a/src/plugin_discovery/plugin_spec/__tests__/plugin_spec.js +++ b/src/plugin_discovery/plugin_spec/__tests__/plugin_spec.js @@ -433,7 +433,7 @@ describe('plugin discovery/plugin spec', () => { get: sinon.stub() }; - afterEach(() => config.get.reset()); + afterEach(() => config.get.resetHistory()); describe('key = "foo"', () => { it('passes key as own array item', () => { diff --git a/src/server/config/complete.test.js b/src/server/config/complete.test.js index 437a05c06c4a1..e3ec2df336eaf 100644 --- a/src/server/config/complete.test.js +++ b/src/server/config/complete.test.js @@ -7,7 +7,7 @@ import { transformDeprecations } from './transform_deprecations'; /* eslint-enable import/no-duplicates */ describe('server/config completeMixin()', function () { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); afterEach(() => sandbox.restore()); const setup = (options = {}) => { @@ -183,7 +183,7 @@ describe('server/config completeMixin()', function () { }); it('should use transformed settings when considering what is used', function () { - sandbox.stub(transformDeprecationsNS, 'transformDeprecations', (settings) => { + sandbox.stub(transformDeprecationsNS, 'transformDeprecations').callsFake((settings) => { settings.bar = settings.foo; delete settings.foo; return settings; diff --git a/src/server/http/short_url_lookup.test.js b/src/server/http/short_url_lookup.test.js index 58f581748c628..51df1879c5229 100644 --- a/src/server/http/short_url_lookup.test.js +++ b/src/server/http/short_url_lookup.test.js @@ -7,7 +7,7 @@ describe('shortUrlLookupProvider', () => { const TYPE = 'url'; const URL = 'http://elastic.co'; const server = { log: sinon.stub() }; - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); let savedObjectsClient; let req; diff --git a/src/server/index_patterns/service/lib/es_api.test.js b/src/server/index_patterns/service/lib/es_api.test.js index dd6beb47951d6..a86579df57419 100644 --- a/src/server/index_patterns/service/lib/es_api.test.js +++ b/src/server/index_patterns/service/lib/es_api.test.js @@ -9,7 +9,7 @@ import { callIndexAliasApi, callFieldCapsApi } from './es_api'; describe('server/index_patterns/service/lib/es_api', () => { describe('#callIndexAliasApi()', () => { let sandbox; - beforeEach(() => sandbox = sinon.sandbox.create()); + beforeEach(() => sandbox = sinon.createSandbox()); afterEach(() => sandbox.restore()); it('calls indices.getAlias() via callCluster', async () => { @@ -50,7 +50,7 @@ describe('server/index_patterns/service/lib/es_api', () => { const esError = new Error('esError'); const convertedError = new Error('convertedError'); - sandbox.stub(convertEsErrorNS, 'convertEsError', () => { throw convertedError; }); + sandbox.stub(convertEsErrorNS, 'convertEsError').throws(convertedError); const callCluster = sinon.spy(async () => { throw esError; }); try { await callIndexAliasApi(callCluster, indices); @@ -66,7 +66,7 @@ describe('server/index_patterns/service/lib/es_api', () => { describe('#callFieldCapsApi()', () => { let sandbox; - beforeEach(() => sandbox = sinon.sandbox.create()); + beforeEach(() => sandbox = sinon.createSandbox()); afterEach(() => sandbox.restore()); it('calls fieldCaps() via callCluster', async () => { @@ -108,7 +108,7 @@ describe('server/index_patterns/service/lib/es_api', () => { const esError = new Error('esError'); const convertedError = new Error('convertedError'); - sandbox.stub(convertEsErrorNS, 'convertEsError', () => { throw convertedError; }); + sandbox.stub(convertEsErrorNS, 'convertEsError').throws(convertedError); const callCluster = sinon.spy(async () => { throw esError; }); try { await callFieldCapsApi(callCluster, indices); diff --git a/src/server/index_patterns/service/lib/field_capabilities/field_capabilities.test.js b/src/server/index_patterns/service/lib/field_capabilities/field_capabilities.test.js index 510b7037b052f..a108a4fc441c0 100644 --- a/src/server/index_patterns/service/lib/field_capabilities/field_capabilities.test.js +++ b/src/server/index_patterns/service/lib/field_capabilities/field_capabilities.test.js @@ -15,7 +15,7 @@ import * as mergeOverridesNS from './overrides'; describe('index_patterns/field_capabilities/field_capabilities', () => { let sandbox; - beforeEach(() => sandbox = sinon.sandbox.create()); + beforeEach(() => sandbox = sinon.createSandbox()); afterEach(() => sandbox.restore()); const footballs = [ @@ -35,9 +35,9 @@ describe('index_patterns/field_capabilities/field_capabilities', () => { mergeOverrides = identity } = options; - sandbox.stub(callFieldCapsApiNS, 'callFieldCapsApi', async () => esResponse); - sandbox.stub(readFieldCapsResponseNS, 'readFieldCapsResponse', () => fieldsFromFieldCaps); - sandbox.stub(mergeOverridesNS, 'mergeOverrides', mergeOverrides); + sandbox.stub(callFieldCapsApiNS, 'callFieldCapsApi').callsFake(async () => esResponse); + sandbox.stub(readFieldCapsResponseNS, 'readFieldCapsResponse').returns(fieldsFromFieldCaps); + sandbox.stub(mergeOverridesNS, 'mergeOverrides').callsFake(mergeOverrides); }; describe('calls `callFieldCapsApi()`', () => { diff --git a/src/server/index_patterns/service/lib/field_capabilities/field_caps_response.test.js b/src/server/index_patterns/service/lib/field_capabilities/field_caps_response.test.js index f3fc107646fbb..69067963d58b9 100644 --- a/src/server/index_patterns/service/lib/field_capabilities/field_caps_response.test.js +++ b/src/server/index_patterns/service/lib/field_capabilities/field_caps_response.test.js @@ -11,7 +11,7 @@ import esResponse from './__fixtures__/es_field_caps_response.json'; describe('index_patterns/field_capabilities/field_caps_response', () => { let sandbox; - beforeEach(() => sandbox = sinon.sandbox.create()); + beforeEach(() => sandbox = sinon.createSandbox()); afterEach(() => sandbox.restore()); describe('readFieldCapsResponse()', () => { diff --git a/src/server/index_patterns/service/lib/resolve_time_pattern.test.js b/src/server/index_patterns/service/lib/resolve_time_pattern.test.js index 66924699f3afb..40e4b4503c45b 100644 --- a/src/server/index_patterns/service/lib/resolve_time_pattern.test.js +++ b/src/server/index_patterns/service/lib/resolve_time_pattern.test.js @@ -13,7 +13,7 @@ const TIME_PATTERN = '[logs-]dddd-YYYY.w'; describe('server/index_patterns/service/lib/resolve_time_pattern', () => { let sandbox; - beforeEach(() => sandbox = sinon.sandbox.create()); + beforeEach(() => sandbox = sinon.createSandbox()); afterEach(() => sandbox.restore()); describe('resolveTimePattern()', () => { diff --git a/src/server/keystore/keystore.test.js b/src/server/keystore/keystore.test.js index e9a8a6c3c1e1e..ff9d1047b33d0 100644 --- a/src/server/keystore/keystore.test.js +++ b/src/server/keystore/keystore.test.js @@ -5,7 +5,7 @@ import { readFileSync } from 'fs'; import { Keystore } from './keystore'; describe('Keystore', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); const protoctedKeystoreData = '1:4BnWfydL8NwFIQJg+VQKe0jlIs7uXtty6+++yaWPbSB' + 'KIX3d9nPfQ20K1C6Xh26E/gMJAQ9jh7BxK0+W3lt/iDJBJn44wqX3pQ0189iGkNBL0ibDCc' diff --git a/src/server/saved_objects/client/lib/search_dsl/search_dsl.test.js b/src/server/saved_objects/client/lib/search_dsl/search_dsl.test.js index 35078f43ba502..a5f6765f4c3c1 100644 --- a/src/server/saved_objects/client/lib/search_dsl/search_dsl.test.js +++ b/src/server/saved_objects/client/lib/search_dsl/search_dsl.test.js @@ -4,7 +4,7 @@ import * as queryParamsNS from './query_params'; import * as sortParamsNS from './sorting_params'; describe('getSearchDsl', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); afterEach(() => sandbox.restore()); describe('validation', () => { diff --git a/src/server/saved_objects/client/saved_objects_client.test.js b/src/server/saved_objects/client/saved_objects_client.test.js index 6162b1ee8e521..d0bd9c0badfd1 100644 --- a/src/server/saved_objects/client/saved_objects_client.test.js +++ b/src/server/saved_objects/client/saved_objects_client.test.js @@ -6,7 +6,7 @@ import { getSearchDsl } from './lib'; import elasticsearch from 'elasticsearch'; describe('SavedObjectsClient', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); let callAdminCluster; let onBeforeWrite; @@ -207,8 +207,8 @@ describe('SavedObjectsClient', () => { sinon.assert.calledOnce(onBeforeWrite); - callAdminCluster.reset(); - onBeforeWrite.reset(); + callAdminCluster.resetHistory(); + onBeforeWrite.resetHistory(); await savedObjectsClient.bulkCreate([{ type: 'foo', id: 'bar', attributes: {} }], { overwrite: true }); sinon.assert.calledOnce(callAdminCluster); diff --git a/src/server/saved_objects/routes/bulk_get.test.js b/src/server/saved_objects/routes/bulk_get.test.js index 04742b207b77e..ef9be0709ea07 100644 --- a/src/server/saved_objects/routes/bulk_get.test.js +++ b/src/server/saved_objects/routes/bulk_get.test.js @@ -22,7 +22,7 @@ describe('POST /api/saved_objects/_bulk_get', () => { }); afterEach(() => { - savedObjectsClient.bulkGet.reset(); + savedObjectsClient.bulkGet.resetHistory(); }); it('formats successful response', async () => { diff --git a/src/server/saved_objects/routes/create.test.js b/src/server/saved_objects/routes/create.test.js index f87694d89b6a6..cbbbc525c8e22 100644 --- a/src/server/saved_objects/routes/create.test.js +++ b/src/server/saved_objects/routes/create.test.js @@ -22,7 +22,7 @@ describe('POST /api/saved_objects/{type}', () => { }); afterEach(() => { - savedObjectsClient.create.reset(); + savedObjectsClient.create.resetHistory(); }); it('formats successful response', async () => { diff --git a/src/server/saved_objects/routes/delete.test.js b/src/server/saved_objects/routes/delete.test.js index 252dd639e3306..33659e3c36aa7 100644 --- a/src/server/saved_objects/routes/delete.test.js +++ b/src/server/saved_objects/routes/delete.test.js @@ -22,7 +22,7 @@ describe('DELETE /api/saved_objects/{type}/{id}', () => { }); afterEach(() => { - savedObjectsClient.delete.reset(); + savedObjectsClient.delete.resetHistory(); }); it('formats successful response', async () => { diff --git a/src/server/saved_objects/routes/find.test.js b/src/server/saved_objects/routes/find.test.js index f10f3cbd1f5ed..0a0ad5b10af14 100644 --- a/src/server/saved_objects/routes/find.test.js +++ b/src/server/saved_objects/routes/find.test.js @@ -22,7 +22,7 @@ describe('GET /api/saved_objects/_find', () => { }); afterEach(() => { - savedObjectsClient.find.reset(); + savedObjectsClient.find.resetHistory(); }); it('formats successful response', async () => { diff --git a/src/server/saved_objects/routes/get.test.js b/src/server/saved_objects/routes/get.test.js index 07cd5e9c0e2a1..e9e42098023c6 100644 --- a/src/server/saved_objects/routes/get.test.js +++ b/src/server/saved_objects/routes/get.test.js @@ -22,7 +22,7 @@ describe('GET /api/saved_objects/{type}/{id}', () => { }); afterEach(() => { - savedObjectsClient.get.reset(); + savedObjectsClient.get.resetHistory(); }); it('formats successful response', async () => { diff --git a/src/server/saved_objects/routes/update.test.js b/src/server/saved_objects/routes/update.test.js index f949a6c363de5..fb547ea807484 100644 --- a/src/server/saved_objects/routes/update.test.js +++ b/src/server/saved_objects/routes/update.test.js @@ -22,7 +22,7 @@ describe('PUT /api/saved_objects/{type}/{id?}', () => { }); afterEach(() => { - savedObjectsClient.update.reset(); + savedObjectsClient.update.resetHistory(); }); it('formats successful response', async () => { diff --git a/src/server/status/metrics_collector/metrics_collector.test.js b/src/server/status/metrics_collector/metrics_collector.test.js index 06d003cd4e20f..9a2559df99fd7 100644 --- a/src/server/status/metrics_collector/metrics_collector.test.js +++ b/src/server/status/metrics_collector/metrics_collector.test.js @@ -37,8 +37,8 @@ describe('Metrics Collector', () => { let sandbox; let clock; beforeAll(() => { - sandbox = sinon.sandbox.create(); - clock = sinon.useFakeTimers(1524174654366); + sandbox = sinon.createSandbox(); + clock = sandbox.useFakeTimers(1524174654366); }); afterAll(() => { diff --git a/src/server/utils/prompt.test.js b/src/server/utils/prompt.test.js index 4a62b5052f5bd..231ad91048a1a 100644 --- a/src/server/utils/prompt.test.js +++ b/src/server/utils/prompt.test.js @@ -4,7 +4,7 @@ import { PassThrough } from 'stream'; import { confirm, question } from './prompt'; describe('prompt', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); let input; let output; diff --git a/src/ui/field_formats/__tests__/field_formats_mixin.js b/src/ui/field_formats/__tests__/field_formats_mixin.js index 5ac648fb61731..c40ce574a9270 100644 --- a/src/ui/field_formats/__tests__/field_formats_mixin.js +++ b/src/ui/field_formats/__tests__/field_formats_mixin.js @@ -6,7 +6,7 @@ import * as FieldFormatsServiceNS from '../field_formats_service'; import { createServer } from '../../../test_utils/kbn_server'; describe('server.registerFieldFormat(createFormat)', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); let server; beforeEach(async () => { @@ -34,7 +34,7 @@ describe('server.registerFieldFormat(createFormat)', () => { it('passes the returned class to the FieldFormatsService', async () => { const { FieldFormatsService: ActualFFS } = FieldFormatsServiceNS; - sinon.stub(FieldFormatsServiceNS, 'FieldFormatsService', function (...args) { + sandbox.stub(FieldFormatsServiceNS, 'FieldFormatsService').callsFake((...args) => { return new ActualFFS(...args); }); diff --git a/src/ui/public/agg_response/hierarchical/__tests__/build_hierarchical_data.js b/src/ui/public/agg_response/hierarchical/__tests__/build_hierarchical_data.js index 4ab97b1a052b4..4f59d16a0026b 100644 --- a/src/ui/public/agg_response/hierarchical/__tests__/build_hierarchical_data.js +++ b/src/ui/public/agg_response/hierarchical/__tests__/build_hierarchical_data.js @@ -14,7 +14,7 @@ let indexPattern; let buildHierarchicalData; describe('buildHierarchicalData', function () { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private, $injector) { diff --git a/src/ui/public/agg_types/__tests__/buckets/_geo_hash.js b/src/ui/public/agg_types/__tests__/buckets/_geo_hash.js index 42610a359ffdf..3c12389eb2e9d 100644 --- a/src/ui/public/agg_types/__tests__/buckets/_geo_hash.js +++ b/src/ui/public/agg_types/__tests__/buckets/_geo_hash.js @@ -41,8 +41,8 @@ describe('Geohash Agg', () => { }; before(function () { - sinon.stub(AggConfigModule, 'AggConfig', AggConfigMock); - sinon.stub(BucketAggTypeModule, 'BucketAggType', BucketAggTypeMock); + sinon.stub(AggConfigModule, 'AggConfig').callsFake(AggConfigMock); + sinon.stub(BucketAggTypeModule, 'BucketAggType').callsFake(BucketAggTypeMock); }); after(function () { diff --git a/src/ui/public/chrome/api/__tests__/xsrf.js b/src/ui/public/chrome/api/__tests__/xsrf.js index 97bfebaa88c6a..a99e7db317133 100644 --- a/src/ui/public/chrome/api/__tests__/xsrf.js +++ b/src/ui/public/chrome/api/__tests__/xsrf.js @@ -9,7 +9,7 @@ import { version } from '../../../../../../package.json'; const xsrfHeader = 'kbn-version'; describe('chrome xsrf apis', function () { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); afterEach(function () { sandbox.restore(); diff --git a/src/ui/public/courier/__tests__/saved_object.js b/src/ui/public/courier/__tests__/saved_object.js index ff703687dd5ad..8afd0649f8263 100644 --- a/src/ui/public/courier/__tests__/saved_object.js +++ b/src/ui/public/courier/__tests__/saved_object.js @@ -169,7 +169,7 @@ describe('Saved Object', function () { const mockDocResponse = getMockedDocResponse('myId'); stubESResponse(mockDocResponse); return createInitializedSavedObject({ type: 'dashboard', id: 'myId' }).then(savedObject => { - sinon.stub(savedObjectsClientStub, 'create', function () { + sinon.stub(savedObjectsClientStub, 'create').callsFake(() => { return BluebirdPromise.resolve({ type: 'dashboard', id: 'newUniqueId' }); }); @@ -185,7 +185,7 @@ describe('Saved Object', function () { const mockDocResponse = getMockedDocResponse(originalId); stubESResponse(mockDocResponse); return createInitializedSavedObject({ type: 'dashboard', id: originalId }).then(savedObject => { - sinon.stub(savedObjectsClientStub, 'create', function () { + sinon.stub(savedObjectsClientStub, 'create').callsFake(() => { return BluebirdPromise.reject('simulated error'); }); savedObject.copyOnSave = true; @@ -203,7 +203,7 @@ describe('Saved Object', function () { stubESResponse(mockDocResponse); return createInitializedSavedObject({ type: 'dashboard', id: id }).then(savedObject => { - sinon.stub(savedObjectsClientStub, 'create', function () { + sinon.stub(savedObjectsClientStub, 'create').callsFake(() => { expect(savedObject.id).to.be(id); return BluebirdPromise.resolve(id); }); @@ -218,7 +218,7 @@ describe('Saved Object', function () { it('returns id from server on success', function () { return createInitializedSavedObject({ type: 'dashboard' }).then(savedObject => { const mockDocResponse = getMockedDocResponse('myId'); - sinon.stub(savedObjectsClientStub, 'create', function () { + sinon.stub(savedObjectsClientStub, 'create').callsFake(() => { return BluebirdPromise.resolve({ type: 'dashboard', id: 'myId', _version: 2 }); }); @@ -235,7 +235,7 @@ describe('Saved Object', function () { stubESResponse(getMockedDocResponse(id)); return createInitializedSavedObject({ type: 'dashboard', id: id }).then(savedObject => { - sinon.stub(savedObjectsClientStub, 'create', () => { + sinon.stub(savedObjectsClientStub, 'create').callsFake(() => { expect(savedObject.isSaving).to.be(true); return BluebirdPromise.resolve({ type: 'dashboard', id, version: 2 @@ -251,7 +251,7 @@ describe('Saved Object', function () { it('on failure', function () { stubESResponse(getMockedDocResponse('id')); return createInitializedSavedObject({ type: 'dashboard' }).then(savedObject => { - sinon.stub(savedObjectsClientStub, 'create', () => { + sinon.stub(savedObjectsClientStub, 'create').callsFake(() => { expect(savedObject.isSaving).to.be(true); return BluebirdPromise.reject(); }); diff --git a/src/ui/public/courier/fetch/request/__tests__/segmented.js b/src/ui/public/courier/fetch/request/__tests__/segmented.js index cec4f55b8b585..9b0cf02a2ff6e 100644 --- a/src/ui/public/courier/fetch/request/__tests__/segmented.js +++ b/src/ui/public/courier/fetch/request/__tests__/segmented.js @@ -18,7 +18,7 @@ describe('SegmentedRequestProvider', () => { SegmentedReq = Private(SegmentedRequestProvider); const SearchRequest = Private(SearchRequestProvider); - abstractReqStart = sinon.stub(SearchRequest.prototype, 'start', () => { + abstractReqStart = sinon.stub(SearchRequest.prototype, 'start').callsFake(() => { const promise = Promise.resolve(); sinon.spy(promise, 'then'); return promise; diff --git a/src/ui/public/debounce/__tests__/debounce.js b/src/ui/public/debounce/__tests__/debounce.js index 939ba6b2eda06..2eba86426d751 100644 --- a/src/ui/public/debounce/__tests__/debounce.js +++ b/src/ui/public/debounce/__tests__/debounce.js @@ -35,7 +35,7 @@ describe('debounce service', function () { }); describe('delayed execution', function () { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); beforeEach(() => sandbox.useFakeTimers()); afterEach(() => sandbox.restore()); @@ -49,7 +49,7 @@ describe('debounce service', function () { $timeout.flush(); sinon.assert.calledOnce(spy); - spy.reset(); + spy.resetHistory(); bouncerFromProvider(); sinon.assert.notCalled(spy); @@ -66,7 +66,7 @@ describe('debounce service', function () { $timeout.flush(); sinon.assert.calledTwice(spy); - spy.reset(); + spy.resetHistory(); bouncerFromProvider(); sinon.assert.calledOnce(spy); @@ -83,7 +83,7 @@ describe('debounce service', function () { $timeout.flush(); sinon.assert.calledOnce(spy); - spy.reset(); + spy.resetHistory(); bouncerFromProvider(); sinon.assert.calledOnce(spy); @@ -105,8 +105,8 @@ describe('debounce service', function () { sinon.assert.calledOnce(spy); sinon.assert.calledOnce(cancelSpy); - spy.reset(); - cancelSpy.reset(); + spy.resetHistory(); + cancelSpy.resetHistory(); bouncerFromProvider(); sandbox.clock.tick(1); @@ -131,7 +131,7 @@ describe('debounce service', function () { // throws if pending timeouts $timeout.verifyNoPendingTasks(); - cancelSpy.reset(); + cancelSpy.resetHistory(); bouncerFromProvider(); bouncerFromProvider.cancel(); diff --git a/src/ui/public/directives/__tests__/fixed_scroll.js b/src/ui/public/directives/__tests__/fixed_scroll.js index 068e92d1a4aec..98f5b162c94f8 100644 --- a/src/ui/public/directives/__tests__/fixed_scroll.js +++ b/src/ui/public/directives/__tests__/fixed_scroll.js @@ -6,7 +6,7 @@ import $ from 'jquery'; import sinon from 'sinon'; describe('FixedScroll directive', function () { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); let compile; let flushPendingTasks; @@ -156,7 +156,7 @@ describe('FixedScroll directive', function () { $from.scroll(); expect(spy.callCount).to.be(2); - spy.reset(); + spy.resetHistory(); $to.scroll(); expect(spy.callCount).to.be(0); }); diff --git a/src/ui/public/directives/__tests__/timepicker.js b/src/ui/public/directives/__tests__/timepicker.js index 7b4f1bd57ea69..cfbeca454586f 100644 --- a/src/ui/public/directives/__tests__/timepicker.js +++ b/src/ui/public/directives/__tests__/timepicker.js @@ -70,7 +70,7 @@ const init = function () { describe('timepicker directive', function () { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); beforeEach(function () { // Stub out the clock so 'now' doesn't move diff --git a/src/ui/public/filter_bar/__tests__/filter_bar_click_handler.js b/src/ui/public/filter_bar/__tests__/filter_bar_click_handler.js index 76582fa3caae2..c7be61300c4a5 100644 --- a/src/ui/public/filter_bar/__tests__/filter_bar_click_handler.js +++ b/src/ui/public/filter_bar/__tests__/filter_bar_click_handler.js @@ -39,7 +39,7 @@ describe('filterBarClickHandler', function () { }; })); - afterEach(function () { + beforeEach(function () { toastNotifications.list.splice(0); }); diff --git a/src/ui/public/filter_manager/__tests__/filter_manager.js b/src/ui/public/filter_manager/__tests__/filter_manager.js index 7eceb78cb3e13..0e7df1a21afa2 100644 --- a/src/ui/public/filter_manager/__tests__/filter_manager.js +++ b/src/ui/public/filter_manager/__tests__/filter_manager.js @@ -41,14 +41,12 @@ describe('Filter Manager', function () { // mock required queryFilter methods, used in the manager queryFilter = Private(FilterBarQueryFilterProvider); - sinon.stub(queryFilter, 'getAppFilters', function () { - return appState.filters; - }); - sinon.stub(queryFilter, 'addFilters', function (filters) { + sinon.stub(queryFilter, 'getAppFilters').callsFake(() => appState.filters); + sinon.stub(queryFilter, 'addFilters').callsFake((filters) => { if (!Array.isArray(filters)) filters = [filters]; appState.filters = appState.filters.concat(filters); }); - sinon.stub(queryFilter, 'invertFilter', function (filter) { + sinon.stub(queryFilter, 'invertFilter').callsFake((filter) => { filter.meta.negate = !filter.meta.negate; }); })); diff --git a/src/ui/public/filters/__tests__/moment.js b/src/ui/public/filters/__tests__/moment.js index a4bd4f68e80f0..151cc2987ba8e 100644 --- a/src/ui/public/filters/__tests__/moment.js +++ b/src/ui/public/filters/__tests__/moment.js @@ -20,7 +20,7 @@ const init = function () { describe('moment formatting filter', function () { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); beforeEach(function () { sandbox.useFakeTimers(moment(anchor).valueOf()); diff --git a/src/ui/public/index_patterns/__tests__/index_patterns.js b/src/ui/public/index_patterns/__tests__/index_patterns.js index df0e277634804..b7d2d3c0ce131 100644 --- a/src/ui/public/index_patterns/__tests__/index_patterns.js +++ b/src/ui/public/index_patterns/__tests__/index_patterns.js @@ -17,9 +17,7 @@ describe('IndexPatterns service', function () { IndexPatternProvider, function (...args) { const indexPattern = new IndexPattern(...args); - sinon.stub(indexPattern, 'init', function () { - return new Promise(); - }); + sinon.stub(indexPattern, 'init').callsFake(() => new Promise()); return indexPattern; } ); diff --git a/src/ui/public/modals/__tests__/confirm_modal.js b/src/ui/public/modals/__tests__/confirm_modal.js index 28683a4407acb..1f7e8936e699a 100644 --- a/src/ui/public/modals/__tests__/confirm_modal.js +++ b/src/ui/public/modals/__tests__/confirm_modal.js @@ -93,8 +93,8 @@ describe('ui/modals/confirm_modal', function () { }; beforeEach(() => { - confirmCallback.reset(); - cancelCallback.reset(); + confirmCallback.resetHistory(); + cancelCallback.resetHistory(); }); it('onCancel', function () { diff --git a/src/ui/public/saved_objects/__tests__/find_object_by_title.js b/src/ui/public/saved_objects/__tests__/find_object_by_title.js index 36024c20e3249..0b3aae17681bf 100644 --- a/src/ui/public/saved_objects/__tests__/find_object_by_title.js +++ b/src/ui/public/saved_objects/__tests__/find_object_by_title.js @@ -4,7 +4,7 @@ import { findObjectByTitle } from '../find_object_by_title'; import { SavedObject } from '../saved_object'; describe('findObjectByTitle', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); const savedObjectsClient = {}; beforeEach(() => { diff --git a/src/ui/public/saved_objects/__tests__/saved_objects_client.js b/src/ui/public/saved_objects/__tests__/saved_objects_client.js index f4f91e2f8a9df..ce456dee147ae 100644 --- a/src/ui/public/saved_objects/__tests__/saved_objects_client.js +++ b/src/ui/public/saved_objects/__tests__/saved_objects_client.js @@ -5,7 +5,7 @@ import { SavedObject } from '../saved_object'; describe('SavedObjectsClient', () => { const basePath = Math.random().toString(36).substring(7); - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); const doc = { id: 'AVwSwFxtcMV38qjDZoQg', type: 'config', diff --git a/src/ui/public/share/__tests__/url_shortener.js b/src/ui/public/share/__tests__/url_shortener.js index 11b96623ca8ca..f944e7548d2b7 100644 --- a/src/ui/public/share/__tests__/url_shortener.js +++ b/src/ui/public/share/__tests__/url_shortener.js @@ -46,7 +46,7 @@ describe('Url shortener', () => { let getBasePath; beforeEach(ngMock.inject((Private) => { - getBasePath = sinon.stub(chrome, 'getBasePath', () => basePath); + getBasePath = sinon.stub(chrome, 'getBasePath').returns(basePath); urlShortener = Private(UrlShortenerProvider); })); diff --git a/src/ui/public/state_management/__tests__/state.js b/src/ui/public/state_management/__tests__/state.js index 798ec9c30bcbc..2e5d223bbf626 100644 --- a/src/ui/public/state_management/__tests__/state.js +++ b/src/ui/public/state_management/__tests__/state.js @@ -210,7 +210,7 @@ describe('State Management', () => { it('does not replace the state value on read', () => { const { state } = setup(); - sinon.stub($location, 'search', (newSearch) => { + sinon.stub($location, 'search').callsFake((newSearch) => { if (newSearch) { return $location; } else { diff --git a/src/ui/public/test_harness/test_harness.js b/src/ui/public/test_harness/test_harness.js index 249e5fdaf5c8f..0ce8cacff43c6 100644 --- a/src/ui/public/test_harness/test_harness.js +++ b/src/ui/public/test_harness/test_harness.js @@ -30,7 +30,6 @@ before(() => { sinon.useFakeXMLHttpRequest(); }); - let stubUiSettings = new UiSettingsClient({ defaults: metadata.uiSettings.defaults, initialSettings: {}, @@ -41,7 +40,7 @@ let stubUiSettings = new UiSettingsClient({ } } }); -sinon.stub(chrome, 'getUiSettingsClient', () => stubUiSettings); +sinon.stub(chrome, 'getUiSettingsClient').callsFake(() => stubUiSettings); beforeEach(function () { // ensure that notifications are not left in the notifiers diff --git a/src/ui/public/timepicker/__tests__/toggle.js b/src/ui/public/timepicker/__tests__/toggle.js index a90314fc4bffe..c9db1aedd4d97 100644 --- a/src/ui/public/timepicker/__tests__/toggle.js +++ b/src/ui/public/timepicker/__tests__/toggle.js @@ -5,7 +5,7 @@ import $ from 'jquery'; import sinon from 'sinon'; describe('kbnGlobalTimepicker', function () { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); let compile; let scope; @@ -16,7 +16,7 @@ describe('kbnGlobalTimepicker', function () { scope = $rootScope.$new(); compile = (timefilterStubProperties = {}) => { Object.keys(timefilterStubProperties).forEach((key) => { - sandbox.stub(timefilter, key, timefilterStubProperties[key]); + sandbox.stub(timefilter, key).value(timefilterStubProperties[key]); }); const $el = $(''); diff --git a/src/ui/public/utils/__tests__/scanner.js b/src/ui/public/utils/__tests__/scanner.js index 21f42da23e06a..943d7c0d8df33 100644 --- a/src/ui/public/utils/__tests__/scanner.js +++ b/src/ui/public/utils/__tests__/scanner.js @@ -52,7 +52,7 @@ describe('Scanner', function () { search = sinon.stub().returns(Promise.resolve({ data: mockSearch })); scroll = sinon.stub().returns(Promise.resolve({ data: mockScroll })); - httpPost = sinon.stub(scanner.$http, 'post', (path, ...args) => { + httpPost = sinon.stub(scanner.$http, 'post').callsFake((path, ...args) => { if (path.includes('legacy_scroll_start')) { return search(...args); } diff --git a/src/ui/public/vis/__tests__/_agg_configs.js b/src/ui/public/vis/__tests__/_agg_configs.js index 1482d0072c364..129dd25097f0e 100644 --- a/src/ui/public/vis/__tests__/_agg_configs.js +++ b/src/ui/public/vis/__tests__/_agg_configs.js @@ -239,9 +239,7 @@ describe('AggConfigs', function () { const aggInfos = vis.aggs.map(function (aggConfig) { const football = {}; - sinon.stub(aggConfig, 'toDsl', function () { - return football; - }); + sinon.stub(aggConfig, 'toDsl').returns(football); return { id: aggConfig.id, diff --git a/src/ui/public/vis/__tests__/map/service_settings.js b/src/ui/public/vis/__tests__/map/service_settings.js index bb487ca350639..71de96227a75c 100644 --- a/src/ui/public/vis/__tests__/map/service_settings.js +++ b/src/ui/public/vis/__tests__/map/service_settings.js @@ -89,7 +89,7 @@ describe('service_settings (FKA tilemaptest)', function () { manifestServiceUrlOriginal = mapConfig.manifestServiceUrl; tilemapsConfigDeprecatedOriginal = tilemapsConfig.deprecated; - sinon.stub(serviceSettings, '_getManifest', function (url) { + sinon.stub(serviceSettings, '_getManifest').callsFake((url) => { let contents = null; if (url.startsWith(tmsManifestUrl)) { contents = tmsManifest; diff --git a/src/ui/public/vis/components/tooltip/__tests__/positioning.js b/src/ui/public/vis/components/tooltip/__tests__/positioning.js index 4ef613a008105..5fe1f758fec21 100644 --- a/src/ui/public/vis/components/tooltip/__tests__/positioning.js +++ b/src/ui/public/vis/components/tooltip/__tests__/positioning.js @@ -5,7 +5,7 @@ import sinon from 'sinon'; import { positionTooltip } from '../position_tooltip'; describe('Tooltip Positioning', function () { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); const positions = ['north', 'south', 'east', 'west']; const bounds = ['top', 'left', 'bottom', 'right', 'area']; let $window; diff --git a/src/ui/public/visualize/loader/__tests__/loader.js b/src/ui/public/visualize/loader/__tests__/loader.js index 1e74e2fb2bce7..67125558e17b4 100644 --- a/src/ui/public/visualize/loader/__tests__/loader.js +++ b/src/ui/public/visualize/loader/__tests__/loader.js @@ -78,7 +78,7 @@ describe('visualize loader', () => { // Setup savedObject mockedSavedObject = createSavedObject(); // Mock savedVisualizations.get to return 'mockedSavedObject' when id is 'exists' - sinon.stub(savedVisualizations, 'get', (id) => + sinon.stub(savedVisualizations, 'get').callsFake((id) => id === 'exists' ? Promise.resolve(mockedSavedObject) : Promise.reject() ); })); @@ -251,7 +251,7 @@ describe('visualize loader', () => { expect(spy.notCalled).to.be(true); container.find('visualize').trigger('renderComplete'); expect(spy.calledOnce).to.be(true); - spy.reset(); + spy.resetHistory(); handler.removeRenderCompleteListener(spy); container.find('visualize').trigger('renderComplete'); expect(spy.notCalled).to.be(true); diff --git a/src/ui/ui_settings/__tests__/ui_settings_mixin_integration.js b/src/ui/ui_settings/__tests__/ui_settings_mixin_integration.js index 9ff97dbd135a9..7eef942f88e71 100644 --- a/src/ui/ui_settings/__tests__/ui_settings_mixin_integration.js +++ b/src/ui/ui_settings/__tests__/ui_settings_mixin_integration.js @@ -13,7 +13,7 @@ import { getUiSettingsServiceForRequest } from '../ui_settings_service_for_reque import { uiSettingsMixin } from '../ui_settings_mixin'; describe('uiSettingsMixin()', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); async function setup(options = {}) { const { diff --git a/src/ui/ui_settings/__tests__/ui_settings_service.js b/src/ui/ui_settings/__tests__/ui_settings_service.js index 2eb4bf1f25997..485b8de9bfc4e 100644 --- a/src/ui/ui_settings/__tests__/ui_settings_service.js +++ b/src/ui/ui_settings/__tests__/ui_settings_service.js @@ -17,7 +17,7 @@ const BUILD_NUM = 1234; const chance = new Chance(); describe('ui settings', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); function setup(options = {}) { const { diff --git a/src/ui/ui_settings/create_or_upgrade_saved_config/__tests__/create_or_upgrade_saved_config.js b/src/ui/ui_settings/create_or_upgrade_saved_config/__tests__/create_or_upgrade_saved_config.js index 6fd8d5fc169c6..4094b6aa92bea 100644 --- a/src/ui/ui_settings/create_or_upgrade_saved_config/__tests__/create_or_upgrade_saved_config.js +++ b/src/ui/ui_settings/create_or_upgrade_saved_config/__tests__/create_or_upgrade_saved_config.js @@ -7,7 +7,7 @@ import { createOrUpgradeSavedConfig } from '../create_or_upgrade_saved_config'; const chance = new Chance(); describe('uiSettings/createOrUpgradeSavedConfig', function () { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); afterEach(() => sandbox.restore()); const version = '4.0.1'; diff --git a/src/utils/streams/__tests__/intersperse_stream.js b/src/utils/streams/__tests__/intersperse_stream.js index f0638be121d8a..93289f9f2d955 100644 --- a/src/utils/streams/__tests__/intersperse_stream.js +++ b/src/utils/streams/__tests__/intersperse_stream.js @@ -27,7 +27,7 @@ describe('intersperseStream', () => { str.write('a'); sinon.assert.calledOnce(stub); expect(stub.firstCall.args).to.eql(['a']); - stub.reset(); + stub.resetHistory(); str.write('b'); sinon.assert.calledTwice(stub); diff --git a/x-pack/package.json b/x-pack/package.json index bf411a3d2b82e..c79053efca917 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -64,8 +64,7 @@ "rsync": "0.4.0", "run-sequence": "^2.2.1", "simple-git": "1.37.0", - "sinon": "1.17.3", - "sinon-as-promised": "4.0.3", + "sinon": "^5.0.7", "supertest": "3.0.0", "supertest-as-promised": "4.0.2", "tmp": "0.0.31", diff --git a/x-pack/plugins/reporting/export_types/csv/server/__tests__/execute_job.js b/x-pack/plugins/reporting/export_types/csv/server/__tests__/execute_job.js index aecb312b44a30..d42d6fffef6dd 100644 --- a/x-pack/plugins/reporting/export_types/csv/server/__tests__/execute_job.js +++ b/x-pack/plugins/reporting/export_types/csv/server/__tests__/execute_job.js @@ -7,7 +7,6 @@ import expect from 'expect.js'; import Puid from 'puid'; import sinon from 'sinon'; -import 'sinon-as-promised'; import nodeCrypto from '@elastic/node-crypto'; import { CancellationToken } from '../../../../server/lib/esqueue/helpers/cancellation_token'; @@ -370,7 +369,7 @@ describe('CSV Execute Job', function () { // that delays the Promise resolution so we have a chance to call cancellationToken.cancel(). // Otherwise, we get into an endless loop, and don't have a chance to call cancel callWithRequestStub.restore(); - callWithRequestStub = sinon.stub(clusterStub, 'callWithRequest', async function () { + callWithRequestStub = sinon.stub(clusterStub, 'callWithRequest').callsFake(async function () { await delay(1); return { hits: { diff --git a/x-pack/plugins/reporting/server/lib/__tests__/authorized_user_pre_routing.js b/x-pack/plugins/reporting/server/lib/__tests__/authorized_user_pre_routing.js index 26b414cfac31c..665de2068a491 100644 --- a/x-pack/plugins/reporting/server/lib/__tests__/authorized_user_pre_routing.js +++ b/x-pack/plugins/reporting/server/lib/__tests__/authorized_user_pre_routing.js @@ -57,7 +57,7 @@ describe('authorized_user_pre_routing', function () { } }; - callWithRequestStub.reset(); + callWithRequestStub.resetHistory(); callWithRequestStub.returns(Promise.resolve(user)); return mockServer; }; diff --git a/x-pack/plugins/reporting/server/lib/__tests__/validate_config.js b/x-pack/plugins/reporting/server/lib/__tests__/validate_config.js index deca78f7ac57e..ef460ff19574c 100644 --- a/x-pack/plugins/reporting/server/lib/__tests__/validate_config.js +++ b/x-pack/plugins/reporting/server/lib/__tests__/validate_config.js @@ -12,7 +12,7 @@ describe('Reporting: Validate config', function () { const log = sinon.spy(); beforeEach(() => { - log.reset(); + log.resetHistory(); }); [undefined, null].forEach(value => { diff --git a/x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/create_index.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/create_index.js index a89189cc95ba3..698f7e1605aa7 100644 --- a/x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/create_index.js +++ b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/create_index.js @@ -102,7 +102,7 @@ describe('Create Index', function () { beforeEach(function () { client = new ClientMock(); - sinon.stub(client.indices, 'exists', () => Promise.resolve(true)); + sinon.stub(client.indices, 'exists').callsFake(() => Promise.resolve(true)); createSpy = sinon.spy(client.indices, 'create'); }); diff --git a/x-pack/plugins/reporting/server/lib/esqueue/__tests__/job.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/job.js index d4af1aa85744e..d928f82f3abb3 100644 --- a/x-pack/plugins/reporting/server/lib/esqueue/__tests__/job.js +++ b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/job.js @@ -38,7 +38,7 @@ describe('Job Class', function () { let options; beforeEach(function () { - createIndexMock.reset(); + createIndexMock.resetHistory(); createIndexMock.returns(Promise.resolve('mock')); index = 'test'; @@ -163,7 +163,7 @@ describe('Job Class', function () { const errMsg = 'test document index failure'; client.index.restore(); - sinon.stub(client, 'index', () => Promise.reject(new Error(errMsg))); + sinon.stub(client, 'index').callsFake(() => Promise.reject(new Error(errMsg))); const job = new Job(mockQueue, index, type, payload); job.once(constants.EVENT_JOB_CREATE_ERROR, (err) => { diff --git a/x-pack/plugins/reporting/server/lib/esqueue/__tests__/worker.js b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/worker.js index cc6f0cff7a594..d480a1ad15429 100644 --- a/x-pack/plugins/reporting/server/lib/esqueue/__tests__/worker.js +++ b/x-pack/plugins/reporting/server/lib/esqueue/__tests__/worker.js @@ -211,7 +211,7 @@ describe('Worker class', function () { it('should start polling for jobs after interval', async function () { worker = new Worker(mockQueue, 'test', noop, defaultWorkerOptions); - const processPendingJobsStub = sinon.stub(worker, '_processPendingJobs', () => Promise.resolve()); + const processPendingJobsStub = sinon.stub(worker, '_processPendingJobs').callsFake(() => Promise.resolve()); sinon.assert.notCalled(processPendingJobsStub); await allowPoll(defaultWorkerOptions.interval); sinon.assert.calledOnce(processPendingJobsStub); @@ -220,7 +220,7 @@ describe('Worker class', function () { it('should use interval option to control polling', async function () { const interval = 567; worker = new Worker(mockQueue, 'test', noop, { ...defaultWorkerOptions, interval }); - const processPendingJobsStub = sinon.stub(worker, '_processPendingJobs', () => Promise.resolve()); + const processPendingJobsStub = sinon.stub(worker, '_processPendingJobs').callsFake(() => Promise.resolve()); sinon.assert.notCalled(processPendingJobsStub); await allowPoll(interval); @@ -230,7 +230,7 @@ describe('Worker class', function () { it('should not poll once destroyed', async function () { worker = new Worker(mockQueue, 'test', noop, defaultWorkerOptions); - const processPendingJobsStub = sinon.stub(worker, '_processPendingJobs', () => Promise.resolve()); + const processPendingJobsStub = sinon.stub(worker, '_processPendingJobs').callsFake(() => Promise.resolve()); // move the clock a couple times, test for searches each time sinon.assert.notCalled(processPendingJobsStub); @@ -266,7 +266,7 @@ describe('Worker class', function () { it('should not use error multiplier when processPendingJobs resolved the Promise', async function () { worker = new Worker(mockQueue, 'test', noop, defaultWorkerOptions); - const processPendingJobsStub = sinon.stub(worker, "_processPendingJobs", () => Promise.resolve()); + const processPendingJobsStub = sinon.stub(worker, "_processPendingJobs").callsFake(() => Promise.resolve()); await allowPoll(defaultWorkerOptions.interval); expect(processPendingJobsStub.callCount).to.be(1); @@ -289,7 +289,7 @@ describe('Worker class', function () { }); it('should pass search errors', function (done) { - searchStub = sinon.stub(mockQueue.client, 'search', () => Promise.reject()); + searchStub = sinon.stub(mockQueue.client, 'search').callsFake(() => Promise.reject()); worker = new Worker(mockQueue, 'test', noop, defaultWorkerOptions); worker._getPendingJobs() .then(() => done(new Error('should not resolve'))) @@ -301,7 +301,7 @@ describe('Worker class', function () { describe('missing index', function () { it('should swallow error', function (done) { - searchStub = sinon.stub(mockQueue.client, 'search', () => Promise.reject({ + searchStub = sinon.stub(mockQueue.client, 'search').callsFake(() => Promise.reject({ status: 404 })); worker = new Worker(mockQueue, 'test', noop, defaultWorkerOptions); @@ -311,7 +311,7 @@ describe('Worker class', function () { }); it('should return an empty array', function (done) { - searchStub = sinon.stub(mockQueue.client, 'search', () => Promise.reject({ + searchStub = sinon.stub(mockQueue.client, 'search').callsFake(() => Promise.reject({ status: 404 })); worker = new Worker(mockQueue, 'test', noop, defaultWorkerOptions); @@ -333,7 +333,7 @@ describe('Worker class', function () { describe('query parameters', function () { beforeEach(() => { - searchStub = sinon.stub(mockQueue.client, 'search', () => Promise.resolve({ hits: { hits: [] } })); + searchStub = sinon.stub(mockQueue.client, 'search').callsFake(() => Promise.resolve({ hits: { hits: [] } })); }); it('should query with version', function () { @@ -358,7 +358,7 @@ describe('Worker class', function () { const jobtype = 'test_jobtype'; beforeEach(() => { - searchStub = sinon.stub(mockQueue.client, 'search', () => Promise.resolve({ hits: { hits: [] } })); + searchStub = sinon.stub(mockQueue.client, 'search').callsFake(() => Promise.resolve({ hits: { hits: [] } })); anchorMoment = moment(anchor); clock = sinon.useFakeTimers(anchorMoment.valueOf()); }); @@ -907,7 +907,7 @@ describe('Worker class', function () { }; beforeEach(function () { - sinon.stub(mockQueue.client, 'search', () => Promise.resolve({ hits: { hits: [] } })); + sinon.stub(mockQueue.client, 'search').callsFake(() => Promise.resolve({ hits: { hits: [] } })); }); describe('workerFn rejects promise', function () { diff --git a/x-pack/plugins/security/server/lib/__tests__/auth_redirect.js b/x-pack/plugins/security/server/lib/__tests__/auth_redirect.js index 1886fa9f6e0cc..61955452c03d7 100644 --- a/x-pack/plugins/security/server/lib/__tests__/auth_redirect.js +++ b/x-pack/plugins/security/server/lib/__tests__/auth_redirect.js @@ -111,7 +111,14 @@ describe('lib/auth_redirect', function () { await authenticate(request, reply); - sinon.assert.calledWithExactly(reply, Boom.unauthorized()); + sinon.assert.calledWithExactly( + reply, + sinon.match({ + isBoom: true, + message: 'Unauthorized', + output: { statusCode: 401 }, + }) + ); sinon.assert.notCalled(reply.redirect); sinon.assert.notCalled(reply.continue); }); diff --git a/x-pack/plugins/security/server/lib/__tests__/validate_config.js b/x-pack/plugins/security/server/lib/__tests__/validate_config.js index 2474179a311db..84f098ae442dd 100644 --- a/x-pack/plugins/security/server/lib/__tests__/validate_config.js +++ b/x-pack/plugins/security/server/lib/__tests__/validate_config.js @@ -10,7 +10,7 @@ import { validateConfig } from '../validate_config'; describe('Validate config', function () { let config; - const log = sinon.spy(); + const log = sinon.stub(); const validKey = 'd624dce49dafa1401be7f3e1182b756a'; beforeEach(() => { @@ -18,7 +18,7 @@ describe('Validate config', function () { get: sinon.stub(), set: sinon.stub() }; - log.reset(); + log.resetHistory(); }); it('should log a warning and set xpack.security.encryptionKey if not set', function () { diff --git a/x-pack/plugins/security/server/lib/authentication/__tests__/authenticator.js b/x-pack/plugins/security/server/lib/authentication/__tests__/authenticator.js index dbf3ad77875d6..ab32f30c2e315 100644 --- a/x-pack/plugins/security/server/lib/authentication/__tests__/authenticator.js +++ b/x-pack/plugins/security/server/lib/authentication/__tests__/authenticator.js @@ -16,7 +16,7 @@ import { initAuthenticator } from '../authenticator'; import * as ClientShield from '../../../../../../server/lib/get_client_shield'; describe('Authenticator', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); let config; let server; diff --git a/x-pack/plugins/security/server/lib/authentication/__tests__/session.js b/x-pack/plugins/security/server/lib/authentication/__tests__/session.js index b22a678fdd395..1c8612ad2f4d7 100644 --- a/x-pack/plugins/security/server/lib/authentication/__tests__/session.js +++ b/x-pack/plugins/security/server/lib/authentication/__tests__/session.js @@ -11,7 +11,7 @@ import { serverFixture } from '../../__tests__/__fixtures__/server'; import { Session } from '../session'; describe('Session', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); let server; let config; @@ -110,14 +110,14 @@ describe('Session', () => { sinon.assert.calledOnce(callback); sinon.assert.calledWithExactly(callback, null, true, sessionWithoutExpires); - callback.reset(); + callback.resetHistory(); const notExpiredSession = { token: 'token', expires: currentTime + 1 }; validateFunc({}, notExpiredSession, callback); sinon.assert.calledOnce(callback); sinon.assert.calledWithExactly(callback, null, true, notExpiredSession); - callback.reset(); + callback.resetHistory(); const expiredSession = { token: 'token', expires: currentTime - 1 }; validateFunc({}, expiredSession, callback); diff --git a/x-pack/plugins/security/server/routes/api/v1/__tests__/authenticate.js b/x-pack/plugins/security/server/routes/api/v1/__tests__/authenticate.js index d263d43d5114c..0e4bcbf2f6a06 100644 --- a/x-pack/plugins/security/server/routes/api/v1/__tests__/authenticate.js +++ b/x-pack/plugins/security/server/routes/api/v1/__tests__/authenticate.js @@ -93,7 +93,15 @@ describe('Authentication routes', () => { sinon.assert.notCalled(replyStub.continue); sinon.assert.calledOnce(replyStub); - sinon.assert.calledWithExactly(replyStub, Boom.unauthorized(failureReason)); + + sinon.assert.calledWithExactly( + replyStub, + sinon.match({ + isBoom: true, + message: failureReason.toString(), + output: { statusCode: 401 }, + }) + ); }); it('returns 401 if authentication is not handled.', async () => { @@ -105,7 +113,15 @@ describe('Authentication routes', () => { sinon.assert.notCalled(replyStub.continue); sinon.assert.calledOnce(replyStub); - sinon.assert.calledWithExactly(replyStub, Boom.unauthorized()); + + sinon.assert.calledWithExactly( + replyStub, + sinon.match({ + isBoom: true, + message: 'Unauthorized', + output: { statusCode: 401 }, + }) + ); }); it('returns user data if authentication succeed.', async () => { @@ -183,7 +199,11 @@ describe('Authentication routes', () => { sinon.assert.calledOnce(replyStub); sinon.assert.calledWithExactly( replyStub, - Boom.badRequest('Client should be able to process redirect response.') + sinon.match({ + isBoom: true, + message: 'Client should be able to process redirect response.', + output: { statusCode: 400 } + }) ); sinon.assert.notCalled(replyStub.continue); sinon.assert.notCalled(replyStub.redirect); @@ -323,7 +343,14 @@ describe('Authentication routes', () => { sinon.assert.notCalled(replyStub.continue); sinon.assert.notCalled(replyStub.redirect); sinon.assert.calledOnce(replyStub); - sinon.assert.calledWithExactly(replyStub, Boom.unauthorized(failureReason)); + sinon.assert.calledWithExactly( + replyStub, + sinon.match({ + isBoom: true, + message: failureReason.toString(), + output: { statusCode: 401 } + }) + ); }); it('returns 401 if authentication is not handled.', async () => { @@ -336,7 +363,14 @@ describe('Authentication routes', () => { sinon.assert.notCalled(replyStub.continue); sinon.assert.notCalled(replyStub.redirect); sinon.assert.calledOnce(replyStub); - sinon.assert.calledWithExactly(replyStub, Boom.unauthorized()); + sinon.assert.calledWithExactly( + replyStub, + sinon.match({ + isBoom: true, + message: 'Unauthorized', + output: { statusCode: 401 } + }) + ); }); it('returns 403 if there an active session exists.', async () => { @@ -351,10 +385,12 @@ describe('Authentication routes', () => { sinon.assert.calledOnce(replyStub); sinon.assert.calledWithExactly( replyStub, - Boom.forbidden( - 'Sorry, you already have an active Kibana session. ' + - 'If you want to start a new one, please logout from the existing session first.' - ) + sinon.match({ + isBoom: true, + message: 'Sorry, you already have an active Kibana session. ' + + 'If you want to start a new one, please logout from the existing session first.', + output: { statusCode: 403 } + }) ); }); diff --git a/x-pack/plugins/security/server/routes/api/v1/__tests__/users.js b/x-pack/plugins/security/server/routes/api/v1/__tests__/users.js index 3473021d182d7..204b703bf0f15 100644 --- a/x-pack/plugins/security/server/routes/api/v1/__tests__/users.js +++ b/x-pack/plugins/security/server/routes/api/v1/__tests__/users.js @@ -15,7 +15,7 @@ import { initUsersApi } from '../users'; import * as ClientShield from '../../../../../../../server/lib/get_client_shield'; describe('User routes', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); let clusterStub; let serverStub; diff --git a/x-pack/plugins/watcher/server/models/watch/__tests__/base_watch.js b/x-pack/plugins/watcher/server/models/watch/__tests__/base_watch.js index 8cbe7cc98d31a..1316559561f37 100644 --- a/x-pack/plugins/watcher/server/models/watch/__tests__/base_watch.js +++ b/x-pack/plugins/watcher/server/models/watch/__tests__/base_watch.js @@ -262,7 +262,7 @@ describe('BaseWatch', () => { let downstreamJson; beforeEach(() => { - actionFromDownstreamJSONMock.reset(); + actionFromDownstreamJSONMock.resetHistory(); downstreamJson = { id: 'my-watch', @@ -316,8 +316,8 @@ describe('BaseWatch', () => { let upstreamJson; beforeEach(() => { - actionFromUpstreamJSONMock.reset(); - watchStatusFromUpstreamJSONMock.reset(); + actionFromUpstreamJSONMock.resetHistory(); + watchStatusFromUpstreamJSONMock.resetHistory(); upstreamJson = { id: 'my-watch', diff --git a/x-pack/plugins/watcher/server/models/watch/__tests__/json_watch.js b/x-pack/plugins/watcher/server/models/watch/__tests__/json_watch.js index 8608b5e5a923c..e4b258d51cfe5 100644 --- a/x-pack/plugins/watcher/server/models/watch/__tests__/json_watch.js +++ b/x-pack/plugins/watcher/server/models/watch/__tests__/json_watch.js @@ -56,7 +56,7 @@ describe('JsonWatch', () => { let props; beforeEach(() => { - constructorMock.reset(); + constructorMock.resetHistory(); props = { watch: 'foo' @@ -99,7 +99,7 @@ describe('JsonWatch', () => { describe('upstreamJson getter method', () => { beforeEach(() => { - upstreamJsonMock.reset(); + upstreamJsonMock.resetHistory(); }); it('should call the getter from WatchBase and return the correct result', () => { @@ -119,7 +119,7 @@ describe('JsonWatch', () => { let props; beforeEach(() => { - downstreamJsonMock.reset(); + downstreamJsonMock.resetHistory(); props = { watch: 'foo', @@ -145,7 +145,7 @@ describe('JsonWatch', () => { let upstreamJson; beforeEach(() => { - getPropsFromUpstreamJsonMock.reset(); + getPropsFromUpstreamJsonMock.resetHistory(); upstreamJson = { watchJson: { foo: { bar: 'baz' } } @@ -199,7 +199,7 @@ describe('JsonWatch', () => { let downstreamJson; beforeEach(() => { - getPropsFromDownstreamJsonMock.reset(); + getPropsFromDownstreamJsonMock.resetHistory(); downstreamJson = { watch: { foo: { bar: 'baz' } } diff --git a/x-pack/plugins/watcher/server/models/watch/__tests__/monitoring_watch.js b/x-pack/plugins/watcher/server/models/watch/__tests__/monitoring_watch.js index 8b4c2e0d0455f..c580d8c8f7768 100644 --- a/x-pack/plugins/watcher/server/models/watch/__tests__/monitoring_watch.js +++ b/x-pack/plugins/watcher/server/models/watch/__tests__/monitoring_watch.js @@ -41,7 +41,7 @@ describe('MonitoringWatch', () => { let props; beforeEach(() => { - constructorMock.reset(); + constructorMock.resetHistory(); props = {}; }); @@ -108,7 +108,7 @@ describe('MonitoringWatch', () => { let props; beforeEach(() => { - downstreamJsonMock.reset(); + downstreamJsonMock.resetHistory(); props = {}; }); @@ -129,7 +129,7 @@ describe('MonitoringWatch', () => { describe('fromUpstreamJson factory method', () => { beforeEach(() => { - getPropsFromUpstreamJsonMock.reset(); + getPropsFromUpstreamJsonMock.resetHistory(); }); it('should call the getPropsFromUpstreamJson method of BaseWatch', () => { diff --git a/x-pack/plugins/watcher/server/models/watch/__tests__/threshold_watch.js b/x-pack/plugins/watcher/server/models/watch/__tests__/threshold_watch.js index 46d9a6d699a79..ed99ff6a84da8 100644 --- a/x-pack/plugins/watcher/server/models/watch/__tests__/threshold_watch.js +++ b/x-pack/plugins/watcher/server/models/watch/__tests__/threshold_watch.js @@ -111,7 +111,7 @@ describe('ThresholdWatch', () => { let props; beforeEach(() => { - constructorMock.reset(); + constructorMock.resetHistory(); props = { index: 'index', @@ -195,12 +195,12 @@ describe('ThresholdWatch', () => { describe('watchJson getter method', () => { beforeEach(() => { - buildActionsMock.reset(); - buildConditionMock.reset(); - buildInputMock.reset(); - buildMetadataMock.reset(); - buildTransformMock.reset(); - buildTriggerMock.reset(); + buildActionsMock.resetHistory(); + buildConditionMock.resetHistory(); + buildInputMock.resetHistory(); + buildMetadataMock.resetHistory(); + buildTransformMock.resetHistory(); + buildTriggerMock.resetHistory(); }); it('should return the correct result', () => { @@ -229,7 +229,7 @@ describe('ThresholdWatch', () => { describe('getVisualizeQuery method', () => { beforeEach(() => { - buildVisualizeQueryMock.reset(); + buildVisualizeQueryMock.resetHistory(); }); it('should call the external buildVisualizeQuery method', () => { @@ -245,7 +245,7 @@ describe('ThresholdWatch', () => { describe('formatVisualizeData method', () => { beforeEach(() => { - formatVisualizeDataMock.reset(); + formatVisualizeDataMock.resetHistory(); }); it('should call the external formatVisualizeData method', () => { @@ -262,7 +262,7 @@ describe('ThresholdWatch', () => { let props; beforeEach(() => { - upstreamJsonMock.reset(); + upstreamJsonMock.resetHistory(); props = { index: 'index', @@ -295,7 +295,7 @@ describe('ThresholdWatch', () => { let props; beforeEach(() => { - downstreamJsonMock.reset(); + downstreamJsonMock.resetHistory(); props = { index: 'index', @@ -342,7 +342,7 @@ describe('ThresholdWatch', () => { let upstreamJson; beforeEach(() => { - getPropsFromUpstreamJsonMock.reset(); + getPropsFromUpstreamJsonMock.resetHistory(); upstreamJson = { watchJson: { @@ -399,7 +399,7 @@ describe('ThresholdWatch', () => { let downstreamJson; beforeEach(() => { - getPropsFromDownstreamJsonMock.reset(); + getPropsFromDownstreamJsonMock.resetHistory(); downstreamJson = { index: 'index', diff --git a/x-pack/plugins/watcher/server/models/watch/__tests__/watch.js b/x-pack/plugins/watcher/server/models/watch/__tests__/watch.js index d91fd150de3c2..ac186b3846579 100644 --- a/x-pack/plugins/watcher/server/models/watch/__tests__/watch.js +++ b/x-pack/plugins/watcher/server/models/watch/__tests__/watch.js @@ -60,7 +60,7 @@ describe('Watch', () => { beforeEach(() => { Object.keys(watchTypeMocks).forEach(key => { - watchTypeMocks[key].fromDownstreamJsonMock.reset(); + watchTypeMocks[key].fromDownstreamJsonMock.resetHistory(); }); }); @@ -95,7 +95,7 @@ describe('Watch', () => { beforeEach(() => { Object.keys(watchTypeMocks).forEach(key => { - watchTypeMocks[key].fromUpstreamJsonMock.reset(); + watchTypeMocks[key].fromUpstreamJsonMock.resetHistory(); }); }); diff --git a/x-pack/plugins/xpack_main/public/hacks/__tests__/check_xpack_info_change.js b/x-pack/plugins/xpack_main/public/hacks/__tests__/check_xpack_info_change.js index a3304a1b12b33..a3cb4dfd8cdf5 100644 --- a/x-pack/plugins/xpack_main/public/hacks/__tests__/check_xpack_info_change.js +++ b/x-pack/plugins/xpack_main/public/hacks/__tests__/check_xpack_info_change.js @@ -12,7 +12,7 @@ const XPACK_INFO_SIG_KEY = 'xpackMain.infoSignature'; const XPACK_INFO_KEY = 'xpackMain.info'; describe('CheckXPackInfoChange Factory', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); let mockSessionStorage; beforeEach(ngMock.module('kibana', ($provide) => { @@ -95,7 +95,7 @@ describe('CheckXPackInfoChange Factory', () => { }); // If license didn't change banner shouldn't be displayed. - Notifier.prototype.directive.reset(); + Notifier.prototype.directive.resetHistory(); mockSessionStorage.getItem.withArgs(XPACK_INFO_SIG_KEY).returns('bar'); $http.post('/api/test'); diff --git a/x-pack/plugins/xpack_main/server/lib/__tests__/setup_xpack_main.js b/x-pack/plugins/xpack_main/server/lib/__tests__/setup_xpack_main.js index 2a71b1a9dfd73..c3bb9ccc5b21c 100644 --- a/x-pack/plugins/xpack_main/server/lib/__tests__/setup_xpack_main.js +++ b/x-pack/plugins/xpack_main/server/lib/__tests__/setup_xpack_main.js @@ -10,7 +10,7 @@ import { setupXPackMain } from '../setup_xpack_main'; import * as InjectXPackInfoSignatureNS from '../inject_xpack_info_signature'; describe('setupXPackMain()', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); let mockServer; let mockElasticsearchPlugin; @@ -58,7 +58,7 @@ describe('setupXPackMain()', () => { sinon.assert.calledWithExactly(mockServer.expose, 'info', sinon.match.instanceOf(XPackInfo)); sinon.assert.calledWithExactly(mockServer.ext, 'onPreResponse', sinon.match.func); - sinon.assert.calledWithExactly(mockElasticsearchPlugin.status.on, 'change', sinon.match.typeOf('asyncfunction')); + sinon.assert.calledWithExactly(mockElasticsearchPlugin.status.on, 'change', sinon.match.func); }); it('onPreResponse hook calls `injectXPackInfoSignature` for every request.', () => { @@ -95,7 +95,7 @@ describe('setupXPackMain()', () => { sinon.stub(xPackInfo, 'isAvailable').returns(false); // We need this to make sure the code waits for `refreshNow` to complete before it tries // to access its properties. - sinon.stub(xPackInfo, 'refreshNow', () => { + sinon.stub(xPackInfo, 'refreshNow').callsFake(() => { return new Promise((resolve) => { xPackInfo.isAvailable.returns(true); resolve(); @@ -114,7 +114,7 @@ describe('setupXPackMain()', () => { // We need this to make sure the code waits for `refreshNow` to complete before it tries // to access its properties. - sinon.stub(xPackInfo, 'refreshNow', () => { + sinon.stub(xPackInfo, 'refreshNow').callsFake(() => { return new Promise((resolve) => { xPackInfo.isAvailable.returns(false); xPackInfo.unavailableReason.returns('Some weird error.'); diff --git a/x-pack/plugins/xpack_main/server/lib/__tests__/xpack_info.js b/x-pack/plugins/xpack_main/server/lib/__tests__/xpack_info.js index 2bbc9d98d8681..4d896268d4d8a 100644 --- a/x-pack/plugins/xpack_main/server/lib/__tests__/xpack_info.js +++ b/x-pack/plugins/xpack_main/server/lib/__tests__/xpack_info.js @@ -48,7 +48,7 @@ function getSignature(object) { } describe('XPackInfo', () => { - const sandbox = sinon.sandbox.create(); + const sandbox = sinon.createSandbox(); let mockServer; let mockElasticsearchCluster; @@ -188,7 +188,7 @@ describe('XPackInfo', () => { 'mode: gold | status: active | expiry date: ' ) ); - mockServer.log.reset(); + mockServer.log.resetHistory(); await xPackInfo.refreshNow(); @@ -212,7 +212,7 @@ describe('XPackInfo', () => { }); it('restarts the poller.', async () => { - mockElasticsearchCluster.callWithInternalUser.reset(); + mockElasticsearchCluster.callWithInternalUser.resetHistory(); sandbox.clock.tick(1499); sinon.assert.notCalled(mockElasticsearchCluster.callWithInternalUser); @@ -231,7 +231,7 @@ describe('XPackInfo', () => { sandbox.clock.tick(1499); await xPackInfo.refreshNow(); - mockElasticsearchCluster.callWithInternalUser.reset(); + mockElasticsearchCluster.callWithInternalUser.resetHistory(); // Since poller has been restarted, it should not be called now. sandbox.clock.tick(1); diff --git a/x-pack/plugins/xpack_main/server/routes/api/v1/__tests__/xpack_info.js b/x-pack/plugins/xpack_main/server/routes/api/v1/__tests__/xpack_info.js index f5316a67c97de..06f5b8885f7dd 100644 --- a/x-pack/plugins/xpack_main/server/routes/api/v1/__tests__/xpack_info.js +++ b/x-pack/plugins/xpack_main/server/routes/api/v1/__tests__/xpack_info.js @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import Boom from 'boom'; import sinon from 'sinon'; import { xpackInfoRoute } from '../xpack_info'; @@ -43,7 +42,11 @@ describe('XPackInfo routes', () => { sinon.assert.calledWithExactly( replyStub, - Boom.notFound() + sinon.match({ + isBoom: true, + message: 'Not Found', + output: { statusCode: 404 }, + }) ); }); diff --git a/x-pack/yarn.lock b/x-pack/yarn.lock index 26895be8f54ee..a1766fbdb8e81 100644 --- a/x-pack/yarn.lock +++ b/x-pack/yarn.lock @@ -70,6 +70,12 @@ version "0.0.0" uid "" +"@sinonjs/formatio@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@sinonjs/formatio/-/formatio-2.0.0.tgz#84db7e9eb5531df18a8c5e0bfb6e449e55e654b2" + dependencies: + samsam "1.3.0" + "@types/jest@^22.2.3": version "22.2.3" resolved "https://registry.yarnpkg.com/@types/jest/-/jest-22.2.3.tgz#0157c0316dc3722c43a7b71de3fdf3acbccef10d" @@ -1463,13 +1469,6 @@ create-react-class@^15.5.2: loose-envify "^1.3.1" object-assign "^4.1.1" -create-thenable@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/create-thenable/-/create-thenable-1.0.2.tgz#e2031720ccc9575d8cfa31f5c146e762a80c0534" - dependencies: - object.omit "~2.0.0" - unique-concat "~0.2.2" - cross-spawn@^5.0.1: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" @@ -1870,6 +1869,10 @@ diff@3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" +diff@^3.1.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" + diff@^3.2.0: version "3.4.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.4.0.tgz#b1d85507daf3964828de54b37d0d73ba67dda56c" @@ -2538,12 +2541,6 @@ form-data@~2.1.1: combined-stream "^1.0.5" mime-types "^2.1.12" -formatio@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/formatio/-/formatio-1.1.1.tgz#5ed3ccd636551097383465d996199100e86161e9" - dependencies: - samsam "~1.1" - formidable@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/formidable/-/formidable-1.1.1.tgz#96b8886f7c3c3508b932d6bd70c4d3a88f35f1a9" @@ -4151,6 +4148,10 @@ jstimezonedetect@1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/jstimezonedetect/-/jstimezonedetect-1.0.5.tgz#93d035cd20e8c7d64eb1375cf5aa7a10a024466a" +just-extend@^1.1.27: + version "1.1.27" + resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-1.1.27.tgz#ec6e79410ff914e472652abfa0e603c03d60e905" + keymirror@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/keymirror/-/keymirror-0.1.1.tgz#918889ea13f8d0a42e7c557250eee713adc95c35" @@ -4511,9 +4512,9 @@ lodash@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/lodash/-/lodash-1.0.2.tgz#8f57560c83b59fc270bd3d561b690043430e2551" -lolex@1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.3.2.tgz#7c3da62ffcb30f0f5a80a2566ca24e45d8a01f31" +lolex@^2.2.0, lolex@^2.3.2: + version "2.6.0" + resolved "https://registry.yarnpkg.com/lolex/-/lolex-2.6.0.tgz#cf9166f3c9dece3cdeb5d6b01fce50f14a1203e3" longest@^1.0.1: version "1.0.1" @@ -4857,10 +4858,6 @@ nanomatch@^1.2.5: snapdragon "^0.8.1" to-regex "^3.0.1" -native-promise-only@~0.8.1: - version "0.8.1" - resolved "https://registry.yarnpkg.com/native-promise-only/-/native-promise-only-0.8.1.tgz#20a318c30cb45f71fe7adfbf7b21c99c1472ef11" - natives@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.1.tgz#011acce1f7cbd87f7ba6b3093d6cd9392be1c574" @@ -4892,6 +4889,16 @@ nigel@2.x.x: hoek "4.x.x" vise "2.x.x" +nise@^1.2.0: + version "1.3.3" + resolved "https://registry.yarnpkg.com/nise/-/nise-1.3.3.tgz#c17a850066a8a1dfeb37f921da02441afc4a82ba" + dependencies: + "@sinonjs/formatio" "^2.0.0" + just-extend "^1.1.27" + lolex "^2.3.2" + path-to-regexp "^1.7.0" + text-encoding "^0.6.4" + node-fetch@^1.0.1: version "1.7.3" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef" @@ -5087,7 +5094,7 @@ object.map@^1.0.0: for-own "^1.0.0" make-iterator "^1.0.0" -object.omit@^2.0.0, object.omit@~2.0.0: +object.omit@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" dependencies: @@ -6347,13 +6354,9 @@ safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@~5.1.0, version "5.1.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" -samsam@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.2.tgz#bec11fdc83a9fda063401210e40176c3024d1567" - -samsam@~1.1: - version "1.1.3" - resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.3.tgz#9f5087419b4d091f232571e7fa52e90b0f552621" +samsam@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.3.0.tgz#8d1d9350e25622da30de3e44ba692b5221ab7c50" sane@^2.0.0: version "2.2.0" @@ -6488,21 +6491,17 @@ simple-git@^1.91.0: dependencies: debug "^3.1.0" -sinon-as-promised@4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/sinon-as-promised/-/sinon-as-promised-4.0.3.tgz#c0545b1685fd813588a4ed697012487ed11d151b" +sinon@^5.0.7: + version "5.0.7" + resolved "https://registry.yarnpkg.com/sinon/-/sinon-5.0.7.tgz#3bded6a73613ccc9e512e20246ced69a27c27dab" dependencies: - create-thenable "~1.0.0" - native-promise-only "~0.8.1" - -sinon@1.17.3: - version "1.17.3" - resolved "https://registry.yarnpkg.com/sinon/-/sinon-1.17.3.tgz#44d64bc748d023880046c1543cefcea34c47d17e" - dependencies: - formatio "1.1.1" - lolex "1.3.2" - samsam "1.1.2" - util ">=0.10.3 <1" + "@sinonjs/formatio" "^2.0.0" + diff "^3.1.0" + lodash.get "^4.4.2" + lolex "^2.2.0" + nise "^1.2.0" + supports-color "^5.1.0" + type-detect "^4.0.5" slash@^1.0.0: version "1.0.0" @@ -6882,6 +6881,12 @@ supports-color@^4.0.0: dependencies: has-flag "^2.0.0" +supports-color@^5.1.0: + version "5.4.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.4.0.tgz#1c6b337402c2137605efe19f10fec390f6faab54" + dependencies: + has-flag "^3.0.0" + supports-color@^5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.3.0.tgz#5b24ac15db80fa927cf5227a4a33fd3c4c7676c0" @@ -6989,6 +6994,10 @@ tether@^1.3.7: version "1.4.3" resolved "https://registry.yarnpkg.com/tether/-/tether-1.4.3.tgz#fd547024c47b6e5c9b87e1880f997991a9a6ad54" +text-encoding@^0.6.4: + version "0.6.4" + resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19" + throat@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a" @@ -7184,6 +7193,10 @@ type-detect@0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822" +type-detect@^4.0.5: + version "4.0.8" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" + typedarray@^0.0.6, typedarray@~0.0.5: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" @@ -7267,10 +7280,6 @@ union-value@^1.0.0: is-extendable "^0.1.1" set-value "^0.4.3" -unique-concat@~0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/unique-concat/-/unique-concat-0.2.2.tgz#9210f9bdcaacc5e1e3929490d7c019df96f18712" - unique-stream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-1.0.0.tgz#d59a4a75427447d9aa6c91e70263f8d26a4b104b" @@ -7316,12 +7325,6 @@ util.promisify@^1.0.0: define-properties "^1.1.2" object.getownpropertydescriptors "^2.0.3" -"util@>=0.10.3 <1": - version "0.10.3" - resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" - dependencies: - inherits "2.0.1" - uuid@3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" diff --git a/yarn.lock b/yarn.lock index 8165bf16b31b8..73aafdd113502 100644 --- a/yarn.lock +++ b/yarn.lock @@ -172,6 +172,12 @@ call-me-maybe "^1.0.1" glob-to-regexp "^0.3.0" +"@sinonjs/formatio@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@sinonjs/formatio/-/formatio-2.0.0.tgz#84db7e9eb5531df18a8c5e0bfb6e449e55e654b2" + dependencies: + samsam "1.3.0" + "@types/events@*": version "1.2.0" resolved "https://registry.yarnpkg.com/@types/events/-/events-1.2.0.tgz#81a6731ce4df43619e5c8c945383b3e62a89ea86" @@ -4888,12 +4894,6 @@ form-data@~2.1.1: combined-stream "^1.0.5" mime-types "^2.1.12" -formatio@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/formatio/-/formatio-1.1.1.tgz#5ed3ccd636551097383465d996199100e86161e9" - dependencies: - samsam "~1.1" - formidable@^1.1.1: version "1.2.1" resolved "https://registry.yarnpkg.com/formidable/-/formidable-1.2.1.tgz#70fb7ca0290ee6ff961090415f4b3df3d2082659" @@ -7324,6 +7324,10 @@ jszip@2.5.0: dependencies: pako "~0.2.5" +just-extend@^1.1.27: + version "1.1.27" + resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-1.1.27.tgz#ec6e79410ff914e472652abfa0e603c03d60e905" + karma-chrome-launcher@2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-2.1.1.tgz#216879c68ac04d8d5140e99619ba04b59afd46cf" @@ -7970,9 +7974,9 @@ log4js@^0.6.31: readable-stream "~1.0.2" semver "~4.3.3" -lolex@1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.3.2.tgz#7c3da62ffcb30f0f5a80a2566ca24e45d8a01f31" +lolex@^2.2.0, lolex@^2.3.2: + version "2.6.0" + resolved "https://registry.yarnpkg.com/lolex/-/lolex-2.6.0.tgz#cf9166f3c9dece3cdeb5d6b01fce50f14a1203e3" longest@^1.0.1: version "1.0.1" @@ -8502,6 +8506,16 @@ nigel@2.x.x: hoek "4.x.x" vise "2.x.x" +nise@^1.2.0: + version "1.3.3" + resolved "https://registry.yarnpkg.com/nise/-/nise-1.3.3.tgz#c17a850066a8a1dfeb37f921da02441afc4a82ba" + dependencies: + "@sinonjs/formatio" "^2.0.0" + just-extend "^1.1.27" + lolex "^2.3.2" + path-to-regexp "^1.7.0" + text-encoding "^0.6.4" + no-ui-slider@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/no-ui-slider/-/no-ui-slider-1.2.0.tgz#1f64f5a8b82e6786f3261d82b0cc99b598817e69" @@ -10828,13 +10842,9 @@ safefs@^4.0.0: editions "^1.1.1" graceful-fs "^4.1.4" -samsam@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.2.tgz#bec11fdc83a9fda063401210e40176c3024d1567" - -samsam@~1.1: - version "1.1.3" - resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.3.tgz#9f5087419b4d091f232571e7fa52e90b0f552621" +samsam@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.3.0.tgz#8d1d9350e25622da30de3e44ba692b5221ab7c50" sane@^2.0.0: version "2.5.0" @@ -11037,14 +11047,17 @@ simple-swizzle@^0.2.2: dependencies: is-arrayish "^0.3.1" -sinon@1.17.3: - version "1.17.3" - resolved "https://registry.yarnpkg.com/sinon/-/sinon-1.17.3.tgz#44d64bc748d023880046c1543cefcea34c47d17e" +sinon@^5.0.7: + version "5.0.7" + resolved "https://registry.yarnpkg.com/sinon/-/sinon-5.0.7.tgz#3bded6a73613ccc9e512e20246ced69a27c27dab" dependencies: - formatio "1.1.1" - lolex "1.3.2" - samsam "1.1.2" - util ">=0.10.3 <1" + "@sinonjs/formatio" "^2.0.0" + diff "^3.1.0" + lodash.get "^4.4.2" + lolex "^2.2.0" + nise "^1.2.0" + supports-color "^5.1.0" + type-detect "^4.0.5" slash@^1.0.0: version "1.0.0" @@ -11675,6 +11688,12 @@ supports-color@^4.2.1: dependencies: has-flag "^2.0.0" +supports-color@^5.1.0: + version "5.4.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.4.0.tgz#1c6b337402c2137605efe19f10fec390f6faab54" + dependencies: + has-flag "^3.0.0" + supports-color@^5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.3.0.tgz#5b24ac15db80fa927cf5227a4a33fd3c4c7676c0" @@ -11827,6 +11846,10 @@ tether@^1.3.7: version "1.4.3" resolved "https://registry.yarnpkg.com/tether/-/tether-1.4.3.tgz#fd547024c47b6e5c9b87e1880f997991a9a6ad54" +text-encoding@^0.6.4: + version "0.6.4" + resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19" + text-table@^0.2.0, text-table@~0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" @@ -12163,6 +12186,10 @@ type-detect@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2" +type-detect@^4.0.5: + version "4.0.8" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" + type-is@~1.6.0, type-is@~1.6.10, type-is@~1.6.15: version "1.6.16" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.16.tgz#f89ce341541c672b25ee7ae3c73dee3b2be50194" @@ -12489,7 +12516,7 @@ util.promisify@^1.0.0: define-properties "^1.1.2" object.getownpropertydescriptors "^2.0.3" -util@0.10.3, "util@>=0.10.3 <1", util@^0.10.3: +util@0.10.3, util@^0.10.3: version "0.10.3" resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" dependencies: