@vltpkg/query 1.0.0-rc.32 → 1.0.0-rc.34

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.
Files changed (215) hide show
  1. package/dist/index.js +10 -6
  2. package/dist/parser.js +2 -1
  3. package/dist/pseudo/hostname.js +3 -1
  4. package/dist/pseudo/malware.d.ts +3 -16
  5. package/dist/pseudo/malware.js +11 -171
  6. package/dist/pseudo/scripts.js +1 -1
  7. package/dist/pseudo/vuln.d.ts +22 -0
  8. package/dist/pseudo/vuln.js +220 -0
  9. package/dist/pseudo.js +3 -3
  10. package/dist/types.d.ts +3 -2
  11. package/package.json +19 -10
  12. package/skills/dss-query/REFERENCE.md +123 -0
  13. package/skills/dss-query/SKILL.md +190 -0
  14. package/skills/dss-query/evals/README.md +79 -0
  15. package/skills/dss-query/evals/evals.json +89 -0
  16. package/skills/dss-query/evals/grade.mjs +480 -0
  17. package/src/attribute.ts +186 -0
  18. package/src/combinator.ts +132 -0
  19. package/src/id.ts +46 -0
  20. package/src/index.ts +620 -0
  21. package/src/parser.ts +122 -0
  22. package/src/pseudo/abandoned.ts +9 -0
  23. package/src/pseudo/attr.ts +92 -0
  24. package/src/pseudo/built.ts +19 -0
  25. package/src/pseudo/confused.ts +29 -0
  26. package/src/pseudo/cve.ts +93 -0
  27. package/src/pseudo/cwe.ts +97 -0
  28. package/src/pseudo/debug.ts +9 -0
  29. package/src/pseudo/deprecated.ts +9 -0
  30. package/src/pseudo/dev.ts +18 -0
  31. package/src/pseudo/diff.ts +90 -0
  32. package/src/pseudo/dist.ts +144 -0
  33. package/src/pseudo/dynamic.ts +9 -0
  34. package/src/pseudo/empty.ts +15 -0
  35. package/src/pseudo/entropic.ts +9 -0
  36. package/src/pseudo/env.ts +6 -0
  37. package/src/pseudo/eval.ts +9 -0
  38. package/src/pseudo/fs.ts +9 -0
  39. package/src/pseudo/helpers.ts +106 -0
  40. package/src/pseudo/host.ts +111 -0
  41. package/src/pseudo/hostname.ts +156 -0
  42. package/src/pseudo/license.ts +134 -0
  43. package/src/pseudo/link.ts +30 -0
  44. package/src/pseudo/malware.ts +41 -0
  45. package/src/pseudo/minified.ts +9 -0
  46. package/src/pseudo/missing.ts +16 -0
  47. package/src/pseudo/native.ts +9 -0
  48. package/src/pseudo/network.ts +9 -0
  49. package/src/pseudo/obfuscated.ts +9 -0
  50. package/src/pseudo/optional.ts +18 -0
  51. package/src/pseudo/outdated.ts +305 -0
  52. package/src/pseudo/overridden.ts +20 -0
  53. package/src/pseudo/path.ts +146 -0
  54. package/src/pseudo/peer.ts +18 -0
  55. package/src/pseudo/prerelease.ts +47 -0
  56. package/src/pseudo/private.ts +19 -0
  57. package/src/pseudo/prod.ts +18 -0
  58. package/src/pseudo/published.ts +248 -0
  59. package/src/pseudo/registry.ts +29 -0
  60. package/src/pseudo/root.ts +19 -0
  61. package/src/pseudo/scanned.ts +20 -0
  62. package/src/pseudo/score.ts +186 -0
  63. package/src/pseudo/scripts.ts +54 -0
  64. package/src/pseudo/semver.ts +320 -0
  65. package/src/pseudo/severity.ts +231 -0
  66. package/src/pseudo/shell.ts +9 -0
  67. package/src/pseudo/shrinkwrap.ts +9 -0
  68. package/src/pseudo/spec.ts +131 -0
  69. package/src/pseudo/squat.ts +225 -0
  70. package/src/pseudo/suspicious.ts +9 -0
  71. package/src/pseudo/tracker.ts +9 -0
  72. package/src/pseudo/trivial.ts +9 -0
  73. package/src/pseudo/type.ts +26 -0
  74. package/src/pseudo/undesirable.ts +9 -0
  75. package/src/pseudo/unknown.ts +9 -0
  76. package/src/pseudo/unmaintained.ts +9 -0
  77. package/src/pseudo/unpopular.ts +9 -0
  78. package/src/pseudo/unstable.ts +9 -0
  79. package/src/pseudo/vuln.ts +273 -0
  80. package/src/pseudo/workspace.ts +22 -0
  81. package/src/pseudo.ts +413 -0
  82. package/src/types.ts +165 -0
  83. package/tap-snapshots/test/attribute.ts.test.cjs +304 -0
  84. package/tap-snapshots/test/combinator.ts.test.cjs +333 -0
  85. package/tap-snapshots/test/id.ts.test.cjs +118 -0
  86. package/tap-snapshots/test/parser.ts.test.cjs +344 -0
  87. package/tap-snapshots/test/pseudo/abandoned.ts.test.cjs +18 -0
  88. package/tap-snapshots/test/pseudo/attr.ts.test.cjs +161 -0
  89. package/tap-snapshots/test/pseudo/built.ts.test.cjs +70 -0
  90. package/tap-snapshots/test/pseudo/confused.ts.test.cjs +32 -0
  91. package/tap-snapshots/test/pseudo/cve.ts.test.cjs +49 -0
  92. package/tap-snapshots/test/pseudo/cwe.ts.test.cjs +49 -0
  93. package/tap-snapshots/test/pseudo/debug.ts.test.cjs +18 -0
  94. package/tap-snapshots/test/pseudo/deprecated.ts.test.cjs +18 -0
  95. package/tap-snapshots/test/pseudo/dist.ts.test.cjs +30 -0
  96. package/tap-snapshots/test/pseudo/dynamic.ts.test.cjs +18 -0
  97. package/tap-snapshots/test/pseudo/empty.ts.test.cjs +50 -0
  98. package/tap-snapshots/test/pseudo/entropic.ts.test.cjs +18 -0
  99. package/tap-snapshots/test/pseudo/env.ts.test.cjs +18 -0
  100. package/tap-snapshots/test/pseudo/eval.ts.test.cjs +18 -0
  101. package/tap-snapshots/test/pseudo/fs.ts.test.cjs +18 -0
  102. package/tap-snapshots/test/pseudo/helpers.ts.test.cjs +18 -0
  103. package/tap-snapshots/test/pseudo/hostname.ts.test.cjs +148 -0
  104. package/tap-snapshots/test/pseudo/license.ts.test.cjs +41 -0
  105. package/tap-snapshots/test/pseudo/link.ts.test.cjs +36 -0
  106. package/tap-snapshots/test/pseudo/malware.ts.test.cjs +22 -0
  107. package/tap-snapshots/test/pseudo/minified.ts.test.cjs +18 -0
  108. package/tap-snapshots/test/pseudo/missing.ts.test.cjs +30 -0
  109. package/tap-snapshots/test/pseudo/native.ts.test.cjs +18 -0
  110. package/tap-snapshots/test/pseudo/network.ts.test.cjs +18 -0
  111. package/tap-snapshots/test/pseudo/obfuscated.ts.test.cjs +18 -0
  112. package/tap-snapshots/test/pseudo/outdated.ts.test.cjs +130 -0
  113. package/tap-snapshots/test/pseudo/overridden.ts.test.cjs +75 -0
  114. package/tap-snapshots/test/pseudo/prerelease.ts.test.cjs +101 -0
  115. package/tap-snapshots/test/pseudo/private.ts.test.cjs +38 -0
  116. package/tap-snapshots/test/pseudo/published.ts.test.cjs +171 -0
  117. package/tap-snapshots/test/pseudo/registry.ts.test.cjs +68 -0
  118. package/tap-snapshots/test/pseudo/root.ts.test.cjs +24 -0
  119. package/tap-snapshots/test/pseudo/scanned.ts.test.cjs +18 -0
  120. package/tap-snapshots/test/pseudo/score.ts.test.cjs +239 -0
  121. package/tap-snapshots/test/pseudo/scripts.ts.test.cjs +61 -0
  122. package/tap-snapshots/test/pseudo/semver.ts.test.cjs +575 -0
  123. package/tap-snapshots/test/pseudo/severity.ts.test.cjs +95 -0
  124. package/tap-snapshots/test/pseudo/shell.ts.test.cjs +18 -0
  125. package/tap-snapshots/test/pseudo/shrinkwrap.ts.test.cjs +18 -0
  126. package/tap-snapshots/test/pseudo/spec.ts.test.cjs +148 -0
  127. package/tap-snapshots/test/pseudo/squat.ts.test.cjs +129 -0
  128. package/tap-snapshots/test/pseudo/suspicious.ts.test.cjs +18 -0
  129. package/tap-snapshots/test/pseudo/tracker.ts.test.cjs +18 -0
  130. package/tap-snapshots/test/pseudo/trivial.ts.test.cjs +18 -0
  131. package/tap-snapshots/test/pseudo/type.ts.test.cjs +51 -0
  132. package/tap-snapshots/test/pseudo/undesirable.ts.test.cjs +18 -0
  133. package/tap-snapshots/test/pseudo/unknown.ts.test.cjs +18 -0
  134. package/tap-snapshots/test/pseudo/unmaintained.ts.test.cjs +18 -0
  135. package/tap-snapshots/test/pseudo/unpopular.ts.test.cjs +18 -0
  136. package/tap-snapshots/test/pseudo/unstable.ts.test.cjs +18 -0
  137. package/tap-snapshots/test/pseudo/vuln.ts.test.cjs +208 -0
  138. package/tap-snapshots/test/pseudo/vulnerable.ts.test.cjs +20 -0
  139. package/tap-snapshots/test/pseudo/workspace.ts.test.cjs +19 -0
  140. package/tap-snapshots/test/pseudo.ts.test.cjs +1247 -0
  141. package/test/attribute.ts +266 -0
  142. package/test/combinator.ts +168 -0
  143. package/test/fixtures/graph.ts +999 -0
  144. package/test/fixtures/selector.ts +103 -0
  145. package/test/fixtures/types.ts +7 -0
  146. package/test/id.ts +102 -0
  147. package/test/index.ts +1000 -0
  148. package/test/parser.ts +117 -0
  149. package/test/pseudo/abandoned.ts +98 -0
  150. package/test/pseudo/attr.ts +298 -0
  151. package/test/pseudo/built.ts +214 -0
  152. package/test/pseudo/confused.ts +160 -0
  153. package/test/pseudo/cve.ts +249 -0
  154. package/test/pseudo/cwe.ts +255 -0
  155. package/test/pseudo/debug.ts +98 -0
  156. package/test/pseudo/deprecated.ts +98 -0
  157. package/test/pseudo/dev.ts +61 -0
  158. package/test/pseudo/diff.ts +417 -0
  159. package/test/pseudo/dist.ts +215 -0
  160. package/test/pseudo/dynamic.ts +98 -0
  161. package/test/pseudo/empty.ts +108 -0
  162. package/test/pseudo/entropic.ts +101 -0
  163. package/test/pseudo/env.ts +98 -0
  164. package/test/pseudo/eval.ts +98 -0
  165. package/test/pseudo/fs.ts +98 -0
  166. package/test/pseudo/helpers.ts +370 -0
  167. package/test/pseudo/host-context.ts +276 -0
  168. package/test/pseudo/hostname.ts +314 -0
  169. package/test/pseudo/license.ts +265 -0
  170. package/test/pseudo/link.ts +94 -0
  171. package/test/pseudo/malware.ts +184 -0
  172. package/test/pseudo/minified.ts +98 -0
  173. package/test/pseudo/missing.ts +111 -0
  174. package/test/pseudo/native.ts +98 -0
  175. package/test/pseudo/network.ts +98 -0
  176. package/test/pseudo/obfuscated.ts +98 -0
  177. package/test/pseudo/optional.ts +73 -0
  178. package/test/pseudo/outdated.ts +331 -0
  179. package/test/pseudo/overridden.ts +317 -0
  180. package/test/pseudo/path.ts +680 -0
  181. package/test/pseudo/peer.ts +101 -0
  182. package/test/pseudo/prerelease.ts +279 -0
  183. package/test/pseudo/private.ts +108 -0
  184. package/test/pseudo/prod.ts +61 -0
  185. package/test/pseudo/published.ts +557 -0
  186. package/test/pseudo/registry.ts +122 -0
  187. package/test/pseudo/root.ts +66 -0
  188. package/test/pseudo/scanned.ts +78 -0
  189. package/test/pseudo/score.ts +591 -0
  190. package/test/pseudo/scripts.ts +294 -0
  191. package/test/pseudo/semver.ts +822 -0
  192. package/test/pseudo/severity.ts +310 -0
  193. package/test/pseudo/shell.ts +98 -0
  194. package/test/pseudo/shrinkwrap.ts +98 -0
  195. package/test/pseudo/spec.ts +525 -0
  196. package/test/pseudo/squat.ts +565 -0
  197. package/test/pseudo/suspicious.ts +98 -0
  198. package/test/pseudo/tracker.ts +98 -0
  199. package/test/pseudo/trivial.ts +98 -0
  200. package/test/pseudo/type.ts +105 -0
  201. package/test/pseudo/undesirable.ts +98 -0
  202. package/test/pseudo/unknown.ts +98 -0
  203. package/test/pseudo/unmaintained.ts +98 -0
  204. package/test/pseudo/unpopular.ts +98 -0
  205. package/test/pseudo/unstable.ts +98 -0
  206. package/test/pseudo/vuln.ts +625 -0
  207. package/test/pseudo/vulnerable.ts +137 -0
  208. package/test/pseudo/workspace.ts +111 -0
  209. package/test/pseudo.ts +558 -0
  210. package/tsconfig.json +3 -0
  211. package/tsconfig.publish.json +19 -0
  212. package/tsconfig.publish.tsbuildinfo +1 -0
  213. package/typedoc.mjs +2 -0
  214. package/dist/pseudo/vulnerable.d.ts +0 -8
  215. package/dist/pseudo/vulnerable.js +0 -17
@@ -0,0 +1,73 @@
1
+ import t from 'tap'
2
+ import { pseudo } from '../../src/pseudo.ts'
3
+ import {
4
+ selectorFixture,
5
+ copyGraphSelectionState,
6
+ } from '../fixtures/selector.ts'
7
+ import { getSimpleGraph } from '../fixtures/graph.ts'
8
+ import type { TestCase } from '../fixtures/types.ts'
9
+ import type { GraphSelectionState } from '../../src/types.ts'
10
+
11
+ const testPseudo = selectorFixture(pseudo)
12
+
13
+ t.test(':optional pseudo-selector', async t => {
14
+ // Get a simple graph for testing
15
+ const simpleGraph = getSimpleGraph()
16
+
17
+ // Get the full selection state
18
+ const all = {
19
+ edges: new Set(simpleGraph.edges),
20
+ nodes: new Set(simpleGraph.nodes.values()),
21
+ }
22
+
23
+ // Create an empty selection state
24
+ const empty: GraphSelectionState = {
25
+ edges: new Set(),
26
+ nodes: new Set(),
27
+ }
28
+
29
+ // Run tests in the same pattern as the main pseudo.ts tests
30
+ const queryToExpected = new Set<TestCase>([
31
+ [':optional', all, ['f']], // Should return optional dependencies
32
+ [':optional', empty, []], // Empty input should return empty output
33
+ ])
34
+
35
+ const initial = copyGraphSelectionState(all)
36
+ for (const [query, partial, expected] of queryToExpected) {
37
+ const result = await testPseudo(
38
+ query,
39
+ initial,
40
+ copyGraphSelectionState(partial),
41
+ )
42
+
43
+ t.strictSame(
44
+ result.nodes.map(i => i.name),
45
+ expected,
46
+ `query > "${query}"`,
47
+ )
48
+
49
+ // Verify all edges have type 'optional' if any
50
+ const edgeArray = [...result.edges]
51
+ if (edgeArray.length > 0) {
52
+ for (const edge of edgeArray) {
53
+ t.equal(
54
+ edge.type,
55
+ 'optional',
56
+ `edge ${edge.name} should be of type 'optional'`,
57
+ )
58
+ }
59
+ }
60
+
61
+ // Verify all nodes have optional property if any
62
+ const nodeArray = [...result.nodes]
63
+ if (nodeArray.length > 0) {
64
+ for (const node of nodeArray) {
65
+ t.ok(
66
+ node.optional ||
67
+ [...node.edgesIn].some(e => e.type === 'optional'),
68
+ `node ${node.name} should be optional or connected by optional edge`,
69
+ )
70
+ }
71
+ }
72
+ }
73
+ })
@@ -0,0 +1,331 @@
1
+ import t from 'tap'
2
+ import { joinDepIDTuple } from '@vltpkg/dep-id'
3
+ import { parse, asPostcssNodeWithChildren } from '@vltpkg/dss-parser'
4
+ import {
5
+ outdated,
6
+ parseInternals,
7
+ queueNode,
8
+ retrieveRemoteVersions,
9
+ } from '../../src/pseudo/outdated.ts'
10
+ import {
11
+ getSemverRichGraph,
12
+ getSimpleGraph,
13
+ } from '../fixtures/graph.ts'
14
+ import type { NodeLike } from '@vltpkg/types'
15
+ import type { SpecOptions } from '@vltpkg/spec'
16
+ import type { ParserState } from '../../src/types.ts'
17
+
18
+ // the `npm` alias is no longer built in; configure it so the
19
+ // default-registry DepIDs hydrate to the npm registry URL. Typed as
20
+ // SpecOptions so the surrounding `as NodeLike` casts stay valid.
21
+ const npmSpecOptions: SpecOptions = {
22
+ registries: { npm: 'https://registry.npmjs.org/' },
23
+ }
24
+
25
+ global.fetch = (async (url: string) => {
26
+ if (url === 'https://registry.npmjs.org/h') {
27
+ return {
28
+ ok: false,
29
+ }
30
+ } else if (url === 'https://registry.npmjs.org/i') {
31
+ throw new Error('ERR')
32
+ } else if (url === 'https://registry.npmjs.org/c') {
33
+ return {
34
+ status: 404,
35
+ ok: false,
36
+ }
37
+ }
38
+ return {
39
+ ok: true,
40
+ json: async () => {
41
+ switch (url) {
42
+ case 'https://registry.npmjs.org/a': {
43
+ return {
44
+ versions: {
45
+ '1.0.0': {},
46
+ '2.0.0': {},
47
+ '3.0.0': {},
48
+ },
49
+ }
50
+ }
51
+ case 'https://registry.npmjs.org/b': {
52
+ return {
53
+ versions: {
54
+ '1.0.0': {},
55
+ '2.0.0': {},
56
+ '2.1.0': {},
57
+ '2.2.0': {},
58
+ },
59
+ }
60
+ }
61
+ case 'http://example.com/c': {
62
+ return {
63
+ versions: {
64
+ '3.0.0': {},
65
+ '3.4.0': {},
66
+ '4.0.0': {},
67
+ '5.0.0': {},
68
+ },
69
+ }
70
+ }
71
+ case 'https://registry.npmjs.org/d': {
72
+ return {
73
+ versions: {
74
+ '1.0.0': {},
75
+ '1.2.0': {},
76
+ '2.3.4': {},
77
+ '2.3.5': {},
78
+ },
79
+ }
80
+ }
81
+ case 'https://registry.npmjs.org/e': {
82
+ return {
83
+ versions: {
84
+ '120.0.0': {},
85
+ '120.1.0': {},
86
+ '121.0.0': {},
87
+ '122.0.0': {},
88
+ },
89
+ }
90
+ }
91
+ case 'https://registry.npmjs.org/f': {
92
+ return {
93
+ versions: {
94
+ '4.0.0': {},
95
+ '4.5.6': {},
96
+ },
97
+ }
98
+ }
99
+ case 'https://registry.npmjs.org/g': {
100
+ return {
101
+ versions: {
102
+ '1.2.3-rc.1+rev.1': {},
103
+ '1.2.3-rc.1+rev.2': {},
104
+ '1.2.3-rc.2+rev.3': {},
105
+ '1.2.3-rc.3+rev.4': {},
106
+ },
107
+ }
108
+ }
109
+ }
110
+ },
111
+ }
112
+ }) as unknown as typeof global.fetch
113
+
114
+ const getState = (query: string, graph = getSemverRichGraph()) => {
115
+ const ast = parse(query)
116
+ const current = asPostcssNodeWithChildren(ast.first.first)
117
+ const state: ParserState = {
118
+ comment: '',
119
+ current,
120
+ initial: {
121
+ edges: new Set(graph.edges.values()),
122
+ nodes: new Set(graph.nodes.values()),
123
+ },
124
+ partial: {
125
+ edges: new Set(graph.edges.values()),
126
+ nodes: new Set(graph.nodes.values()),
127
+ },
128
+ collect: {
129
+ edges: new Set(),
130
+ nodes: new Set(),
131
+ },
132
+ cancellable: async () => {},
133
+ walk: async i => i,
134
+ retries: 0,
135
+ securityArchive: undefined,
136
+ importers: new Set(graph.importers),
137
+ signal: new AbortController().signal,
138
+ specificity: { idCounter: 0, commonCounter: 0 },
139
+ }
140
+ return state
141
+ }
142
+
143
+ t.test('select from outdated definition', async t => {
144
+ await t.test('outdated as an element', async t => {
145
+ const res = await outdated(getState(':outdated'))
146
+ t.strictSame(
147
+ [...res.partial.nodes].map(n => n.name),
148
+ ['a', 'c', 'd', 'e', 'g', 'e'],
149
+ 'should have expected result using outdated defaulting to "any"',
150
+ )
151
+ t.matchSnapshot({
152
+ nodes: [...res.partial.nodes].map(n => n.name),
153
+ edges: [...res.partial.edges].map(e => e.name),
154
+ })
155
+ })
156
+
157
+ await t.test('outdated kind any', async t => {
158
+ const res = await outdated(getState(':outdated(any)'))
159
+ t.strictSame(
160
+ [...res.partial.nodes].map(n => n.name),
161
+ ['a', 'c', 'd', 'e', 'g', 'e'],
162
+ 'should have expected result using outdated kind "any"',
163
+ )
164
+ t.matchSnapshot({
165
+ nodes: [...res.partial.nodes].map(n => n.name),
166
+ edges: [...res.partial.edges].map(e => e.name),
167
+ })
168
+ })
169
+
170
+ await t.test('outdated kind major', async t => {
171
+ const res = await outdated(getState(':outdated(major)'))
172
+ t.strictSame(
173
+ [...res.partial.nodes].map(n => n.name),
174
+ ['a', 'c', 'e', 'e'],
175
+ 'should have expected result using outdated kind "major"',
176
+ )
177
+ t.matchSnapshot({
178
+ nodes: [...res.partial.nodes].map(n => n.name),
179
+ edges: [...res.partial.edges].map(e => e.name),
180
+ })
181
+ })
182
+
183
+ await t.test('outdated kind minor', async t => {
184
+ const res = await outdated(getState(':outdated("minor")'))
185
+ t.strictSame(
186
+ [...res.partial.nodes].map(n => n.name),
187
+ ['e'],
188
+ 'should have expected result using outdated kind "minor"',
189
+ )
190
+ t.matchSnapshot({
191
+ nodes: [...res.partial.nodes].map(n => n.name),
192
+ edges: [...res.partial.edges].map(e => e.name),
193
+ })
194
+ })
195
+
196
+ await t.test('outdated kind patch', async t => {
197
+ const res = await outdated(getState(':outdated("patch")'))
198
+ t.strictSame(
199
+ [...res.partial.nodes].map(n => n.name),
200
+ ['d'],
201
+ 'should have expected result using outdated kind "patch"',
202
+ )
203
+ t.matchSnapshot({
204
+ nodes: [...res.partial.nodes].map(n => n.name),
205
+ edges: [...res.partial.edges].map(e => e.name),
206
+ })
207
+ })
208
+
209
+ await t.test('outdated kind in-range', async t => {
210
+ const res = await outdated(getState(':outdated(in-range)'))
211
+ t.strictSame(
212
+ [...res.partial.nodes].map(n => n.name),
213
+ ['c', 'e'],
214
+ 'should have expected result using outdated kind "in-range"',
215
+ )
216
+ t.matchSnapshot({
217
+ nodes: [...res.partial.nodes].map(n => n.name),
218
+ edges: [...res.partial.edges].map(e => e.name),
219
+ })
220
+ })
221
+
222
+ await t.test('outdated kind out-of-range', async t => {
223
+ const res = await outdated(getState(':outdated(out-of-range)'))
224
+ t.strictSame(
225
+ [...res.partial.nodes].map(n => n.name),
226
+ ['a', 'd', 'g', 'e'],
227
+ 'should have expected result using outdated kind "out-of-range"',
228
+ )
229
+ t.matchSnapshot({
230
+ nodes: [...res.partial.nodes].map(n => n.name),
231
+ edges: [...res.partial.edges].map(e => e.name),
232
+ })
233
+ })
234
+
235
+ await t.test('invalid pseudo selector usage', async t => {
236
+ await t.rejects(
237
+ outdated(getState(':outdated(foo)')),
238
+ /Failed to parse :outdated selector/,
239
+ 'should throw an error for invalid pseudo selector usage',
240
+ )
241
+ })
242
+
243
+ await t.test('missing package response', async t => {
244
+ const log = t.capture(console, 'warn').args
245
+ const res = await outdated(
246
+ getState(':outdated(any)', getSimpleGraph()),
247
+ )
248
+ // mind this is a different graph that is being asserted,
249
+ // as manifests differs so are the results here
250
+ t.strictSame(
251
+ [...res.partial.nodes].map(n => n.name),
252
+ ['a', 'b', 'e', 'f'],
253
+ 'should have expected results still',
254
+ )
255
+ t.matchSnapshot(
256
+ log(),
257
+ 'should log a warning for missing package response',
258
+ )
259
+ })
260
+ })
261
+
262
+ t.test('parseInternals', async t => {
263
+ const ast = parse(':outdated(any)')
264
+ const nodes = asPostcssNodeWithChildren(ast.first.first).nodes
265
+ const internals = parseInternals(nodes)
266
+ t.strictSame(
267
+ internals,
268
+ { kind: 'any' },
269
+ 'should correctly parse internals from outdated selector',
270
+ )
271
+ })
272
+
273
+ t.test('invalid outdated kind', async t => {
274
+ const ast = parse(':outdated(unsupported)')
275
+ const nodes = asPostcssNodeWithChildren(ast.first.first).nodes
276
+ t.throws(
277
+ () => parseInternals(nodes),
278
+ /Expected a valid outdated kind/,
279
+ 'should throw an error for invalid outdated kind',
280
+ )
281
+ })
282
+
283
+ t.test('retrieveRemoveVersions', async t => {
284
+ t.capture(console, 'warn')
285
+
286
+ const missingName = {
287
+ id: joinDepIDTuple(['registry', '', 'a@1.0.0']),
288
+ } as NodeLike
289
+ t.strictSame(
290
+ await retrieveRemoteVersions(missingName),
291
+ [],
292
+ 'should return an empty array if missing essential info',
293
+ )
294
+
295
+ await t.test('no response from registry', async t => {
296
+ const missingName = {
297
+ name: 'h',
298
+ id: joinDepIDTuple(['registry', '', 'h@1.0.0']),
299
+ options: npmSpecOptions,
300
+ } as NodeLike
301
+ await t.rejects(
302
+ retrieveRemoteVersions(missingName),
303
+ /Failed to fetch packument/,
304
+ 'should throw an internal error so that it may be retried',
305
+ )
306
+ })
307
+
308
+ await t.test('fetch error', async t => {
309
+ const missingName = {
310
+ name: 'i',
311
+ id: joinDepIDTuple(['registry', '', 'i@1.0.0']),
312
+ options: npmSpecOptions,
313
+ } as NodeLike
314
+ await t.rejects(
315
+ retrieveRemoteVersions(missingName),
316
+ /ERR/,
317
+ 'should throw the original error that will be retried',
318
+ )
319
+ })
320
+ })
321
+
322
+ t.test('queueNode', async t => {
323
+ const missingName = {
324
+ id: joinDepIDTuple(['registry', '', 'a@1.0.0']),
325
+ } as NodeLike
326
+ t.strictSame(
327
+ await queueNode(getState(':outdated(any)'), missingName, 'any'),
328
+ missingName,
329
+ 'should return an empty array if missing essential info',
330
+ )
331
+ })