Skip to content

Commit

Permalink
add a test for xpack.banner config deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed May 10, 2021
1 parent e51543e commit 346d20f
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions x-pack/plugins/banners/server/config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { config } from './config';
import { getDeprecationsFor } from '../../../../src/core/server/test_utils';

function applyDeprecations(settings?: Record<string, any>) {
return getDeprecationsFor({ provider: config.deprecations!, settings, path: 'xpack.banners' });
}

describe('deprecations', () => {
it('replaces xpack.banners.placement from "header" to "top"', () => {
const { migrated } = applyDeprecations({
placement: 'header',
});
expect(migrated.xpack.banners.placement).toBe('top');
});
it('logs a warning message about xpack.banners.placement renaming', () => {
const { messages } = applyDeprecations({
placement: 'header',
});
expect(messages).toMatchInlineSnapshot(`
Array [
"The \`header\` value for xpack.banners.placement has been replaced by \`top\`",
]
`);
});
it('do not rename other placement values', () => {
const { migrated, messages } = applyDeprecations({
placement: 'disabled',
});
expect(migrated.xpack.banners.placement).toBe('disabled');
expect(messages.length).toBe(0);
});
});

0 comments on commit 346d20f

Please sign in to comment.