Skip to content

Commit

Permalink
fix: failed unit test because of an invalid mocked request
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
  • Loading branch information
SuZhou-Joe committed Aug 14, 2024
1 parent c8e849c commit 943056b
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions server/utils/next_url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ import {
validateNextUrl,
INVALID_NEXT_URL_PARAMETER_MESSAGE,
} from './next_url';
import { httpServerMock } from '../../../../src/core/server/mocks';

describe('test composeNextUrlQueryParam', () => {
httpServerMock.createOpenSearchDashboardsRequest();
test('no base, no path', () => {
expect(
composeNextUrlQueryParam(
{
url: 'http://localhost:123',
},
httpServerMock.createOpenSearchDashboardsRequest({
path: ''
}),
''
)
).toEqual('');
Expand All @@ -34,9 +36,9 @@ describe('test composeNextUrlQueryParam', () => {
test('no base, path', () => {
expect(
composeNextUrlQueryParam(
{
url: 'http://localhost:123/alpha/major/foxtrot',
},
httpServerMock.createOpenSearchDashboardsRequest({
path: '/alpha/major/foxtrot'
}),
''
)
).toEqual('nextUrl=%2Falpha%2Fmajor%2Ffoxtrot');
Expand All @@ -45,9 +47,9 @@ describe('test composeNextUrlQueryParam', () => {
test('base, no path', () => {
expect(
composeNextUrlQueryParam(
{
url: 'http://localhost:123',
},
httpServerMock.createOpenSearchDashboardsRequest({
path: ''
}),
'xyz'
)
).toEqual('');
Expand All @@ -56,9 +58,9 @@ describe('test composeNextUrlQueryParam', () => {
test('base, path', () => {
expect(
composeNextUrlQueryParam(
{
url: 'http://localhost:123/alpha/major/foxtrot',
},
httpServerMock.createOpenSearchDashboardsRequest({
path: '/alpha/major/foxtrot'
}),
'xyz'
)
).toEqual('nextUrl=xyz%2Falpha%2Fmajor%2Ffoxtrot');
Expand Down

0 comments on commit 943056b

Please sign in to comment.