mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[6.x] Upgrade sinon
(v1.17.3 --> v5.0.7). (#19293)
This commit is contained in:
parent
8bd8d4c35c
commit
dc16506da8
112 changed files with 444 additions and 354 deletions
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -7,7 +7,7 @@ import {
|
|||
KuiToolBarSearchBox,
|
||||
} from './tool_bar_search_box';
|
||||
|
||||
const onFilter = sinon.spy();
|
||||
const onFilter = sinon.stub();
|
||||
|
||||
test('renders KuiToolBarSearchBox', () => {
|
||||
const component = <KuiToolBarSearchBox onFilter={onFilter} {...requiredProps} />;
|
||||
|
@ -17,7 +17,7 @@ test('renders KuiToolBarSearchBox', () => {
|
|||
describe('onFilter', () => {
|
||||
test('is called on change event, with the value entered', () => {
|
||||
const searchBox = mount(<KuiToolBarSearchBox onFilter={onFilter} {...requiredProps} />);
|
||||
onFilter.reset();
|
||||
onFilter.resetHistory();
|
||||
const event = { target: { value: 'a' } };
|
||||
searchBox.find('input').simulate('change', event);
|
||||
sinon.assert.calledWith(onFilter, 'a');
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
|
|
@ -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'
|
||||
});
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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()));
|
||||
});
|
||||
|
||||
|
|
|
@ -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()));
|
||||
});
|
||||
|
||||
|
|
|
@ -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()));
|
||||
});
|
||||
|
||||
|
|
|
@ -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()));
|
||||
});
|
||||
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
|
|
@ -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: {} }) => {
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -67,7 +67,7 @@ describe('Dashboard Context', () => {
|
|||
});
|
||||
|
||||
afterEach(() => {
|
||||
getAppState.reset();
|
||||
getAppState.resetHistory();
|
||||
});
|
||||
|
||||
it('should add a valid filter to must', () => {
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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 = {};
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()`', () => {
|
||||
|
|
|
@ -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()', () => {
|
||||
|
|
|
@ -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()', () => {
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -22,7 +22,7 @@ describe('POST /api/saved_objects/_bulk_get', () => {
|
|||
});
|
||||
|
||||
afterEach(() => {
|
||||
savedObjectsClient.bulkGet.reset();
|
||||
savedObjectsClient.bulkGet.resetHistory();
|
||||
});
|
||||
|
||||
it('formats successful response', async () => {
|
||||
|
|
|
@ -22,7 +22,7 @@ describe('POST /api/saved_objects/{type}', () => {
|
|||
});
|
||||
|
||||
afterEach(() => {
|
||||
savedObjectsClient.create.reset();
|
||||
savedObjectsClient.create.resetHistory();
|
||||
});
|
||||
|
||||
it('formats successful response', async () => {
|
||||
|
|
|
@ -22,7 +22,7 @@ describe('DELETE /api/saved_objects/{type}/{id}', () => {
|
|||
});
|
||||
|
||||
afterEach(() => {
|
||||
savedObjectsClient.delete.reset();
|
||||
savedObjectsClient.delete.resetHistory();
|
||||
});
|
||||
|
||||
it('formats successful response', async () => {
|
||||
|
|
|
@ -22,7 +22,7 @@ describe('GET /api/saved_objects/_find', () => {
|
|||
});
|
||||
|
||||
afterEach(() => {
|
||||
savedObjectsClient.find.reset();
|
||||
savedObjectsClient.find.resetHistory();
|
||||
});
|
||||
|
||||
it('formats successful response', async () => {
|
||||
|
|
|
@ -22,7 +22,7 @@ describe('GET /api/saved_objects/{type}/{id}', () => {
|
|||
});
|
||||
|
||||
afterEach(() => {
|
||||
savedObjectsClient.get.reset();
|
||||
savedObjectsClient.get.resetHistory();
|
||||
});
|
||||
|
||||
it('formats successful response', async () => {
|
||||
|
|
|
@ -22,7 +22,7 @@ describe('PUT /api/saved_objects/{type}/{id?}', () => {
|
|||
});
|
||||
|
||||
afterEach(() => {
|
||||
savedObjectsClient.update.reset();
|
||||
savedObjectsClient.update.resetHistory();
|
||||
});
|
||||
|
||||
it('formats successful response', async () => {
|
||||
|
|
|
@ -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(() => {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -39,7 +39,7 @@ describe('filterBarClickHandler', function () {
|
|||
};
|
||||
}));
|
||||
|
||||
afterEach(function () {
|
||||
beforeEach(function () {
|
||||
toastNotifications.list.splice(0);
|
||||
});
|
||||
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
}));
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
);
|
||||
|
|
|
@ -93,8 +93,8 @@ describe('ui/modals/confirm_modal', function () {
|
|||
};
|
||||
|
||||
beforeEach(() => {
|
||||
confirmCallback.reset();
|
||||
cancelCallback.reset();
|
||||
confirmCallback.resetHistory();
|
||||
cancelCallback.resetHistory();
|
||||
});
|
||||
|
||||
it('onCancel', function () {
|
||||
|
|
|
@ -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(() => {
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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);
|
||||
}));
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 = $('<kbn-global-timepicker></kbn-global-timepicker>');
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -57,7 +57,7 @@ describe('authorized_user_pre_routing', function () {
|
|||
}
|
||||
};
|
||||
|
||||
callWithRequestStub.reset();
|
||||
callWithRequestStub.resetHistory();
|
||||
callWithRequestStub.returns(Promise.resolve(user));
|
||||
return mockServer;
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ describe('Reporting: Validate config', function () {
|
|||
const log = sinon.spy();
|
||||
|
||||
beforeEach(() => {
|
||||
log.reset();
|
||||
log.resetHistory();
|
||||
});
|
||||
|
||||
[undefined, null].forEach(value => {
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 }
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue