Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed Dec 10, 2019
1 parent 0587f5f commit 55bc0e1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/core/public/http/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* under the License.
*/

import Url from 'url';
import { merge } from 'lodash';
import { format } from 'url';

import { merge } from '../../utils';
import { IBasePath, HttpInterceptor, HttpHandler, HttpFetchOptions, IHttpResponse } from './types';
import { HttpFetchError } from './http_fetch_error';
import { HttpInterceptController } from './http_intercept_controller';
Expand Down Expand Up @@ -99,7 +99,7 @@ export class FetchService {
},
options || {}
);
const url = Url.format({
const url = format({
pathname: shouldPrependBasePath ? this.params.basePath.prepend(path) : path,
query,
});
Expand Down
14 changes: 7 additions & 7 deletions src/core/public/http/http_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,32 +101,32 @@ describe('http requests', () => {

it('should return response', async () => {
const { http } = setup();

fetchMock.get('*', { foo: 'bar' });

const json = await http.fetch('/my/path');

expect(json).toEqual({ foo: 'bar' });
});

it('should prepend url with basepath by default', async () => {
const { http } = setup();

fetchMock.get('*', {});
await http.fetch('/my/path');

expect(fetchMock.lastUrl()).toBe('http://localhost/myBase/my/path');
});

it('should not prepend url with basepath when disabled', async () => {
const { http } = setup();

fetchMock.get('*', {});
await http.fetch('my/path', { prependBasePath: false });

expect(fetchMock.lastUrl()).toBe('/my/path');
});

it('should not include undefined query params', async () => {
const { http } = setup();
fetchMock.get('*', {});
await http.fetch('/my/path', { query: { a: undefined } });
expect(fetchMock.lastUrl()).toBe('http://localhost/myBase/my/path');
});

it('should make request with defaults', async () => {
const { http } = setup();

Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/spaces/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { Plugin } from './plugin';
// end public contract exports

export { SpacesPluginSetup } from './plugin';
export { SpacesServiceSetup } from './spaces_service';

export const config = { schema: ConfigSchema };
export const plugin = (initializerContext: PluginInitializerContext) =>
Expand Down

0 comments on commit 55bc0e1

Please sign in to comment.