mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 18:20:27 +00:00
42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
|
|
import {OrderedMap as makeOrderedMap} from 'immutable';
|
|
|
|
describe('WebApiUtils', () => {
|
|
const WebApiUtils = require('../web-api-utils');
|
|
|
|
describe('basePath', () => {
|
|
const basePath = WebApiUtils.basePath;
|
|
|
|
it('should handle /scope/terminal.html', () => {
|
|
expect(basePath('/scope/terminal.html')).toBe('/scope');
|
|
});
|
|
|
|
it('should handle /scope/', () => {
|
|
expect(basePath('/scope/')).toBe('/scope');
|
|
});
|
|
|
|
it('should handle /scope', () => {
|
|
expect(basePath('/scope')).toBe('/scope');
|
|
});
|
|
|
|
it('should handle /', () => {
|
|
expect(basePath('/')).toBe('');
|
|
});
|
|
});
|
|
|
|
describe('buildOptionsQuery', () => {
|
|
const buildOptionsQuery = WebApiUtils.buildOptionsQuery;
|
|
|
|
it('should handle empty options', () => {
|
|
expect(buildOptionsQuery(makeOrderedMap({}))).toBe('');
|
|
});
|
|
|
|
it('should combine multiple options', () => {
|
|
expect(buildOptionsQuery(makeOrderedMap([
|
|
['foo', 2],
|
|
['bar', 4]
|
|
]))).toBe('foo=2&bar=4');
|
|
});
|
|
});
|
|
});
|