aboutsummaryrefslogtreecommitdiff
path: root/test/git.unit.js
diff options
context:
space:
mode:
authorDanielle Adams <[email protected]>2018-06-26 16:03:46 -0400
committerMarak <[email protected]>2018-09-23 11:12:09 -0400
commit2968497cff29f81b223010c25fa7d34785a8a004 (patch)
treef35509b6b4dee3b258291feee086a194f9af7716 /test/git.unit.js
parentdafd3316ac63e3eec322e0d56f9dcfd5a62cbaf3 (diff)
downloadfaker-2968497cff29f81b223010c25fa7d34785a8a004.tar.xz
faker-2968497cff29f81b223010c25fa7d34785a8a004.zip
add unit test for git module
Diffstat (limited to 'test/git.unit.js')
-rw-r--r--test/git.unit.js62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/git.unit.js b/test/git.unit.js
new file mode 100644
index 00000000..3e0c5104
--- /dev/null
+++ b/test/git.unit.js
@@ -0,0 +1,62 @@
+if (typeof module !== 'undefined') {
+ var assert = require('assert');
+ var sinon = require('sinon');
+ var faker = require('../index');
+}
+
+describe("git.js", function() {
+ describe("branch()", function() {
+ beforeEach(function() {
+ sinon.spy(faker.hacker, 'noun');
+ sinon.spy(faker.hacker, 'verb');
+ });
+
+ afterEach(function() {
+ faker.hacker.noun.restore();
+ faker.hacker.verb.restore();
+ });
+
+ it("returns a branch with hacker noun, adj and verb", function() {
+ var message = faker.git.branch();
+
+ assert.ok(faker.hacker.noun.calledOnce);
+ assert.ok(faker.hacker.verb.calledOnce);
+ });
+ });
+
+ describe("commitSha()", function() {
+ it("returns a random commit SHA", function() {
+ var commitSha = faker.git.commitSha();
+ assert.ok(commitSha.match(/^[a-z0-9]{40}$/));
+ });
+ });
+
+ describe("commitMessage()", function() {
+ beforeEach(function() {
+ sinon.spy(faker.hacker, 'verb');
+ sinon.spy(faker.hacker, 'adjective');
+ sinon.spy(faker.hacker, 'noun');
+ });
+
+ afterEach(function() {
+ faker.hacker.verb.restore();
+ faker.hacker.adjective.restore();
+ faker.hacker.noun.restore();
+ });
+
+ it("returns a commit message with hacker noun, adj and verb", function() {
+ var message = faker.git.commitMessage();
+
+ assert.ok(faker.hacker.verb.calledOnce);
+ assert.ok(faker.hacker.adjective.calledOnce);
+ assert.ok(faker.hacker.noun.calledOnce);
+ });
+ });
+
+ describe("shortSha()", function() {
+ it("returns a random short SHA", function() {
+ var commitSha = faker.git.shortSha();
+ assert.ok(commitSha.match(/^[a-z0-9]{7}$/));
+ });
+ });
+}); \ No newline at end of file