Skip to content

Commit

Permalink
updates to new ava syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
thisconnect committed Apr 28, 2016
1 parent 18f4992 commit 9eb8e07
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 61 deletions.
18 changes: 9 additions & 9 deletions test/test-commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ test.serial('commit three times', function(t){
});
})
.then(function(oid){
t.ok(oid, 'has oid');
t.ok(oid.toString().length == 40, 'oid has 40 bytes');
t.truthy(oid, 'has oid');
t.truthy(oid.toString().length == 40, 'oid has 40 bytes');
return files.writeFile(filepath, 'test2\n');
})
.then(function(){
Expand Down Expand Up @@ -59,7 +59,7 @@ test.serial('commit log', function(t){
sort: 'time'
})
.then(function(history){
t.ok(Array.isArray(history), 'has history');
t.truthy(Array.isArray(history), 'has history');
t.is(history.length, 4, 'has 4 commits');
t.is(history.pop().message, 'initial commit', 'last entry is initial commit');
});
Expand All @@ -78,7 +78,7 @@ test.serial('commit nothing', function(t){
return git.log(repo);
})
.then(function(history){
t.ok(Array.isArray(history), 'has history');
t.truthy(Array.isArray(history), 'has history');
t.is(history.length, 4, 'still 4 commits');
});
})
Expand All @@ -96,7 +96,7 @@ test.serial('commit test log --abbrev-commit', function(t){
'abbrev-commit': true
})
.catch(function(error){
t.ok(error instanceof Error, 'has Error');
t.truthy(error instanceof Error, 'has Error');
var msg = 'Config value \'core.abbrev\' was not found';
t.is(error.message, msg, msg);
})
Expand All @@ -107,8 +107,8 @@ test.serial('commit test log --abbrev-commit', function(t){
});
})
.then(function(history){
t.ok(history.length > 3, 'has commits');
t.ok(history.every(function(entry){
t.truthy(history.length > 3, 'has commits');
t.truthy(history.every(function(entry){
return entry.commit.length == 6;
}), 'every id has length of 6');
})
Expand All @@ -123,8 +123,8 @@ test.serial('commit test log --abbrev-commit', function(t){
});
})
.then(function(history){
t.ok(history.length > 3, 'has commits');
t.ok(history.every(function(entry){
t.truthy(history.length > 3, 'has commits');
t.truthy(history.every(function(entry){
return entry.commit.length == 9;
}), 'every id has length of 9');
});
Expand Down
50 changes: 25 additions & 25 deletions test/test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test.serial('config test init with local user', function(t){
return git.init.commit(repo);
})
.then(function(oid){
t.ok(oid, 'has oid');
t.truthy(oid, 'has oid');

return repo.getMasterCommit()
.then(function(master){
Expand All @@ -49,10 +49,10 @@ test.serial('config test init with local user', function(t){
var author = commit.author();
t.is(author.name(), 'test', 'author name is test');
t.is(author.email(), 'test@localhost', 'author email is test@localhost');
t.same(oid, commit.id(), 'same Oid');
t.deepEqual(oid, commit.id(), 'same Oid');
});
history.on('end', function(commits){
t.ok(commits, 'has commits');
t.truthy(commits, 'has commits');
t.is(commits.length, 1, 'has 1 commit');
});
history.start();
Expand Down Expand Up @@ -87,7 +87,7 @@ test.serial('config test overwrite user', function(t){
])
.catch(function(error){
t.pass('expect lock error');
t.ok(error, error);
t.truthy(error, error);
return;
});
})
Expand Down Expand Up @@ -118,7 +118,7 @@ test.serial('config core.autocrlf', function(t){
return git.config.get(repo, 'core.autocrlf');
})
.then(function(autocrlf){
t.ok(autocrlf, 'got core.autocrlf');
t.truthy(autocrlf, 'got core.autocrlf');
t.is(autocrlf, 'input', 'core.autocrlf is input');
})
.catch(function(error){
Expand All @@ -138,7 +138,7 @@ test.serial('config set a number (core.abbrev)', function(t){
});
})
.then(function(abbrev){
t.ok(abbrev, 'got core.abbrev');
t.truthy(abbrev, 'got core.abbrev');
t.is(Number(abbrev), 11, 'core.abbrev is 11');
})
.catch(function(error){
Expand All @@ -153,10 +153,10 @@ test.serial('config get local user', function(t){
return git.config.get(repo, ['user.name', 'user.email']);
})
.then(function(config){
t.ok(config[0], config[0]);
t.ok(config[1], config[1]);
t.ok(config[0] == 'test', 'user.name is test');
t.ok(config[1] == 'test@localhost', 'user.email is test@localhost');
t.truthy(config[0], config[0]);
t.truthy(config[1], config[1]);
t.truthy(config[0] == 'test', 'user.name is test');
t.truthy(config[1] == 'test@localhost', 'user.email is test@localhost');
})
.catch(function(error){
t.fail(error);
Expand All @@ -174,11 +174,11 @@ test.serial('config init without local user', function(t){
var history = master.history();
history.on('commit', function(commit){
var author = commit.author();
t.ok(author.name(), author.name());
t.ok(author.email(), author.email());
t.truthy(author.name(), author.name());
t.truthy(author.email(), author.email());
});
history.on('end', function(commits){
t.ok(commits, 'has commits');
t.truthy(commits, 'has commits');
t.is(commits.length, 1, 'has 1 commit');
});
history.start();
Expand All @@ -195,10 +195,10 @@ test.serial('config get user from repo without local user', function(t){
return git.config.get(repo, ['user.name', 'user.email']);
})
.then(function(config){
t.ok(config[0], config[0]);
t.ok(config[1], config[1]);
t.ok(config[0] != 'test', 'user.name is not test');
t.ok(config[1] != 'test@localhost', 'user.email is not test@localhost');
t.truthy(config[0], config[0]);
t.truthy(config[1], config[1]);
t.truthy(config[0] != 'test', 'user.name is not test');
t.truthy(config[1] != 'test@localhost', 'user.email is not test@localhost');
})
.catch(function(error){
t.fail(error);
Expand All @@ -212,10 +212,10 @@ test.serial('config get global user', function(t){
git.config.get('user.email')
])
.then(function(config){
t.ok(config[0], config[0]);
t.ok(config[1], config[1]);
t.ok(config[0] != 'test', 'user.name is not test');
t.ok(config[1] != 'test@localhost', 'user.email is not test@localhost');
t.truthy(config[0], config[0]);
t.truthy(config[1], config[1]);
t.truthy(config[0] != 'test', 'user.name is not test');
t.truthy(config[1] != 'test@localhost', 'user.email is not test@localhost');
})
.catch(function(error){
t.fail(error);
Expand All @@ -226,10 +226,10 @@ test.serial('config get global user', function(t){
test.serial('config get multiple global user configs', function(t){
return git.config.get(['user.name', 'user.email'])
.then(function(config){
t.ok(config[0], config[0]);
t.ok(config[1], config[1]);
t.ok(config[0] != 'test', 'user.name is not test');
t.ok(config[1] != 'test@localhost', 'user.email is not test@localhost');
t.truthy(config[0], config[0]);
t.truthy(config[1], config[1]);
t.truthy(config[0] != 'test', 'user.name is not test');
t.truthy(config[1] != 'test@localhost', 'user.email is not test@localhost');
})
.catch(function(error){
t.fail(error);
Expand Down
18 changes: 9 additions & 9 deletions test/test-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test.serial('init error', function(t){
t.fail('should not initialize repository on a file');
})
.catch(function(error){
t.ok(error, error);
t.truthy(error, error);
return files.rmdir(dir);
});
});
Expand All @@ -41,7 +41,7 @@ test.serial('init', function(t){
'message': 'the very first commit'
})
.then(function(repo){
t.ok(repo, 'initialized repository');
t.truthy(repo, 'initialized repository');
})
.catch(function(error){
t.fail(error);
Expand All @@ -52,7 +52,7 @@ test.serial('init', function(t){
test.serial('init reinitialize', function(t){
return git.init(dir)
.then(function(repo){
t.ok(repo, 'reinitialized existing repository');
t.truthy(repo, 'reinitialized existing repository');
})
.catch(function(error){
t.fail(error);
Expand All @@ -65,7 +65,7 @@ test.serial('init bare', function(t){
'bare': 1
})
.then(function(repo){
t.ok(repo, 'initialized bare repository');
t.truthy(repo, 'initialized bare repository');
})
.catch(function(error){
t.fail(error);
Expand All @@ -78,23 +78,23 @@ test.serial('init without commit', function(t){
'commit': false
})
.then(function(repo){
t.ok(repo, 'initialized repository without first commit');
t.truthy(repo, 'initialized repository without first commit');
// add files or change configs before first commit
return repo.getMasterCommit()
.then(function(master){
t.fail('should have no master commit yet');
})
.catch(function(error){
t.ok(error, error);
t.truthy(error, error);
// manually do first commit
return git.init.commit(repo);
})
.then(function(oid){
t.ok(oid, 'has oid');
t.truthy(oid, 'has oid');
return repo.getMasterCommit()
.then(function(commit){
t.ok(commit, 'has master commit');
t.same(oid, commit.id(), 'same Oid');
t.truthy(commit, 'has master commit');
t.deepEqual(oid, commit.id(), 'same Oid');
});
});
})
Expand Down
4 changes: 2 additions & 2 deletions test/test-open.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ test.serial('open error', function(t){
t.fail('should not open uninitialized repo');
})
.catch(function(error){
t.ok(error, error);
t.truthy(error, error);
});
});


test.serial('open should create a new repo', function(t){
return git.open(dir)
.then(function(repo){
t.ok(repo, 'has repo');
t.truthy(repo, 'has repo');
})
.catch(function(error){
t.fail(error);
Expand Down
32 changes: 16 additions & 16 deletions test/test-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ test.serial('state get status', function(t){
return git.status(repo);
})
.then(function(status){
t.ok(status && status.length, 'got status');
t.truthy(status && status.length, 'got status');
t.is(status.length, 2, 'got two items');

t.ok(status.some(function(file){
t.truthy(status.some(function(file){
return file.status == 'modified' && file.path == 'file2.txt';
}), 'file2.txt is modified');

t.ok(status.some(function(file){
t.truthy(status.some(function(file){
return file.status == 'new' && file.path == 'file3.txt';
}), 'file3.txt is new');
})
Expand All @@ -78,17 +78,17 @@ test.serial('state get diff', function(t){
return git.diff(repo);
})
.then(function(changes){
t.ok(Array.isArray(changes), 'changes is an Array');
t.truthy(Array.isArray(changes), 'changes is an Array');
changes.forEach(function(change){
t.ok(change.path, 'has path');
t.ok(change.size, 'has size');
t.ok(change.status, 'has status');
t.truthy(change.path, 'has path');
t.truthy(change.size, 'has size');
t.truthy(change.status, 'has status');

if (change.status != 'modified') return;
t.is(change.size, 78, 'size is 78');
t.is(change.oldsize, 78, 'oldsize is 78');
t.ok(Array.isArray(change.hunks), 'hunks is an Array');
t.ok(change.hunks.length == 2, 'has 2 hunks');
t.truthy(Array.isArray(change.hunks), 'hunks is an Array');
t.truthy(change.hunks.length == 2, 'has 2 hunks');
t.is(change.hunks[0], hunk1, 'test hunk 1');
t.is(change.hunks[1], hunk2, 'test hunk 2');
});
Expand Down Expand Up @@ -135,7 +135,7 @@ test.serial('state diff commit', function(t){
return git.diff(repo, commits[1])
.then(function(changes){
var hunk = '@@ -4,3 +4,5 @@ c\n d\n e\n f\n+g\n+h';
t.ok(Array.isArray(changes), 'changes is an Array');
t.truthy(Array.isArray(changes), 'changes is an Array');
t.is(changes.length, 1, 'has 1 change');
t.is(changes[0].status, 'modified', 'status is modified');
t.is(changes[0].size, 16, 'size is 16');
Expand All @@ -162,8 +162,8 @@ test.serial('state diff commit', function(t){
.then(function(changes){
changes.forEach(function(change){

t.ok(change.path, change.path);
t.ok(change.status, 'has status');
t.truthy(change.path, change.path);
t.truthy(change.status, 'has status');
if (change.path == 'file1.txt'){
t.is(change.status, 'modified', 'status is modified');
t.is(change.size, 16, 'size is 16');
Expand All @@ -181,7 +181,7 @@ test.serial('state diff commit', function(t){
if (change.path == 'file3.txt'){
t.is(change.status, 'added', 'status is added');
t.is(change.size, 8, 'size is 8');
t.notOk(change.oldsize, 'has no oldsize');
t.falsy(change.oldsize, 'has no oldsize');
t.is(change.hunks[0], '@@ -0,0 +1,2 @@\n+foo\n+bar', 'test hunk');
}

Expand Down Expand Up @@ -243,8 +243,8 @@ test.serial('state get diff commit', function(t){
.then(function(changes){
changes.forEach(function(change){

t.ok(change.path, change.path);
t.ok(change.status, 'has status');
t.truthy(change.path, change.path);
t.truthy(change.status, 'has status');
if (change.path == 'file1.txt'){
t.is(change.status, 'modified', 'status is modified');
t.is(change.size, 16, 'size is 16');
Expand All @@ -262,7 +262,7 @@ test.serial('state get diff commit', function(t){
if (change.path == 'file3.txt'){
t.is(change.status, 'added', 'status is added');
t.is(change.size, 8, 'size is 8');
t.notOk(change.oldsize, 'has no oldsize');
t.falsy(change.oldsize, 'has no oldsize');
t.is(change.hunks[0], '@@ -0,0 +1,2 @@\n+foo\n+bar', 'test hunk');
}

Expand Down

0 comments on commit 9eb8e07

Please sign in to comment.