@mintlify/scraping 4.0.1161 → 4.0.1162

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.
@@ -44,4 +44,110 @@ describe('findSdkPage heuristic fallback', () => {
44
44
  'other/location'
45
45
  );
46
46
  });
47
+
48
+ it('does not fall back to the heuristic for an explicit namespace or a targeted page', () => {
49
+ const targeted: SdkReference = {
50
+ pages: [
51
+ {
52
+ slug: 'other/Client/Do',
53
+ title: 'Client.Do',
54
+ content: '',
55
+ target: { kind: 'method', name: 'Do', parent: 'Client', namespace: 'other' },
56
+ },
57
+ {
58
+ slug: 'classes/Legacy',
59
+ title: 'Legacy',
60
+ content: '',
61
+ target: { kind: 'class', name: 'Legacy' },
62
+ },
63
+ {
64
+ slug: 'classes/Auth.Client/login',
65
+ title: 'Auth.Client.login',
66
+ content: '',
67
+ target: { kind: 'method', name: 'login', parent: 'Client' },
68
+ },
69
+ ],
70
+ groups: [],
71
+ };
72
+ expect(
73
+ findSdkPage(targeted, { kind: 'method', name: 'Do', parent: 'Client', namespace: 'legacy' })
74
+ ).toBeUndefined();
75
+ expect(findSdkPage(targeted, { kind: 'interface', name: 'Legacy' })).toBeUndefined();
76
+ expect(
77
+ findSdkPage(targeted, { kind: 'method', name: 'login', parent: 'Auth.Client' })?.slug
78
+ ).toBe('classes/Auth.Client/login');
79
+ expect(
80
+ findSdkPage(targeted, { kind: 'property', name: 'login', parent: 'Auth.Client' })
81
+ ).toBeUndefined();
82
+ });
83
+
84
+ it('keeps the first match when duplicate targets carry no namespace', () => {
85
+ const duplicates: SdkReference = {
86
+ pages: [
87
+ {
88
+ slug: 'a/Client',
89
+ title: 'Client',
90
+ content: '',
91
+ target: { kind: 'class', name: 'Client' },
92
+ },
93
+ {
94
+ slug: 'b/Client',
95
+ title: 'Client',
96
+ content: '',
97
+ target: { kind: 'class', name: 'Client' },
98
+ },
99
+ ],
100
+ groups: [],
101
+ };
102
+ expect(findSdkPage(duplicates, { kind: 'class', name: 'Client' })?.slug).toBe('a/Client');
103
+ });
104
+
105
+ it('applies a requested namespace to the symbol or its parent', () => {
106
+ const namespaced: SdkReference = {
107
+ pages: [
108
+ {
109
+ slug: 'legacy/Client',
110
+ title: 'Client',
111
+ content: '',
112
+ target: { kind: 'type', name: 'Client', namespace: 'legacy' },
113
+ },
114
+ {
115
+ slug: 'legacy/Client/Close',
116
+ title: 'Client.Close',
117
+ content: '',
118
+ target: { kind: 'method', name: 'Close', parent: 'Client', namespace: 'legacy' },
119
+ },
120
+ {
121
+ slug: 'x/legacy/Client',
122
+ title: 'Client',
123
+ content: '',
124
+ target: { kind: 'type', name: 'Client', namespace: 'x.legacy' },
125
+ },
126
+ ],
127
+ groups: [],
128
+ };
129
+ expect(
130
+ findSdkPage(namespaced, { kind: 'type', name: 'Client', namespace: 'legacy' })?.slug
131
+ ).toBe('legacy/Client');
132
+ expect(
133
+ findSdkPage(namespaced, { kind: 'type', name: 'Client', namespace: 'x.legacy' })?.slug
134
+ ).toBe('x/legacy/Client');
135
+ expect(findSdkPage(namespaced, { kind: 'type', name: 'legacy.Client' })?.slug).toBe(
136
+ 'legacy/Client'
137
+ );
138
+ expect(findSdkPage(namespaced, { kind: 'type', name: 'x.legacy.Client' })?.slug).toBe(
139
+ 'x/legacy/Client'
140
+ );
141
+ expect(
142
+ findSdkPage(namespaced, {
143
+ kind: 'method',
144
+ name: 'Close',
145
+ parent: 'Client',
146
+ namespace: 'legacy',
147
+ })?.slug
148
+ ).toBe('legacy/Client/Close');
149
+ expect(() => findSdkPage(namespaced, { kind: 'type', name: 'Client' })).toThrow(
150
+ 'type Client matches legacy.Client, x.legacy.Client'
151
+ );
152
+ });
47
153
  });