-
Notifications
You must be signed in to change notification settings - Fork 11
/
test.js
32 lines (30 loc) · 1.04 KB
/
test.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
/**
* Module dependencies
*/
var assert = require('assert');
var regex = require('./');
/**
* Test
*/
describe('username regex', function() {
it('should match username input', function() {
assert.equal(regex().test('foobar'), true);
assert.equal(regex().test('foo-bar'), true);
assert.equal(regex().test('FooBar'), true);
assert.equal(regex().test('FOOBAR'), true);
assert.equal(regex().test('foo-bar-baz'), true);
assert.equal(regex().test('f'), true);
});
it('should catch incorrect input', function() {
assert.equal(regex().test('-foo'), false);
assert.equal(regex().test('foo-'), false);
assert.equal(regex().test('-'), false);
assert.equal(regex().test('foo--bar'), false);
assert.equal(regex().test('foo-bar-'), false);
assert.equal(regex().test('3tobi--ferret'), false);
assert.equal(regex().test('~~derp@darp-----++asdfasdf'), false);
assert.equal(regex().test('foo_bar'), false);
assert.equal(regex().test('_foobar'), false);
assert.equal(regex().test('foobar_'), false);
});
});