Skip to content

Commit

Permalink
- add new testcase to validate inverse tag resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz authored Feb 29, 2024
1 parent f10242a commit 0ed1caa
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions __tests__/tags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,34 @@ it('Should filter tags correctly using the regex', async () => {

expect(filtered).toStrictEqual(`api-0.0.1,api-0.0.1-rc01,api-10.1.0-2`)
})

it('Should filter tags correctly using the regex (inverse)', async () => {
const tags: TagInfo[] = [
{name: 'api-0.0.1', commit: ''},
{name: 'api-0.0.1-rc01', commit: ''},
{name: 'config-0.1.0', commit: ''},
{name: '0.1.0-b01', commit: ''},
{name: '1.0.0', commit: ''},
{name: '1.0.0-a01', commit: ''},
{name: '2.0.0', commit: ''},
{name: 'ap-10.0.0', commit: ''},
{name: '10.1.0', commit: ''},
{name: 'api-10.1.0-2', commit: ''},
{name: '20.0.2', commit: ''}
]

const tagResolver = {
method: 'non-existing-method',
filter: {
pattern: '^(?!\\w+-)(.+)',
flags: 'gu'
}
}
const filtered = filterTags(tags, tagResolver)
.map(function (tag) {
return tag.name
})
.join(',')

expect(filtered).toStrictEqual(`0.1.0-b01,1.0.0,1.0.0-a01,2.0.0,10.1.0,20.0.2`)
})

0 comments on commit 0ed1caa

Please sign in to comment.