forked from sindresorhus/conduct
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
26 lines (23 loc) · 886 Bytes
/
test.js
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
import fs from 'fs';
import path from 'path';
import test from 'ava';
import execa from 'execa';
import tempy from 'tempy';
const bin = path.join(__dirname, 'cli.js');
const fixture = fs.readFileSync(path.join(__dirname, 'fixtures/code-of-conduct.md'), 'utf8');
test('generate', async t => {
const cwd = tempy.directory();
await execa(bin, ['--email=foo@bar.com'], {cwd});
const src = fs.readFileSync(path.join(cwd, 'code-of-conduct.md'), 'utf8');
t.true(src.includes('In the interest of fostering'));
t.true(src.includes('foo@bar.com'));
});
test('update', async t => {
const cwd = tempy.directory();
const filepath = path.join(cwd, 'CODE_OF_CONDUCT.markdown');
fs.writeFileSync(filepath, fixture);
await execa(bin, {cwd});
const src = fs.readFileSync(filepath, 'utf8');
t.true(src.includes('In the interest of fostering'));
t.true(src.includes('fixture@bar.com'));
});