-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(arborist): allow for selectors and function names with :semver p…
…seudo selector
- Loading branch information
Showing
2 changed files
with
218 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,9 @@ t.test('query-selector-all', async t => { | |
name: 'abbrev', | ||
version: '1.1.1', | ||
license: 'ISC', | ||
engines: { | ||
node: '^16.0.0', | ||
}, | ||
}), | ||
}, | ||
b: t.fixture('symlink', '../b'), | ||
|
@@ -62,6 +65,9 @@ t.test('query-selector-all', async t => { | |
dependencies: { | ||
moo: '3.0.0', | ||
}, | ||
engines: { | ||
node: '>= 14.0.0', | ||
}, | ||
arbitrary: { | ||
foo: [ | ||
false, | ||
|
@@ -89,6 +95,10 @@ t.test('query-selector-all', async t => { | |
scripts: { | ||
test: 'tap', | ||
}, | ||
engines: { | ||
// intentionally invalid range | ||
node: 'nope', | ||
}, | ||
}), | ||
}, | ||
foo: { | ||
|
@@ -254,6 +264,18 @@ t.test('query-selector-all', async t => { | |
'should throw in invalid selector' | ||
) | ||
|
||
t.rejects( | ||
q(tree, ':semver(1.0.0, [version], eqqq)'), | ||
{ code: 'EQUERYINVALIDOPERATOR' }, | ||
'should throw on invalid semver operator' | ||
) | ||
|
||
t.rejects( | ||
q(tree, ':semver(nope)'), | ||
{ code: 'EQUERYINVALIDSEMVER' }, | ||
'should throw on invalid semver value' | ||
) | ||
|
||
// :scope pseudo | ||
const [nodeFoo] = await q(tree, '#foo') | ||
const scopeRes = await querySelectorAll(nodeFoo, ':scope') | ||
|
@@ -559,6 +581,92 @@ t.test('query-selector-all', async t => { | |
]], | ||
[':semver(=1.4.0)', ['[email protected]']], | ||
[':semver(1.4.0 || 2.2.2)', ['[email protected]', '[email protected]']], | ||
[':semver(^16.0.0, :attr(engines, [node]))', ['[email protected]', '[email protected]']], | ||
[':semver(18.0.0, :attr(engines, [node]))', ['[email protected]']], | ||
[':semver(^16.0.0, :attr(engines, [node^=">="]))', ['[email protected]']], | ||
[':semver(3.0.0, [version], eq)', ['[email protected]']], | ||
[':semver(^3.0.0, [version], eq)', []], | ||
[':semver(1.0.0, [version], neq)', [ | ||
'@npmcli/[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
]], | ||
[':semver(^1.0.0, [version], neq)', []], | ||
[':semver(2.0.0, [version], gt)', ['[email protected]', '[email protected]']], | ||
[':semver(^2.0.0, [version], gt)', []], | ||
[':semver(2.0.0, [version], gte)', [ | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
]], | ||
[':semver(^2.0.0, [version], gte)', []], | ||
[':semver(1.1.1, [version], lt)', [ | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'ipsum@npm:[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
]], | ||
[':semver(^1.1.1, [version], lt)', []], | ||
[':semver(1.1.1, [version], lte)', [ | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'ipsum@npm:[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
]], | ||
[':semver(^1.1.1, [version], lte)', []], | ||
[':semver(^14.0.0, :attr(engines, [node]), intersects)', ['[email protected]']], | ||
[':semver(>=14, :attr(engines, [node]), subset)', ['[email protected]', '[email protected]']], | ||
[':semver(^2.0.0, [version], gtr)', ['[email protected]']], | ||
[':semver(^2.0.0, :attr(engines, [node]), gtr)', []], | ||
[':semver(20.0.0, :attr(engines, [node]), gtr)', ['[email protected]']], | ||
[':semver(1.0.1, [version], gtr)', [ | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'ipsum@npm:[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
]], | ||
[':semver(^1.1.1, [version], ltr)', [ | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'ipsum@npm:[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
]], | ||
[':semver(^1.1.1, :attr(engines, [node]), ltr)', []], | ||
[':semver(0.0.1, :attr(engines, [node]), ltr)', ['[email protected]', '[email protected]']], | ||
[':semver(1.1.1, [version], ltr)', [ | ||
'@npmcli/[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
]], | ||
|
||
// attr pseudo | ||
[':attr([name=dasher])', ['[email protected]']], | ||
|