mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
More tests
This commit is contained in:
parent
f157d8c731
commit
712ece2f34
39
__tests__/git.test.ts
Normal file
39
__tests__/git.test.ts
Normal file
@ -0,0 +1,39 @@
|
||||
process.env["INPUT_FOLDER"] = "build";
|
||||
|
||||
import { execute } from "../src/util";
|
||||
import { init } from "../src/git";
|
||||
import {action} from '../src/constants'
|
||||
|
||||
jest.mock("../src/constants", () => ({
|
||||
build: 'dist',
|
||||
action: {
|
||||
pusher: {
|
||||
name: 'montezuma',
|
||||
email: 'best@cat',
|
||||
},
|
||||
gitHubToken: 'exists',
|
||||
}
|
||||
}));
|
||||
|
||||
jest.mock("../src/util", () => ({
|
||||
execute: jest.fn()
|
||||
}));
|
||||
|
||||
jest.mock("@actions/io", () => ({
|
||||
cp: jest.fn()
|
||||
}));
|
||||
|
||||
describe("git", () => {
|
||||
describe("init", () => {
|
||||
it("should execute three commands", async () => {
|
||||
|
||||
await init();
|
||||
|
||||
expect(execute).toBeCalledTimes(3);
|
||||
});
|
||||
|
||||
it("should fail if the dpeloyment folder begins with /", async () => {
|
||||
// TODO:
|
||||
})
|
||||
});
|
||||
});
|
@ -5,7 +5,9 @@ jest.mock('@actions/exec', () => ({
|
||||
exec: jest.fn()
|
||||
}))
|
||||
|
||||
test('util - execute - should be called with the correct arguements', async() => {
|
||||
describe('util', () => {
|
||||
describe('execute', () => {
|
||||
it('should be called with the correct arguements', async() => {
|
||||
await execute('echo Montezuma', './')
|
||||
|
||||
expect(exec).toBeCalledWith(
|
||||
@ -16,4 +18,6 @@ test('util - execute - should be called with the correct arguements', async() =>
|
||||
}
|
||||
}
|
||||
)
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
@ -8,10 +8,7 @@ import { workspace, build, action, repositoryPath } from "./constants";
|
||||
*/
|
||||
export async function init(): Promise<any> {
|
||||
try {
|
||||
const accessToken = core.getInput("ACCESS_TOKEN");
|
||||
const gitHubToken = core.getInput("GITHUB_TOKEN");
|
||||
|
||||
if (!accessToken && !gitHubToken) {
|
||||
if (!action.accessToken && !action.gitHubToken) {
|
||||
core.setFailed(
|
||||
"You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy."
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user