main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
936 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var test = require('tape');
|
---|
| 4 | var v = require('es-value-fixtures');
|
---|
| 5 | var forEach = require('for-each');
|
---|
| 6 | var inspect = require('object-inspect');
|
---|
| 7 |
|
---|
| 8 | var regexTester = require('../');
|
---|
| 9 |
|
---|
| 10 | test('regex tester', function (t) {
|
---|
| 11 | t.equal(typeof regexTester, 'function', 'is a function');
|
---|
| 12 |
|
---|
| 13 | t.test('non-regexes', function (st) {
|
---|
[79a0317] | 14 | forEach([].concat(
|
---|
| 15 | // @ts-expect-error TS sucks with concat
|
---|
| 16 | v.primitives,
|
---|
| 17 | v.objects
|
---|
| 18 | ), function (val) {
|
---|
[d565449] | 19 | st['throws'](
|
---|
| 20 | function () { regexTester(val); },
|
---|
| 21 | TypeError,
|
---|
| 22 | inspect(val) + ' is not a regex'
|
---|
| 23 | );
|
---|
| 24 | });
|
---|
| 25 |
|
---|
| 26 | st.end();
|
---|
| 27 | });
|
---|
| 28 |
|
---|
| 29 | t.test('regexes', function (st) {
|
---|
| 30 | var tester = regexTester(/a/);
|
---|
| 31 |
|
---|
| 32 | st.equal(typeof tester, 'function', 'returns a function');
|
---|
| 33 | st.equal(tester('a'), true, 'returns true for a match');
|
---|
| 34 | st.equal(tester('b'), false, 'returns false for a non-match');
|
---|
| 35 | st.equal(tester('a'), true, 'returns true for a match again');
|
---|
| 36 |
|
---|
| 37 | st.end();
|
---|
| 38 | });
|
---|
| 39 |
|
---|
| 40 | t.end();
|
---|
| 41 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.