-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.1.0, delimiter added and some bug fixes
- Loading branch information
Showing
5 changed files
with
71 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,3 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# Commenting this out is preferred by some people, see | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- | ||
node_modules | ||
|
||
# Users Environment Variables | ||
.lock-wscript | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,38 @@ | ||
var assert = require('chai').assert, | ||
haikunate = require('../index'); | ||
|
||
|
||
describe('test haikunate()', function() { | ||
it('default use', function() { | ||
assert.match(haikunate(), /((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(\d)(\d)(\d)(\d)/i); | ||
}); | ||
it('matching with hex turned on', function() { | ||
assert.match(haikunate(4, true), /((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(.)(.)(.)(.)/i); | ||
}); | ||
it('matching with 9 ints', function() { | ||
assert.match(haikunate(9), /((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)/i); | ||
}); | ||
it('matching with hex tuned on', function() { | ||
assert.match(haikunate(9, true), /((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(.)(.)(.)(.)(.)(.)(.)(.)(.)/i); | ||
}); | ||
}) | ||
haikunate = require('../index'); | ||
|
||
|
||
describe('testing haikunate', function () { | ||
|
||
it('haikunate() should return 4 digits', function () { | ||
assert.match(haikunate(), /((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(\d{4})/); | ||
}); | ||
|
||
it('haikunate(4, true) should return 4 digits as hex', function () { | ||
assert.match(haikunate(4, true), /((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(.{4})/i); | ||
}); | ||
|
||
it('haikunate(9) should return 9 digits', function () { | ||
assert.match(haikunate(9), /((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(\d{9})/i); | ||
}); | ||
|
||
it('haikunate(9, true) should return 9 digits as hex', function () { | ||
assert.match(haikunate(9, true), /((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(.{9})/i); | ||
}); | ||
|
||
it('wont return the same name for subsequent calls', function () { | ||
assert.notStrictEqual(haikunate(), haikunate()); | ||
}); | ||
|
||
it('drops the token if token range is 0', function () { | ||
assert.match(haikunate(0), /((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))/); | ||
}); | ||
|
||
it('permits optional configuration of the delimiter', function () { | ||
assert.match(haikunate(4, false, '.'), /((?:[a-z][a-z]+))(\.)((?:[a-z][a-z]+))(\.)(\d+)/i); | ||
}); | ||
|
||
it('drops the token and delimiter if token range is 0 and delimiter is an empty space', function () { | ||
assert.match(haikunate(0, false, ' '), /((?:[a-z][a-z]+))( )((?:[a-z][a-z]+))/i); | ||
}); | ||
}); |