Skip to content

Commit 8eb2c0a

Browse files
bcomnesclaude
andcommitted
Add unit tests for DomStack constructor copy path resolution
Verifies that relative copy paths are resolved to absolute paths (matching process.cwd()), that already-absolute paths are preserved, and that mixed relative+absolute arrays are both resolved correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c0ca6d6 commit 8eb2c0a

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { test } from 'node:test'
2+
import assert from 'node:assert'
3+
import { isAbsolute } from 'node:path'
4+
import { DomStack } from '../../index.js'
5+
6+
test.describe('DomStack constructor - copy path resolution', () => {
7+
test('resolves a relative copy path to an absolute path', () => {
8+
const ds = new DomStack('/tmp/test-src', '/tmp/test-dest', {
9+
copy: ['some-relative-copy-dir'],
10+
})
11+
12+
assert.strictEqual(ds.opts.copy.length, 1, 'one copy entry')
13+
assert.ok(isAbsolute(ds.opts.copy[0]), `copy path should be absolute, got: "${ds.opts.copy[0]}"`)
14+
})
15+
16+
test('leaves an already-absolute copy path unchanged', () => {
17+
const ds = new DomStack('/tmp/test-src', '/tmp/test-dest', {
18+
copy: ['/absolute/copy/dir'],
19+
})
20+
21+
assert.strictEqual(ds.opts.copy[0], '/absolute/copy/dir', 'absolute path is preserved')
22+
})
23+
24+
test('resolves multiple mixed copy paths', () => {
25+
const ds = new DomStack('/tmp/test-src', '/tmp/test-dest', {
26+
copy: ['relative-dir', '/absolute/dir'],
27+
})
28+
29+
assert.strictEqual(ds.opts.copy.length, 2, 'two copy entries')
30+
for (const p of ds.opts.copy) {
31+
assert.ok(isAbsolute(p), `each copy path should be absolute, got: "${p}"`)
32+
}
33+
})
34+
})

0 commit comments

Comments
 (0)