Skip to content

Commit b569b70

Browse files
authored
test: reorganise npm unit tests (#876)
1 parent 4124003 commit b569b70

File tree

3 files changed

+29
-53
lines changed

3 files changed

+29
-53
lines changed

test/unit/app/utils/npm.spec.ts

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { describe, expect, it } from 'vitest'
2+
3+
import { buildScopeTeam } from '../../../../../app/utils/npm/common'
4+
import { validateScopeTeam } from '../../../../../cli/src/npm-client'
5+
6+
describe('buildScopeTeam', () => {
7+
it('constructs scope:team with @ prefix', () => {
8+
expect(buildScopeTeam('netlify', 'developers')).toBe('@netlify:developers')
9+
expect(buildScopeTeam('nuxt', 'core')).toBe('@nuxt:core')
10+
})
11+
12+
it('strips existing @ prefix from orgName', () => {
13+
expect(buildScopeTeam('@netlify', 'developers')).toBe('@netlify:developers')
14+
expect(buildScopeTeam('@nuxt', 'core')).toBe('@nuxt:core')
15+
})
16+
17+
it('produces format accepted by validateScopeTeam', () => {
18+
expect(() => validateScopeTeam(buildScopeTeam('netlify', 'developers'))).not.toThrow()
19+
expect(() => validateScopeTeam(buildScopeTeam('nuxt', 'core'))).not.toThrow()
20+
expect(() => validateScopeTeam(buildScopeTeam('my-org', 'my-team'))).not.toThrow()
21+
})
22+
})

test/unit/shared/utils/spdx.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,25 @@ describe('spdx utilities', () => {
2525
})
2626

2727
describe('getSpdxLicenseUrl', () => {
28-
it('returns URL for valid SPDX licenses', () => {
28+
it('returns URL for valid license identifiers', () => {
2929
expect(getSpdxLicenseUrl('MIT')).toBe('https://spdx.org/licenses/MIT.html')
30+
expect(getSpdxLicenseUrl('ISC')).toBe('https://spdx.org/licenses/ISC.html')
3031
expect(getSpdxLicenseUrl('Apache-2.0')).toBe('https://spdx.org/licenses/Apache-2.0.html')
32+
expect(getSpdxLicenseUrl('GPL-3.0-only')).toBe('https://spdx.org/licenses/GPL-3.0-only.html')
33+
expect(getSpdxLicenseUrl('BSD-2-Clause')).toBe('https://spdx.org/licenses/BSD-2-Clause.html')
34+
expect(getSpdxLicenseUrl('GPL-3.0+')).toBe('https://spdx.org/licenses/GPL-3.0+.html')
3135
})
3236

3337
it('returns null for invalid licenses', () => {
3438
expect(getSpdxLicenseUrl('CustomLicense')).toBeNull()
3539
expect(getSpdxLicenseUrl('INVALID')).toBeNull()
40+
expect(getSpdxLicenseUrl('MIT OR Apache-2.0')).toBeNull()
3641
})
3742

3843
it('returns null for undefined or empty', () => {
3944
expect(getSpdxLicenseUrl(undefined)).toBeNull()
4045
expect(getSpdxLicenseUrl('')).toBeNull()
46+
expect(getSpdxLicenseUrl(' ')).toBeNull()
4147
})
4248

4349
it('trims whitespace', () => {

0 commit comments

Comments
 (0)