source: imaps-frontend/node_modules/safe-regex-test/test/index.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 878 bytes
Line 
1'use strict';
2
3var test = require('tape');
4var v = require('es-value-fixtures');
5var forEach = require('for-each');
6var inspect = require('object-inspect');
7
8var regexTester = require('../');
9
10test('regex tester', function (t) {
11 t.equal(typeof regexTester, 'function', 'is a function');
12
13 t.test('non-regexes', function (st) {
14 forEach(v.primitives.concat(v.objects), function (val) {
15 st['throws'](
16 function () { regexTester(val); },
17 TypeError,
18 inspect(val) + ' is not a regex'
19 );
20 });
21
22 st.end();
23 });
24
25 t.test('regexes', function (st) {
26 var tester = regexTester(/a/);
27
28 st.equal(typeof tester, 'function', 'returns a function');
29 st.equal(tester('a'), true, 'returns true for a match');
30 st.equal(tester('b'), false, 'returns false for a non-match');
31 st.equal(tester('a'), true, 'returns true for a match again');
32
33 st.end();
34 });
35
36 t.end();
37});
Note: See TracBrowser for help on using the repository browser.