Skip to content

Commit

Permalink
[savedObjects/errors] add tests for EsAutoCreateIndexError
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Nov 7, 2017
1 parent ee08eb2 commit d906d3e
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/server/saved_objects/client/lib/__tests__/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
decorateEsUnavailableError,
isEsUnavailableError,
decorateGeneralError,
isEsAutoCreateIndexError,
createEsAutoCreateIndexError,
} from '../errors';

describe('savedObjectsClient/errorTypes', () => {
Expand Down Expand Up @@ -285,4 +287,39 @@ describe('savedObjectsClient/errorTypes', () => {
});
});
});

describe('EsAutoCreateIndex error', () => {
describe('createEsAutoCreateIndexError', () => {
it('does not take an error argument', () => {
const error = new Error();
expect(createEsAutoCreateIndexError(error)).to.not.be(error);
});

it('returns a new Error', () => {
expect(createEsAutoCreateIndexError()).to.be.a(Error);
});

it('makes errors identifiable as EsAutoCreateIndex errors', () => {
expect(isEsAutoCreateIndexError(createEsAutoCreateIndexError())).to.be(true);
});

it('returns a boom error', () => {
const error = createEsAutoCreateIndexError();
expect(error).to.have.property('isBoom', true);
expect(error.output).to.be.an('object');
expect(error.output.statusCode).to.be(503);
});

describe('error.output', () => {
it('uses "Automatic index creation failed" message', () => {
const error = createEsAutoCreateIndexError();
expect(error.output.payload).to.have.property('message', 'Automatic index creation failed');
});
it('sets statusCode to 503', () => {
const error = createEsAutoCreateIndexError();
expect(error.output).to.have.property('statusCode', 503);
});
});
});
});
});

0 comments on commit d906d3e

Please sign in to comment.