forked from petersalomonsen/wasm-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
revert.spec.js
40 lines (30 loc) · 1.29 KB
/
revert.spec.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { lgPromise } from './common.js';
import assert from 'assert';
describe('git revert', () => {
it('should revert commit', async () => {
const lg = await lgPromise;
const FS = lg.FS;
FS.mkdir('/memfs');
FS.mount(lg.MEMFS, { root: '.' }, '/memfs');
FS.chdir('/memfs');
FS.writeFile('/home/web_user/.gitconfig', '[user]\n' +
'name = Test User\n' +
'email = [email protected]');
FS.mkdir('testrevert');
FS.chdir('testrevert');
lg.callMain(['init', '.']);
FS.writeFile('test.txt', 'text 1');
lg.callMain(['add', 'test.txt']);
lg.callMain(['commit', '-m', 'test commit']);
assert.equal(FS.readFile('test.txt', { encoding: 'utf8' }), 'text 1');
FS.writeFile('test.txt', 'text 2');
lg.callMain(['add', 'test.txt']);
lg.callMain(['commit', '-m', 'test commit 2']);
lg.callMain(['revert', 'HEAD']);
assert.equal(FS.readFile('test.txt', { encoding: 'utf8' }), 'text 1',
'expecting file content to be reverted');
assert.match(lg.callWithOutput(['status']),/modified:\s+test.txt/);
lg.callMain(['commit', '-m', 'reverted to commit 1']);
assert.equal(lg.callWithOutput(['status']),'# On branch master');
});
});