diff --git a/x-pack/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md b/x-pack/plugins/reporting/server/browsers/extract/__fixtures__/file.md similarity index 100% rename from x-pack/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md rename to x-pack/plugins/reporting/server/browsers/extract/__fixtures__/file.md diff --git a/x-pack/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md.zip b/x-pack/plugins/reporting/server/browsers/extract/__fixtures__/file.md.zip similarity index 100% rename from x-pack/plugins/reporting/server/browsers/extract/__tests__/__fixtures__/file.md.zip rename to x-pack/plugins/reporting/server/browsers/extract/__fixtures__/file.md.zip diff --git a/x-pack/plugins/reporting/server/browsers/extract/__tests__/extract.js b/x-pack/plugins/reporting/server/browsers/extract/extract.test.js similarity index 88% rename from x-pack/plugins/reporting/server/browsers/extract/__tests__/extract.js rename to x-pack/plugins/reporting/server/browsers/extract/extract.test.js index ab13703a90ed5..243a53e645bc9 100644 --- a/x-pack/plugins/reporting/server/browsers/extract/__tests__/extract.js +++ b/x-pack/plugins/reporting/server/browsers/extract/extract.test.js @@ -6,11 +6,10 @@ import fs from 'fs'; import crypto from 'crypto'; -import expect from '@kbn/expect'; import { resolve } from 'path'; -import { extract } from '../extract'; -import { ExtractError } from '../extract_error'; +import { extract } from './extract'; +import { ExtractError } from './extract_error'; import { promisify } from 'util'; const FIXTURES_FOLDER = resolve(__dirname, '__fixtures__'); @@ -71,18 +70,18 @@ describe('extract', () => { thrownException = e; } - expect(thrownException).to.be.an(ExtractError); + expect(thrownException).toBeInstanceOf(ExtractError); }); it('successfully extracts a valid zip file to the given target', async () => { await extract(SRC_FILE_COMPRESSED_ZIP, EXTRACT_TARGET_FOLDER); const stats = fs.statSync(EXTRACT_TARGET_FILE); - expect(stats).to.be.an(Object); + expect(stats).toBeInstanceOf(fs.Stats); const srcFileHash = await fileHash(SRC_FILE_UNCOMPRESSED); const targetFileHash = await fileHash(EXTRACT_TARGET_FILE); - expect(targetFileHash).to.eql(srcFileHash); + expect(targetFileHash).toEqual(srcFileHash); }); if (isWindows) { @@ -100,8 +99,8 @@ describe('extract', () => { thrownException = e; } - expect(thrownException).to.be.an(ExtractError); - expect(thrownException.cause.code).to.eql('EACCES'); + expect(thrownException).toBeInstanceOf(ExtractError); + expect(thrownException.cause.code).toEqual('EACCES'); }); } }); diff --git a/x-pack/plugins/reporting/server/lib/create_worker.test.ts b/x-pack/plugins/reporting/server/lib/create_worker.test.ts index 1fcd750849331..3ba5816beaf42 100644 --- a/x-pack/plugins/reporting/server/lib/create_worker.test.ts +++ b/x-pack/plugins/reporting/server/lib/create_worker.test.ts @@ -16,7 +16,7 @@ import { createWorkerFactory } from './create_worker'; // @ts-ignore import { Esqueue } from './esqueue'; // @ts-ignore -import { ClientMock } from './esqueue/__tests__/fixtures/legacy_elasticsearch'; +import { ClientMock } from './esqueue/__fixtures__/legacy_elasticsearch'; import { ExportTypesRegistry } from './export_types_registry'; const logger = createMockLevelLogger(); diff --git a/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/job.js b/x-pack/plugins/reporting/server/lib/esqueue/__fixtures__/job.js similarity index 100% rename from x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/job.js rename to x-pack/plugins/reporting/server/lib/esqueue/__fixtures__/job.js diff --git a/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/legacy_elasticsearch.js b/x-pack/plugins/reporting/server/lib/esqueue/__fixtures__/legacy_elasticsearch.js similarity index 100% rename from x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/legacy_elasticsearch.js rename to x-pack/plugins/reporting/server/lib/esqueue/__fixtures__/legacy_elasticsearch.js diff --git a/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/queue.js b/x-pack/plugins/reporting/server/lib/esqueue/__fixtures__/queue.js similarity index 100% rename from x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/queue.js rename to x-pack/plugins/reporting/server/lib/esqueue/__fixtures__/queue.js diff --git a/x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/worker.js b/x-pack/plugins/reporting/server/lib/esqueue/__fixtures__/worker.js similarity index 100% rename from x-pack/plugins/reporting/server/lib/esqueue/__tests__/fixtures/worker.js rename to x-pack/plugins/reporting/server/lib/esqueue/__fixtures__/worker.js diff --git a/x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/errors.js b/x-pack/plugins/reporting/server/lib/esqueue/helpers/errors.test.js similarity index 67% rename from x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/errors.js rename to x-pack/plugins/reporting/server/lib/esqueue/helpers/errors.test.js index d41b29106bb9d..a188add2d1ddc 100644 --- a/x-pack/plugins/reporting/server/lib/esqueue/__tests__/helpers/errors.js +++ b/x-pack/plugins/reporting/server/lib/esqueue/helpers/errors.test.js @@ -4,54 +4,53 @@ * you may not use this file except in compliance with the Elastic License. */ -import expect from '@kbn/expect'; -import { WorkerTimeoutError, UnspecifiedWorkerError } from '../../helpers/errors'; +import { WorkerTimeoutError, UnspecifiedWorkerError } from './errors'; describe('custom errors', function () { describe('WorkerTimeoutError', function () { it('should be function', () => { - expect(WorkerTimeoutError).to.be.a('function'); + expect(typeof WorkerTimeoutError).toBe('function'); }); it('should have a name', function () { const err = new WorkerTimeoutError('timeout error'); - expect(err).to.have.property('name', 'WorkerTimeoutError'); + expect(err).toHaveProperty('name', 'WorkerTimeoutError'); }); it('should take a jobId property', function () { const err = new WorkerTimeoutError('timeout error', { jobId: 'il7hl34rqlo8ro' }); - expect(err).to.have.property('jobId', 'il7hl34rqlo8ro'); + expect(err).toHaveProperty('jobId', 'il7hl34rqlo8ro'); }); it('should take a timeout property', function () { const err = new WorkerTimeoutError('timeout error', { timeout: 15000 }); - expect(err).to.have.property('timeout', 15000); + expect(err).toHaveProperty('timeout', 15000); }); it('should be stringifyable', function () { const err = new WorkerTimeoutError('timeout error'); - expect(`${err}`).to.equal('WorkerTimeoutError: timeout error'); + expect(`${err}`).toEqual('WorkerTimeoutError: timeout error'); }); }); describe('UnspecifiedWorkerError', function () { it('should be function', () => { - expect(UnspecifiedWorkerError).to.be.a('function'); + expect(typeof UnspecifiedWorkerError).toBe('function'); }); it('should have a name', function () { const err = new UnspecifiedWorkerError('unspecified error'); - expect(err).to.have.property('name', 'UnspecifiedWorkerError'); + expect(err).toHaveProperty('name', 'UnspecifiedWorkerError'); }); it('should take a jobId property', function () { const err = new UnspecifiedWorkerError('unspecified error', { jobId: 'il7hl34rqlo8ro' }); - expect(err).to.have.property('jobId', 'il7hl34rqlo8ro'); + expect(err).toHaveProperty('jobId', 'il7hl34rqlo8ro'); }); it('should be stringifyable', function () { const err = new UnspecifiedWorkerError('unspecified error'); - expect(`${err}`).to.equal('UnspecifiedWorkerError: unspecified error'); + expect(`${err}`).toEqual('UnspecifiedWorkerError: unspecified error'); }); }); }); diff --git a/x-pack/plugins/reporting/server/lib/esqueue/__tests__/index.js b/x-pack/plugins/reporting/server/lib/esqueue/index.test.js similarity index 92% rename from x-pack/plugins/reporting/server/lib/esqueue/__tests__/index.js rename to x-pack/plugins/reporting/server/lib/esqueue/index.test.js index 7cdae152ad0d7..072614e69d5a5 100644 --- a/x-pack/plugins/reporting/server/lib/esqueue/__tests__/index.js +++ b/x-pack/plugins/reporting/server/lib/esqueue/index.test.js @@ -9,17 +9,18 @@ import expect from '@kbn/expect'; import sinon from 'sinon'; import proxyquire from 'proxyquire'; import { noop, times } from 'lodash'; -import { constants } from '../constants'; -import { ClientMock } from './fixtures/legacy_elasticsearch'; -import { JobMock } from './fixtures/job'; -import { WorkerMock } from './fixtures/worker'; +import { constants } from './constants'; +import { ClientMock } from './__fixtures__/legacy_elasticsearch'; +import { JobMock } from './__fixtures__/job'; +import { WorkerMock } from './__fixtures__/worker'; -const { Esqueue } = proxyquire.noPreserveCache()('../index', { +const { Esqueue } = proxyquire.noPreserveCache()('./index', { './job': { Job: JobMock }, './worker': { Worker: WorkerMock }, }); -describe('Esqueue class', function () { +// TODO: tests were not running and are not up to date +describe.skip('Esqueue class', function () { let client; beforeEach(function () { diff --git a/x-pack/plugins/reporting/server/lib/esqueue/__tests__/worker.js b/x-pack/plugins/reporting/server/lib/esqueue/worker.test.js similarity index 99% rename from x-pack/plugins/reporting/server/lib/esqueue/__tests__/worker.js rename to x-pack/plugins/reporting/server/lib/esqueue/worker.test.js index 123607710aa57..52b55d72296e4 100644 --- a/x-pack/plugins/reporting/server/lib/esqueue/__tests__/worker.js +++ b/x-pack/plugins/reporting/server/lib/esqueue/worker.test.js @@ -8,10 +8,10 @@ import expect from '@kbn/expect'; import sinon from 'sinon'; import moment from 'moment'; import { noop, random, get, find, identity } from 'lodash'; -import { ClientMock } from './fixtures/legacy_elasticsearch'; -import { QueueMock } from './fixtures/queue'; -import { formatJobObject, getUpdatedDocPath, Worker } from '../worker'; -import { constants } from '../constants'; +import { ClientMock } from './__fixtures__/legacy_elasticsearch'; +import { QueueMock } from './__fixtures__/queue'; +import { formatJobObject, getUpdatedDocPath, Worker } from './worker'; +import { constants } from './constants'; const anchor = '2016-04-02T01:02:03.456'; // saturday const defaults = { @@ -26,9 +26,10 @@ const defaultWorkerOptions = { intervalErrorMultiplier: 10, }; -describe('Worker class', function () { +// TODO: tests were not running and are not up to date +describe.skip('Worker class', function () { // some of these tests might be a little slow, give them a little extra time - this.timeout(10000); + jest.setTimeout(10000); let anchorMoment; let clock; diff --git a/x-pack/plugins/reporting/server/lib/__tests__/export_types_registry.js b/x-pack/plugins/reporting/server/lib/export_types_registry.test.js similarity index 86% rename from x-pack/plugins/reporting/server/lib/__tests__/export_types_registry.js rename to x-pack/plugins/reporting/server/lib/export_types_registry.test.js index 3f8b7e7e75af1..1afeaa4bba950 100644 --- a/x-pack/plugins/reporting/server/lib/__tests__/export_types_registry.js +++ b/x-pack/plugins/reporting/server/lib/export_types_registry.test.js @@ -4,8 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import expect from '@kbn/expect'; -import { ExportTypesRegistry } from '../export_types_registry'; +import { ExportTypesRegistry } from './export_types_registry'; describe('ExportTypesRegistry', function () { let exportTypesRegistry; @@ -17,30 +16,30 @@ describe('ExportTypesRegistry', function () { it(`doesn't throw an Error when using a new type with a string id`, function () { expect(() => { exportTypesRegistry.register({ id: 'foo' }); - }).to.not.throwError(); + }).not.toThrow(); }); it('throws an Error when registering a type without an id', function () { expect(() => { exportTypesRegistry.register({}); - }).to.throwError(); + }).toThrow(); }); it('throws an Error when registering a type with an integer id', function () { expect(() => { exportTypesRegistry.register({ id: 1 }); - }).to.throwError(); + }).toThrow(); }); it('throws an Error when registering the same id twice', function () { const id = 'foo'; expect(() => { exportTypesRegistry.register({ id }); - }).to.not.throwError(); + }).not.toThrow(); expect(() => { exportTypesRegistry.register({ id }); - }).to.throwError(); + }).toThrow(); }); }); @@ -50,20 +49,20 @@ describe('ExportTypesRegistry', function () { const obj = { id }; exportTypesRegistry.register(obj); exportTypesRegistry.register({ id: 'bar' }); - expect(exportTypesRegistry.getById(id)).to.be(obj); + expect(exportTypesRegistry.getById(id)).toBe(obj); }); it(`throws an Error if the id isn't found`, function () { expect(() => { exportTypesRegistry.getById('foo'); - }).to.throwError(); + }).toThrow(); }); }); describe('getAll', function () { it('returns an empty Iterator if no objects have been registered', function () { const array = Array.from(exportTypesRegistry.getAll()); - expect(array.length).to.be(0); + expect(array.length).toBe(0); }); it('returns all objects that have been registered', function () { @@ -72,15 +71,15 @@ describe('ExportTypesRegistry', function () { const objs = [obj1, obj2]; objs.forEach((obj) => exportTypesRegistry.register(obj)); const all = Array.from(exportTypesRegistry.getAll()); - expect(all).to.contain(obj1); - expect(all).to.contain(obj2); + expect(all).toContain(obj1); + expect(all).toContain(obj2); }); }); describe('getSize', function () { it('returns 0 initially', function () { const size = exportTypesRegistry.getSize(); - expect(size).to.be(0); + expect(size).toBe(0); }); it('returns the number of objects that have been added', function () { @@ -88,7 +87,7 @@ describe('ExportTypesRegistry', function () { exportTypesRegistry.register({ id: 'bar' }); exportTypesRegistry.register({ id: 'baz' }); const size = exportTypesRegistry.getSize(); - expect(size).to.be(3); + expect(size).toBe(3); }); }); @@ -97,7 +96,7 @@ describe('ExportTypesRegistry', function () { const prop = 'fooProp'; const match = { id: 'foo', prop }; [match, { id: 'bar' }, { id: 'baz' }].forEach((obj) => exportTypesRegistry.register(obj)); - expect(exportTypesRegistry.get((item) => item.prop === prop)).to.be(match); + expect(exportTypesRegistry.get((item) => item.prop === prop)).toBe(match); }); it('throws Error if multiple items match predicate', function () { @@ -108,7 +107,7 @@ describe('ExportTypesRegistry', function () { ].forEach((obj) => exportTypesRegistry.register(obj)); expect(() => { exportTypesRegistry.get((item) => item.prop === prop); - }).to.throwError(); + }).toThrow(); }); it('throws Error if no items match predicate', function () { @@ -119,7 +118,7 @@ describe('ExportTypesRegistry', function () { ].forEach((obj) => exportTypesRegistry.register(obj)); expect(() => { exportTypesRegistry.get((item) => item.prop !== prop); - }).to.throwError(); + }).toThrow(); }); }); });