|
1 | | -import path from 'node:path'; |
| 1 | +import path from "node:path"; |
2 | 2 |
|
3 | | -import { describe, expect, it } from 'vitest'; |
| 3 | +import { describe, expect, it } from "vitest"; |
4 | 4 |
|
5 | | -import { getResolvedInput } from '../index'; |
| 5 | +import { getResolvedInput } from "../index"; |
6 | 6 |
|
7 | | -describe('getResolvedInput', () => { |
8 | | - it('handles url', async () => { |
9 | | - const pathOrUrlOrSchema = 'https://foo.com'; |
| 7 | +describe("getResolvedInput", () => { |
| 8 | + it("handles url", async () => { |
| 9 | + const pathOrUrlOrSchema = "https://foo.com"; |
10 | 10 | const resolvedInput = await getResolvedInput({ pathOrUrlOrSchema }); |
11 | | - expect(resolvedInput.type).toBe('url'); |
| 11 | + expect(resolvedInput.type).toBe("url"); |
12 | 12 | expect(resolvedInput.schema).toBeUndefined(); |
13 | | - expect(resolvedInput.path).toBe('https://foo.com/'); |
| 13 | + expect(resolvedInput.path).toBe("https://foo.com/"); |
14 | 14 | }); |
15 | 15 |
|
16 | | - it('handles file', async () => { |
17 | | - const pathOrUrlOrSchema = './path/to/openapi.json'; |
| 16 | + it("handles file", async () => { |
| 17 | + const pathOrUrlOrSchema = "./path/to/openapi.json"; |
18 | 18 | const resolvedInput = await getResolvedInput({ pathOrUrlOrSchema }); |
19 | | - expect(resolvedInput.type).toBe('file'); |
| 19 | + expect(resolvedInput.type).toBe("file"); |
20 | 20 | expect(resolvedInput.schema).toBeUndefined(); |
21 | | - expect(resolvedInput.path).toBe(path.resolve('./path/to/openapi.json')); |
| 21 | + expect(path.normalize(resolvedInput.path).toLowerCase()).toBe( |
| 22 | + path.normalize(path.resolve("./path/to/openapi.json")).toLowerCase(), |
| 23 | + ); |
22 | 24 | }); |
23 | 25 |
|
24 | | - it('handles raw spec', async () => { |
25 | | - const pathOrUrlOrSchema = { |
| 26 | + it("handles raw spec", async () => { |
| 27 | + const pathOrUrlOrSchema = { |
26 | 28 | info: { |
27 | | - version: '1.0.0', |
| 29 | + version: "1.0.0", |
28 | 30 | }, |
29 | | - openapi: '3.1.0', |
| 31 | + openapi: "3.1.0", |
30 | 32 | paths: {}, |
31 | 33 | }; |
32 | 34 | const resolvedInput = await getResolvedInput({ pathOrUrlOrSchema }); |
33 | | - expect(resolvedInput.type).toBe('json'); |
| 35 | + expect(resolvedInput.type).toBe("json"); |
34 | 36 | expect(resolvedInput.schema).toEqual({ |
35 | 37 | info: { |
36 | | - version: '1.0.0', |
| 38 | + version: "1.0.0", |
37 | 39 | }, |
38 | | - openapi: '3.1.0', |
| 40 | + openapi: "3.1.0", |
39 | 41 | paths: {}, |
40 | 42 | }); |
41 | | - expect(resolvedInput.path).toBe(''); |
| 43 | + expect(resolvedInput.path).toBe(""); |
42 | 44 | }); |
43 | 45 | }); |
0 commit comments