backend-test-utils: move reusable test failure case (#32388)

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2026-01-20 17:33:48 +01:00
committed by GitHub
parent 07eded33e6
commit 4178587bb2
@@ -271,14 +271,16 @@ describe('createMockDirectory', () => {
});
it('should reject non-child paths', () => {
const path = mockDir.resolve('/root/a.txt');
expect(() => mockDir.setContent({ '/root/a.txt': 'a' })).toThrow(
const pathOutside = createMockDirectory().path;
const path = mockDir.resolve(pathOutside);
expect(() => mockDir.setContent({ [pathOutside]: 'a' })).toThrow(
`Provided path must resolve to a child path of the mock directory, got '${path}'`,
);
expect(() => mockDir.addContent({ '/root/a.txt': 'a' })).toThrow(
expect(() => mockDir.addContent({ [pathOutside]: 'a' })).toThrow(
`Provided path must resolve to a child path of the mock directory, got '${path}'`,
);
expect(() => mockDir.content({ path: '/root/a.txt' })).toThrow(
expect(() => mockDir.content({ path: pathOutside })).toThrow(
`Provided path must resolve to a child path of the mock directory, got '${path}'`,
);
});