test: Add testing for set-tokens.ts (#126)

* test: remove main
* test: add getPublishRepo()
* test: Add setPersonalToken()
* test: Add setGithubToken()
* test: add showInputs()
* test: .nojekyll already exists
* test: ignore jest/expect-expect
* refactor: squash inputs log
* fix: throw error message
This commit is contained in:
Shohei Ueda
2020-03-07 00:41:30 +09:00
committed by GitHub
parent acd0462710
commit fd6e5fc7ce
9 changed files with 306 additions and 106 deletions

View File

@@ -77,8 +77,8 @@ describe('addNoJekyll()', () => {
const filepath = path.join(workDir, '.nojekyll');
await addNoJekyll(workDir, false, 'gh-pages');
const test1 = fs.existsSync(filepath);
expect(test1).toBe(true);
const test = fs.existsSync(filepath);
expect(test).toBe(true);
fs.unlinkSync(filepath);
});
@@ -91,8 +91,23 @@ describe('addNoJekyll()', () => {
const filepath = path.join(workDir, '.nojekyll');
await addNoJekyll(workDir, false, 'master');
const test2 = fs.existsSync(filepath);
expect(test2).toBe(true);
const test = fs.existsSync(filepath);
expect(test).toBe(true);
fs.unlinkSync(filepath);
});
test('.nojekyll already exists', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const filepath = path.join(workDir, '.nojekyll');
fs.closeSync(fs.openSync(filepath, 'w'));
await addNoJekyll(workDir, false, 'master');
const test = fs.existsSync(filepath);
expect(test).toBe(true);
fs.unlinkSync(filepath);
});
@@ -105,8 +120,8 @@ describe('addNoJekyll()', () => {
const filepath = path.join(workDir, '.nojekyll');
await addNoJekyll(workDir, true, 'gh-pages');
const test3 = fs.existsSync(filepath);
expect(test3).toBe(false);
const test = fs.existsSync(filepath);
expect(test).toBe(false);
});
test('not add .nojekyll disable_nojekyll master', async () => {
@@ -117,8 +132,8 @@ describe('addNoJekyll()', () => {
const filepath = path.join(workDir, '.nojekyll');
await addNoJekyll(workDir, true, 'master');
const test4 = fs.existsSync(filepath);
expect(test4).toBe(false);
const test = fs.existsSync(filepath);
expect(test).toBe(false);
});
test('not add .nojekyll other-branch', async () => {
@@ -129,8 +144,8 @@ describe('addNoJekyll()', () => {
const filepath = path.join(workDir, '.nojekyll');
await addNoJekyll(workDir, false, 'other-branch');
const test5 = fs.existsSync(filepath);
expect(test5).toBe(false);
const test = fs.existsSync(filepath);
expect(test).toBe(false);
});
test('not add .nojekyll disable_nojekyll other-branch', async () => {
@@ -141,8 +156,8 @@ describe('addNoJekyll()', () => {
const filepath = path.join(workDir, '.nojekyll');
await addNoJekyll(workDir, true, 'other-branch');
const test6 = fs.existsSync(filepath);
expect(test6).toBe(false);
const test = fs.existsSync(filepath);
expect(test).toBe(false);
});
});
@@ -155,8 +170,8 @@ describe('addCNAME()', () => {
const filepath = path.join(workDir, 'CNAME');
await addCNAME(workDir, 'github.com');
const test1 = fs.readFileSync(filepath, 'utf8');
expect(test1).toMatch('github.com');
const test = fs.readFileSync(filepath, 'utf8');
expect(test).toMatch('github.com');
fs.unlinkSync(filepath);
});
@@ -169,8 +184,8 @@ describe('addCNAME()', () => {
const filepath = path.join(workDir, 'CNAME');
await addCNAME(workDir, '');
const test2 = fs.existsSync(filepath);
expect(test2).toBe(false);
const test = fs.existsSync(filepath);
expect(test).toBe(false);
});
test('CNAME already exists', async () => {
@@ -182,8 +197,8 @@ describe('addCNAME()', () => {
await addCNAME(workDir, 'github.io');
await addCNAME(workDir, 'github.com');
const test3 = fs.readFileSync(filepath, 'utf8');
expect(test3).toMatch('github.io');
const test = fs.readFileSync(filepath, 'utf8');
expect(test).toMatch('github.io');
fs.unlinkSync(filepath);
});