forked from Kong/httpsnippet
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathutils.test.ts
32 lines (27 loc) · 1.01 KB
/
utils.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { describe, it, expect } from 'vitest';
import { availableTargets, extname } from './utils.js';
describe('availableTargets', () => {
it('returns all available targets', () => {
expect(availableTargets()).toMatchSnapshot();
});
describe('default value check', () => {
it.each(availableTargets().map(target => [target.title, target]))(
'should match `default` value with one of the client keys (%s)',
(_, target) => {
expect(target.clients).toContainEqual(expect.objectContaining({ key: target.default }));
},
);
});
});
describe('extname', () => {
it('returns the correct extension', () => {
expect(extname('c', 'libcurl')).toBe('.c');
expect(extname('clojure', 'clj_http')).toBe('.clj');
expect(extname('javascript', 'axios')).toBe('.js');
expect(extname('node', 'axios')).toBe('.cjs');
});
it('returns empty string if the extension is not found', () => {
// @ts-expect-error intentionally incorrect
expect(extname('ziltoid')).toBe('');
});
});