Skip to content

Commit e9875d0

Browse files
committed
Add test for absolute path
1 parent 6d05f39 commit e9875d0

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { expect } from "chai";
7+
import { AbsolutePath } from "../../src/packageManager/AbsolutePath";
8+
import { TmpAsset, CreateTmpFile } from "../../src/CreateTmpAsset";
9+
import { join } from "path";
10+
11+
suite(AbsolutePath.name, () => {
12+
let tmpPath: TmpAsset;
13+
14+
setup(async () => {
15+
tmpPath = await CreateTmpFile();
16+
});
17+
18+
teardown(() => {
19+
tmpPath.dispose();
20+
});
21+
22+
test('Throws error when the passed value is not an absolute path', () => {
23+
expect(() => new AbsolutePath("somePath")).to.throw(Error);
24+
});
25+
26+
test(`${AbsolutePath.getAbsolutePath.name}: Returns an absolute path based by resolving the path with the value to prepend`, () => {
27+
let absolutePath = AbsolutePath.getAbsolutePath(tmpPath.name, "somePath");
28+
expect(absolutePath.value).to.be.equal(join(tmpPath.name, "somePath"));
29+
});
30+
});

0 commit comments

Comments
 (0)