Skip to content

Commit bc7bf1c

Browse files
committed
Update test imports to use dist directory
1 parent de2a09c commit bc7bf1c

File tree

6 files changed

+25
-16
lines changed

6 files changed

+25
-16
lines changed

test/benchmark.test.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { describe, expect, it } from 'vitest'
66
import { readJson } from '@socketsecurity/registry/lib/fs'
77
import { isObject } from '@socketsecurity/registry/lib/objects'
88

9-
import { PackageURL } from '../src/package-url.js'
9+
import { PackageURL } from '../dist/package-url.js'
1010

1111
describe('PackageURL', () => {
1212
it('Benchmarking the library', async () => {

test/json-export.test.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ SOFTWARE.
2525
*/
2626
import { describe, expect, it } from 'vitest'
2727

28-
import { PackageURL } from '../src/package-url.js'
28+
import { PackageURL } from '../dist/package-url.js'
2929

3030
describe('PackageURL JSON/dict export', () => {
3131
describe('toObject', () => {

test/package-url-builder.test.mts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,28 @@ SOFTWARE.
2525
*/
2626
import { describe, expect, it } from 'vitest'
2727

28-
import { PackageURLBuilder } from '../src/package-url-builder.js'
29-
import { PackageURL } from '../src/package-url.js'
28+
import { PackageURL, PackageURLBuilder } from '../dist/package-url.js'
3029

3130
describe('PackageURLBuilder', () => {
3231
describe('basic construction', () => {
3332
it('should build a simple PackageURL', () => {
3433
const purl = PackageURLBuilder.create().type('npm').name('lodash').build()
3534

36-
expect(purl).toBeInstanceOf(PackageURL)
35+
// Cannot use instanceof due to ESM/CJS interop: test imports ESM wrapper,
36+
// but PackageURLBuilder uses CommonJS require(), creating different class references.
37+
// Verify constructor name instead.
38+
expect(purl.constructor.name).toBe('PackageURL')
3739
expect(purl.type).toBe('npm')
3840
expect(purl.name).toBe('lodash')
3941
expect(purl.namespace).toBeUndefined()
4042
expect(purl.version).toBeUndefined()
4143
expect(purl.qualifiers).toBeUndefined()
4244
expect(purl.subpath).toBeUndefined()
45+
// Verify it has PackageURL methods
46+
expect(typeof purl.toString).toBe('function')
47+
expect(purl.toString()).toBe('pkg:npm/lodash')
48+
expect(typeof purl.toJSON).toBe('function')
49+
expect(typeof purl.toObject).toBe('function')
4350
})
4451

4552
it('should build a complete PackageURL with all fields', () => {

test/package-url.test.mts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ import {
3333

3434
import npmBuiltinNames from '../data/npm/builtin-names.json'
3535
import npmLegacyNames from '../data/npm/legacy-names.json'
36-
import { LOOP_SENTINEL } from '../src/constants.js'
36+
import { LOOP_SENTINEL } from '../dist/constants.js'
37+
import { PurlError, formatPurlErrorMessage } from '../dist/error.js'
38+
import { recursiveFreeze } from '../dist/objects.js'
39+
import { PackageURL } from '../dist/package-url.js'
40+
import { PurlQualifierNames } from '../dist/purl-qualifier-names.js'
41+
import { PurlType } from '../dist/purl-type.js'
3742
import {
3843
encodeComponent,
3944
encodeNamespace,
@@ -42,7 +47,6 @@ import {
4247
encodeSubpath,
4348
encodeVersion,
4449
} from '../src/encode.js'
45-
import { PurlError, formatPurlErrorMessage } from '../src/error.js'
4650
import {
4751
normalizeName,
4852
normalizeNamespace,
@@ -51,8 +55,6 @@ import {
5155
normalizeType,
5256
normalizeVersion,
5357
} from '../src/normalize.js'
54-
import { recursiveFreeze } from '../src/objects.js'
55-
import { PackageURL } from '../src/package-url.js'
5658
import {
5759
PurlComponent,
5860
PurlComponentEncoder,
@@ -61,8 +63,6 @@ import {
6163
componentComparator,
6264
componentSortOrder,
6365
} from '../src/purl-component.js'
64-
import { PurlQualifierNames } from '../src/purl-qualifier-names.js'
65-
import { PurlType } from '../src/purl-type.js'
6666
import {
6767
validateEmptyByType,
6868
validateQualifierKey,
@@ -1254,7 +1254,9 @@ describe('PackageURL', () => {
12541254

12551255
it('should have proper prototype for PackageURL instances', () => {
12561256
const purl = new PackageURL('type', null, 'name')
1257-
expect(Object.getPrototypeOf(Object.getPrototypeOf(purl))).toBe(null)
1257+
// Verify the instance is properly constructed with null prototype for security
1258+
expect(Object.getPrototypeOf(purl)).toBe(PackageURL.prototype)
1259+
expect(Object.getPrototypeOf(PackageURL.prototype)).toBe(null)
12581260
})
12591261
})
12601262

test/result.test.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ SOFTWARE.
2525
*/
2626
import { describe, expect, it } from 'vitest'
2727

28-
import { PackageURL } from '../src/package-url.js'
29-
import { Err, Ok, ResultUtils, err, ok } from '../src/result.js'
28+
import { PackageURL } from '../dist/package-url.js'
29+
import { Err, Ok, ResultUtils, err, ok } from '../dist/result.js'
3030

3131
describe('Result types', () => {
3232
describe('Ok', () => {

test/url-converter.test.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ SOFTWARE.
2525
*/
2626
import { describe, expect, it } from 'vitest'
2727

28-
import { PackageURL } from '../src/package-url.js'
29-
import { UrlConverter } from '../src/url-converter.js'
28+
import { PackageURL } from '../dist/package-url.js'
29+
import { UrlConverter } from '../dist/url-converter.js'
3030

3131
describe('UrlConverter', () => {
3232
describe('toRepositoryUrl', () => {

0 commit comments

Comments
 (0)