2019-12-22 14:05:15 +00:00
|
|
|
import path from 'path';
|
2020-01-07 21:26:15 +00:00
|
|
|
import fs from 'fs';
|
2019-12-22 14:05:15 +00:00
|
|
|
import Action from './action';
|
|
|
|
|
|
|
|
describe('Action', () => {
|
|
|
|
describe('compatibility check', () => {
|
2022-01-25 21:18:15 +00:00
|
|
|
it('throws for anything other than linux or windows', () => {
|
|
|
|
if (process.platform !== 'linux' && process.platform !== 'win32') {
|
2019-12-22 14:05:15 +00:00
|
|
|
expect(() => Action.checkCompatibility()).toThrow();
|
|
|
|
} else {
|
|
|
|
expect(() => Action.checkCompatibility()).not.toThrow();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('returns the root folder of the action', () => {
|
2021-03-13 23:44:01 +00:00
|
|
|
const { rootFolder, canonicalName } = Action;
|
2019-12-22 14:05:15 +00:00
|
|
|
|
2021-03-13 23:44:01 +00:00
|
|
|
expect(path.basename(rootFolder)).toStrictEqual(canonicalName);
|
2020-01-07 21:26:15 +00:00
|
|
|
expect(fs.existsSync(rootFolder)).toStrictEqual(true);
|
|
|
|
});
|
|
|
|
|
2020-02-01 19:21:22 +00:00
|
|
|
it('returns the action folder', () => {
|
|
|
|
const { actionFolder } = Action;
|
2020-01-07 21:26:15 +00:00
|
|
|
|
2021-03-13 23:44:01 +00:00
|
|
|
expect(path.basename(actionFolder)).toStrictEqual('dist');
|
2020-02-01 19:21:22 +00:00
|
|
|
expect(fs.existsSync(actionFolder)).toStrictEqual(true);
|
2020-01-07 21:26:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('returns the docker file', () => {
|
|
|
|
const { dockerfile } = Action;
|
|
|
|
|
|
|
|
expect(path.basename(dockerfile)).toStrictEqual('Dockerfile');
|
|
|
|
expect(fs.existsSync(dockerfile)).toStrictEqual(true);
|
2019-12-22 14:05:15 +00:00
|
|
|
});
|
|
|
|
});
|