@mintlify/scraping 4.0.1089 → 4.0.1091

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,32 @@
1
1
  import { validateAsyncApi } from '@mintlify/common';
2
2
  import { readFile } from 'fs/promises';
3
3
  import path from 'path';
4
- import { describe, it, expect, beforeEach, vi } from 'vitest';
4
+ import { describe, it, expect, afterEach, beforeEach, vi } from 'vitest';
5
5
 
6
6
  import { getAsyncApiDefinition } from '../src/asyncapi/getAsyncApiDefinition.js';
7
7
 
8
8
  const httpsError =
9
9
  'Only HTTPS URLs are supported. HTTP URLs are only supported with the cli option --local-schema.';
10
10
 
11
- // TODO - make these not reliant on actual network connectivity and unskip
12
- describe.skip('getAsyncApiDefinition', () => {
13
- beforeEach(() => {
14
- vi.resetAllMocks();
11
+ const validUrl = 'https://example.com/asyncapi.yaml';
12
+
13
+ describe('getAsyncApiDefinition', () => {
14
+ beforeEach(async () => {
15
+ const valid = await readFile(path.join(__dirname, 'fixtures', 'basicAsyncAPI.yml'), 'utf8');
16
+ vi.stubGlobal(
17
+ 'fetch',
18
+ vi.fn(async (input: string | URL) => {
19
+ const url = input.toString();
20
+ if (url === validUrl) return new Response(valid);
21
+ if (url.startsWith('https://example.com/')) return new Response('not: asyncapi');
22
+ throw new TypeError('fetch failed');
23
+ })
24
+ );
25
+ });
26
+
27
+ afterEach(() => {
28
+ vi.useRealTimers();
29
+ vi.unstubAllGlobals();
15
30
  });
16
31
 
17
32
  it('should load AsyncAPI doc from a local file path', async () => {
@@ -28,15 +43,14 @@ describe.skip('getAsyncApiDefinition', () => {
28
43
  });
29
44
 
30
45
  it('should fetch yaml AsyncAPI doc from URL', async () => {
31
- const url = new URL('https://d4tuoctqmanu0.cloudfront.net/test-fixtures/asyncapi.yaml');
46
+ const url = new URL(validUrl);
32
47
  const result = await getAsyncApiDefinition(url);
33
48
  expect(result.document).toBeDefined();
34
49
  expect(result.isUrl).toBe(true);
35
50
  });
36
51
 
37
52
  it('should fetch AsyncAPI doc from URL string', async () => {
38
- const url = 'https://d4tuoctqmanu0.cloudfront.net/test-fixtures/asyncapi.yaml';
39
- const result = await getAsyncApiDefinition(url);
53
+ const result = await getAsyncApiDefinition(validUrl);
40
54
  expect(result.document).toBeDefined();
41
55
  expect(result.isUrl).toBe(true);
42
56
  });
@@ -48,9 +62,12 @@ describe.skip('getAsyncApiDefinition', () => {
48
62
  it('should throw error with URL and status code when fetch fails', async () => {
49
63
  const urlString = 'https://mycoolwebsocketschema/asyncapi.doesnotexist';
50
64
 
51
- await expect(getAsyncApiDefinition(urlString)).rejects.toThrow(
65
+ vi.useFakeTimers();
66
+ const assertion = expect(getAsyncApiDefinition(urlString)).rejects.toThrow(
52
67
  `${urlString} - failed to retrieve AsyncAPI file from source - : fetch failed`
53
68
  );
69
+ await vi.runAllTimersAsync();
70
+ await assertion;
54
71
  });
55
72
 
56
73
  it('should throw error when HTTP URL is provided', async () => {
@@ -69,6 +86,6 @@ describe.skip('getAsyncApiDefinition', () => {
69
86
  });
70
87
 
71
88
  it('should throw error when URL response is invalid', async () => {
72
- await expect(getAsyncApiDefinition('https://example.com/asyncapi.yaml')).rejects.toThrow();
89
+ await expect(getAsyncApiDefinition('https://example.com/invalid.yaml')).rejects.toThrow();
73
90
  });
74
91
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/scraping",
3
- "version": "4.0.1089",
3
+ "version": "4.0.1091",
4
4
  "description": "Scrape documentation frameworks to Mintlify docs",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -43,7 +43,7 @@
43
43
  "format:check": "oxfmt --check"
44
44
  },
45
45
  "dependencies": {
46
- "@mintlify/common": "1.0.1219",
46
+ "@mintlify/common": "1.0.1221",
47
47
  "fast-xml-parser": "5.7.3",
48
48
  "fs-extra": "11.1.1",
49
49
  "graphql": "16.11.0",
@@ -87,5 +87,5 @@
87
87
  "optional": true
88
88
  }
89
89
  },
90
- "gitHead": "cccec209b476ebfc259b53bfd7c0e28667202df1"
90
+ "gitHead": "911b500bf0e880176dc9ecc8136ef3e1e5e9d9e8"
91
91
  }