forked from maxim-lobanov/setup-xcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxcode-version-file.test.ts
34 lines (29 loc) · 1.12 KB
/
xcode-version-file.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import fs from "fs";
import os from "os";
import path from "path";
import * as xcodeVersionFile from "../src/xcode-version-file";
describe("getXcodeVersionFromDotFile", () => {
let tmpDirPath: string
beforeEach(() => {
tmpDirPath = fs.mkdtempSync(path.join(os.tmpdir(), "test-"));
});
afterEach(() => {
fs.rmSync(tmpDirPath, { recursive: true, force: true });
});
it("reads the version from .xcode-version file at root of workspace", () => {
const envMock = {
'GITHUB_WORKSPACE': tmpDirPath
};
const version = "1.0";
fs.writeFileSync(path.join(tmpDirPath, ".xcode-version"), version);
const xcodeVersion = xcodeVersionFile.getXcodeVersionFromDotFile(envMock);
expect(xcodeVersion).toBe(version);
});
it("returns undefined if the .xcode-version file does not exist", () => {
const envMock = {
'GITHUB_WORKSPACE': path.join(tmpDirPath, "non-existing-directory")
};
const xcodeVersion = xcodeVersionFile.getXcodeVersionFromDotFile(envMock);
expect(xcodeVersion).toBeUndefined();
});
});