1 | 'use strict';
|
2 |
|
3 | var matches = require('../src/matches'),
|
4 | assert = require('chai').assert;
|
5 |
|
6 | describe('matches', function() {
|
7 | it('throws an error if regexp is not valid regexp', function() {
|
8 | assert.throws(function() {
|
9 | matches('r');
|
10 | }, TypeError, /must be a RegExp object/);
|
11 |
|
12 | assert.throws(function() {
|
13 | matches('r')('test');
|
14 | }, TypeError, /must be a RegExp object/);
|
15 | });
|
16 |
|
17 | it('returns a function if only regexp provided', function() {
|
18 | assert.ok(matches(/r/) instanceof Function);
|
19 | });
|
20 |
|
21 | it('checks whether a string matches a regexp', function() {
|
22 | assert.ok(matches(/wookieb/, 'i am wookieb'));
|
23 | assert.ok(matches(/wookieb/)('i am wookieb'));
|
24 | assert.ok(matches(/wookieb/)('i am groot') === false);
|
25 | });
|
26 | });
|