backend-test-utils: move reusable test failure case (#32388)
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -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}'`,
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user