Skip to content

Commit

Permalink
added jest test
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Oct 11, 2021
1 parent 0848c88 commit 5ed49b7
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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 { get } from 'lodash';
import { ReportingConfig } from '../../../config/config';
import { getFullRedirectAppUrl } from './get_full_redirect_app_url';

describe('getFullRedirectAppUrl', () => {
let config: ReportingConfig;

beforeEach(() => {
const values = {
server: {
basePath: 'test',
},
kibanaServer: {
protocol: 'http',
hostname: 'localhost',
port: '1234',
},
};
config = {
get: jest.fn((...args: string[]) => get(values, args)),
kbnConfig: {
get: jest.fn((...args: string[]) => get(values, args)),
},
};
});

test('smoke test', () => {
expect(getFullRedirectAppUrl(config, 'test', undefined)).toBe(
'http://localhost:1234/test/s/test/app/management/insightsAndAlerting/reporting/r'
);
});

test('adding forceNow', () => {
expect(getFullRedirectAppUrl(config, 'test', 'TEST with a space')).toBe(
'http://localhost:1234/test/s/test/app/management/insightsAndAlerting/reporting/r?forceNow=TEST%20with%20a%20space'
);
});
});

0 comments on commit 5ed49b7

Please sign in to comment.