Browse Source

fix tests

pull/24/head
Nicolas Beaussart 6 years ago
parent
commit
fb1cace7c8
No known key found for this signature in database GPG Key ID: 51D5A407BFCE64A9
  1. 8
      src/tests/add/prettier.spec.ts
  2. 8
      src/tests/add/tailwind.spec.ts
  3. 2
      src/tests/wall.spec.ts
  4. 27
      src/utls/base-add-command.spec.ts

8
src/tests/add/prettier.spec.ts

@ -4,7 +4,7 @@ import * as prompts from 'prompts';
import * as latestVersion from 'latest-version'; import * as latestVersion from 'latest-version';
import Prettier from '../../commands/add/prettier'; import Prettier from '../../commands/add/prettier';
jest.setTimeout(30000);
jest.setTimeout(90000);
/* eslint-disable no-console,max-nested-callbacks,@typescript-eslint/ban-ts-ignore */ /* eslint-disable no-console,max-nested-callbacks,@typescript-eslint/ban-ts-ignore */
let consoleLogOutput: string[]; let consoleLogOutput: string[];
@ -36,7 +36,11 @@ const initWithConfigAndCommit = async () => {
await system.run('touch yarn.lock'); await system.run('touch yarn.lock');
await system.run('echo node_modules > .gitignore'); await system.run('echo node_modules > .gitignore');
await system.run('git add * .nbxrc .gitignore'); await system.run('git add * .nbxrc .gitignore');
await system.run('git commit -m "init state" --author="Dummy <dummy@noop.noop>"');
try {
await system.run('git config user.email "you@example.com"');
await system.run('git config user.name "Your Name"');
} catch {}
await system.run('git commit -m "init state"');
}; };
describe('prettier', () => { describe('prettier', () => {

8
src/tests/add/tailwind.spec.ts

@ -4,7 +4,7 @@ import * as prompts from 'prompts';
import * as latestVersion from 'latest-version'; import * as latestVersion from 'latest-version';
import Tailwind from '../../commands/add/tailwind'; import Tailwind from '../../commands/add/tailwind';
jest.setTimeout(60000);
jest.setTimeout(90000);
/* eslint-disable no-console,max-nested-callbacks,@typescript-eslint/ban-ts-ignore */ /* eslint-disable no-console,max-nested-callbacks,@typescript-eslint/ban-ts-ignore */
let consoleLogOutput: string[]; let consoleLogOutput: string[];
@ -36,7 +36,11 @@ const initWithConfigAndCommit = async (packageJson = {}) => {
await system.run('touch yarn.lock'); await system.run('touch yarn.lock');
await system.run('echo node_modules > .gitignore'); await system.run('echo node_modules > .gitignore');
await system.run('git add * .nbxrc .gitignore'); await system.run('git add * .nbxrc .gitignore');
await system.run('git commit -m "init state" --author="Dummy <dummy@noop.noop>"');
try {
await system.run('git config user.email "you@example.com"');
await system.run('git config user.name "Your Name"');
} catch {}
await system.run('git commit -m "init state"');
}; };
describe('tailwind', () => { describe('tailwind', () => {

2
src/tests/wall.spec.ts

@ -2,7 +2,7 @@ import { filesystem } from 'gluegun';
import Wall from '../commands/wall'; import Wall from '../commands/wall';
const stripANSI = require('strip-ansi'); const stripANSI = require('strip-ansi');
jest.setTimeout(30000);
jest.setTimeout(90000);
/* eslint-disable no-console,max-nested-callbacks,@typescript-eslint/ban-ts-ignore */ /* eslint-disable no-console,max-nested-callbacks,@typescript-eslint/ban-ts-ignore */
let consoleLogOutput: string[]; let consoleLogOutput: string[];
let execPath: string; let execPath: string;

27
src/utls/base-add-command.spec.ts

@ -54,7 +54,11 @@ const initWithConfigAndCommit = async () => {
filesystem.write('package.json', {}); filesystem.write('package.json', {});
await system.run('touch yarn.lock'); await system.run('touch yarn.lock');
await system.run('git add * .nbxrc'); await system.run('git add * .nbxrc');
await system.run('git commit -m "init state" --author="Dummy <dummy@noop.noop>"');
try {
await system.run('git config user.email "you@example.com"');
await system.run('git config user.name "Your Name"');
} catch {}
await system.run('git commit -m "init state"');
}; };
describe('BaseAddCommand', () => { describe('BaseAddCommand', () => {
@ -124,7 +128,7 @@ describe('BaseAddCommand', () => {
'touch test.md', 'touch test.md',
'git add test.md', 'git add test.md',
'git add .nbxrc', 'git add .nbxrc',
'git commit -m "test commit" --author="Dummy <dummy@noop.noop>"',
'git commit -m "test commit"',
'echo hello > test.md', 'echo hello > test.md',
], ],
}, },
@ -134,7 +138,7 @@ describe('BaseAddCommand', () => {
'touch test.md', 'touch test.md',
'git add test.md', 'git add test.md',
'git add .nbxrc', 'git add .nbxrc',
'git commit -m "test commit" --author="Dummy <dummy@noop.noop>"',
'git commit -m "test commit"',
'rm -f test.md', 'rm -f test.md',
], ],
}, },
@ -144,6 +148,10 @@ describe('BaseAddCommand', () => {
it(`should erro when ${action.name}`, async () => { it(`should erro when ${action.name}`, async () => {
filesystem.write('.nbxrc', { git: { user: 'aaa', email: 'bbb' } }); filesystem.write('.nbxrc', { git: { user: 'aaa', email: 'bbb' } });
await system.run('git init'); await system.run('git init');
try {
await system.run('git config user.email "you@example.com"');
await system.run('git config user.name "Your Name"');
} catch {}
for (const step of action.actions) { for (const step of action.actions) {
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
await system.run(step); await system.run(step);
@ -174,8 +182,11 @@ describe('BaseAddCommand', () => {
filesystem.write('.nbxrc', { git: { user: 'aaa', email: 'bbb' } }); filesystem.write('.nbxrc', { git: { user: 'aaa', email: 'bbb' } });
await system.run('git init'); await system.run('git init');
await system.run('git add .nbxrc'); await system.run('git add .nbxrc');
await system.run('pwd');
await system.run('git commit -m "initial commit" --author="Dummy <dummy@noop.noop>"');
try {
await system.run('git config user.email "you@example.com"');
await system.run('git config user.name "Your Name"');
} catch {}
await system.run('git commit -m "initial commit"');
await system.run('git status'); await system.run('git status');
await RunCommand.run(['initGit']); await RunCommand.run(['initGit']);
const gitConfig = filesystem.read('.git/config'); const gitConfig = filesystem.read('.git/config');
@ -248,7 +259,11 @@ describe('BaseAddCommand', () => {
filesystem.write('.nbxrc', { git: { user: 'aaa', email: 'bbb' } }); filesystem.write('.nbxrc', { git: { user: 'aaa', email: 'bbb' } });
await system.run('touch test.md'); await system.run('touch test.md');
await system.run('git add * .nbxrc'); await system.run('git add * .nbxrc');
await system.run('git commit -m "test" --author="Dummy <dummy@noop.noop>"');
try {
await system.run('git config user.email "you@example.com"');
await system.run('git config user.name "Your Name"');
} catch {}
await system.run('git commit -m "test"');
const before = await system.run('git status -s'); const before = await system.run('git status -s');
await RunCommand.run(['gitAddUnstaged']); await RunCommand.run(['gitAddUnstaged']);

Loading…
Cancel
Save