Skip to content

Commit 1a384c3

Browse files
committed
test(nexus): add tests for version filtering in transform method
1 parent 4bbd2cf commit 1a384c3

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

services/nexus/nexus.spec.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,33 @@ describe('Nexus', function () {
4242
})
4343
expect(version).to.equal('1.2.3')
4444
})
45+
46+
it('filters versions and returns highest matching version', function () {
47+
const { version } = Nexus.prototype.transform({
48+
json: {
49+
items: [
50+
{ version: '1.2.3' },
51+
{ version: '1.2.10' },
52+
{ version: '2.0.0' },
53+
],
54+
},
55+
filter: '1.2.*',
56+
})
57+
expect(version).to.equal('1.2.10')
58+
})
59+
60+
it('throws NotFound when filter matches no versions', function () {
61+
try {
62+
Nexus.prototype.transform({
63+
json: { items: [{ version: '1.2.3' }] },
64+
filter: '9.*',
65+
})
66+
expect.fail('Expected to throw')
67+
} catch (e) {
68+
expect(e).to.be.an.instanceof(NotFound)
69+
expect(e.prettyMessage).to.equal('no matching versions found')
70+
}
71+
})
4572
})
4673

4774
describe('auth', function () {

services/nexus/nexus.tester.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ t.create('search release version valid artifact')
99
message: isVersion,
1010
})
1111

12+
t.create('search release version with filter param')
13+
.get(
14+
'/r/me.neznamy/tab-api.json?server=https://repo.tomkeuper.com&filter=4.*.*',
15+
)
16+
.expectBadge({
17+
label: 'nexus',
18+
message: isVersion,
19+
})
20+
1221
t.create('search release version of an nonexistent artifact')
1322
.get(
1423
'/r/me.neznamy/nonexistent-artifact-id.json?server=https://repo.tomkeuper.com',

0 commit comments

Comments
 (0)