Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
20 additions
and
10 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
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,9 +1,22 @@ | ||
#!/usr/bin/env node | ||
var randomMac = require('../index'), | ||
test = require('tap').test; | ||
assert = require('assert'), | ||
mac_regex = /^([a-fA-F0-9]{2}:){5}[0-9a-fA-F]{2}$/, | ||
mac_length = 17, | ||
mac1 = randomMac(), | ||
mac2 = randomMac('00:11:22'), | ||
mac3 = randomMac('wrong'); | ||
|
||
test('Ensure Length', function(t) { | ||
var mac = randomMac(); | ||
t.equal(mac.length, 17, 'Mac Address is 17 Characters'); | ||
t.end(); | ||
}); | ||
console.log('Testing correct length'); | ||
assert.equal(mac1.length, mac_length); | ||
assert.equal(mac2.length, mac_length); | ||
|
||
console.log('Testing correct regex'); | ||
assert.ok(mac1.match(mac_regex)); | ||
assert.ok(mac2.match(mac_regex)); | ||
|
||
console.log('Testing incorrect length'); | ||
assert.notEqual(mac3.length, mac_length); | ||
|
||
console.log('Testing incorrect regex'); | ||
assert.equal(mac3.match(mac_regex), null); |