homebox/frontend/lib/api/base/index.test.ts

25 lines
671 B
TypeScript
Raw Normal View History

2022-08-31 00:06:57 +00:00
import { describe, expect, it } from 'vitest';
2022-09-05 00:55:52 +00:00
import { route } from '.';
2022-08-31 00:06:57 +00:00
describe('UrlBuilder', () => {
2022-09-05 00:55:52 +00:00
it('basic query parameter', () => {
const result = route('/test', { a: 'b' });
expect(result).toBe('/api/v1/test?a=b');
});
2022-08-31 00:06:57 +00:00
2022-09-05 00:55:52 +00:00
it('multiple query parameters', () => {
const result = route('/test', { a: 'b', c: 'd' });
expect(result).toBe('/api/v1/test?a=b&c=d');
});
2022-08-31 00:06:57 +00:00
2022-09-05 00:55:52 +00:00
it('no query parameters', () => {
const result = route('/test');
expect(result).toBe('/api/v1/test');
});
2022-08-31 00:06:57 +00:00
2022-09-05 00:55:52 +00:00
it('list-like query parameters', () => {
const result = route('/test', { a: ['b', 'c'] });
expect(result).toBe('/api/v1/test?a=b&a=c');
});
2022-08-31 00:06:57 +00:00
});