Skip to content

Commit 9d4ddb9

Browse files
committed
test(packages/registry): add tests for SocketRegistry class
- Add 6 tests for empty SocketRegistry class stub - Test class instantiation and constructor - Test instanceof checks and prototype chain - Test independent instance creation - Handle minified class names in production builds - Code coverage: 76.03% → 76.04% (+0.01pp) - Cumulative coverage: 86.37% (maintained)
1 parent ba5c4dc commit 9d4ddb9

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

test/packages/registry.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* @fileoverview Unit tests for Socket Registry class.
3+
*/
4+
5+
import { describe, expect, it } from 'vitest'
6+
7+
import { SocketRegistry } from '@socketsecurity/lib/packages/registry'
8+
9+
describe('packages/registry', () => {
10+
describe('SocketRegistry', () => {
11+
it('should export SocketRegistry class', () => {
12+
expect(typeof SocketRegistry).toBe('function')
13+
})
14+
15+
it('should be instantiable', () => {
16+
const registry = new SocketRegistry()
17+
expect(registry).toBeInstanceOf(SocketRegistry)
18+
})
19+
20+
it('should be a class constructor', () => {
21+
expect(SocketRegistry.prototype).toBeDefined()
22+
expect(SocketRegistry.prototype.constructor).toBe(SocketRegistry)
23+
})
24+
25+
it('should have a name property', () => {
26+
// Note: class name may be minified in production builds
27+
expect(typeof SocketRegistry.name).toBe('string')
28+
expect(SocketRegistry.name.length).toBeGreaterThan(0)
29+
})
30+
31+
it('should create independent instances', () => {
32+
const registry1 = new SocketRegistry()
33+
const registry2 = new SocketRegistry()
34+
expect(registry1).not.toBe(registry2)
35+
expect(registry1).toBeInstanceOf(SocketRegistry)
36+
expect(registry2).toBeInstanceOf(SocketRegistry)
37+
})
38+
39+
it('should support instanceof checks', () => {
40+
const registry = new SocketRegistry()
41+
expect(registry instanceof SocketRegistry).toBe(true)
42+
expect(registry instanceof Object).toBe(true)
43+
})
44+
})
45+
})

0 commit comments

Comments
 (0)