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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
Description: Change from ava to mocha as test runner (ava is not yet
available as a Debian package).
Forwarded: not-needed
Author: Paolo Greppi <paolo.greppi@libpf.com>
Index: node-ansi-regex/test.js
===================================================================
--- node-ansi-regex.orig/test.js
+++ node-ansi-regex/test.js
@@ -1,40 +1,40 @@
-import test from 'ava';
-import ansiCodes from './fixtures/ansi-codes';
-import m from '.';
+var ansiCodes = require('./fixtures/ansi-codes');
+var m = require('.');
+var assert = require('assert');
const consumptionChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+1234567890-=[]{};\':"./>?,<\\|';
// Testing against codes found at: http://ascii-table.com/ansi-escape-sequences-vt-100.php
-test('match ansi code in a string', t => {
- t.regex('foo\u001B[4mcake\u001B[0m', m());
- t.regex('\u001B[4mcake\u001B[0m', m());
- t.regex('foo\u001B[4mcake\u001B[0m', m());
- t.regex('\u001B[0m\u001B[4m\u001B[42m\u001B[31mfoo\u001B[39m\u001B[49m\u001B[24mfoo\u001B[0m', m());
- t.regex('foo\u001B[mfoo', m());
+test('match ansi code in a string', function() {
+ assert(m().test('foo\u001B[4mcake\u001B[0m'));
+ assert(m().test('\u001B[4mcake\u001B[0m'));
+ assert(m().test('foo\u001B[4mcake\u001B[0m'));
+ assert(m().test('\u001B[0m\u001B[4m\u001B[42m\u001B[31mfoo\u001B[39m\u001B[49m\u001B[24mfoo\u001B[0m'));
+ assert(m().test('foo\u001B[mfoo'));
});
-test('match ansi code from ls command', t => {
- t.regex('\u001B[00;38;5;244m\u001B[m\u001B[00;38;5;33mfoo\u001B[0m', m());
+test('match ansi code from ls command', function() {
+ assert(m().test('\u001B[00;38;5;244m\u001B[m\u001B[00;38;5;33mfoo\u001B[0m'));
});
-test('match reset;setfg;setbg;italics;strike;underline sequence in a string', t => {
- t.regex('\u001B[0;33;49;3;9;4mbar\u001B[0m', m());
- t.is('foo\u001B[0;33;49;3;9;4mbar'.match(m())[0], '\u001B[0;33;49;3;9;4m');
+test('match reset;setfg;setbg;italics;strike;underline sequence in a string', function() {
+ assert(m().test('\u001B[0;33;49;3;9;4mbar\u001B[0m'));
+ assert('foo\u001B[0;33;49;3;9;4mbar'.match(m())[0] === '\u001B[0;33;49;3;9;4m');
});
-test('match clear tabs sequence in a string', t => {
- t.regex('foo\u001B[0gbar', m());
- t.is('foo\u001B[0gbar'.match(m())[0], '\u001B[0g');
+test('match clear tabs sequence in a string', function() {
+ assert(m().test('foo\u001B[0gbar'));
+ assert('foo\u001B[0gbar'.match(m())[0] === '\u001B[0g');
});
-test('match clear line from cursor right in a string', t => {
- t.regex('foo\u001B[Kbar', m());
- t.is('foo\u001B[Kbar'.match(m())[0], '\u001B[K');
+test('match clear line from cursor right in a string', function() {
+ assert(m().test('foo\u001B[Kbar'));
+ assert('foo\u001B[Kbar'.match(m())[0] === '\u001B[K');
});
-test('match clear screen in a string', t => {
- t.regex('foo\u001B[2Jbar', m());
- t.is('foo\u001B[2Jbar'.match(m())[0], '\u001B[2J');
+test('match clear screen in a string', function() {
+ assert(m().test('foo\u001B[2Jbar'));
+ assert('foo\u001B[2Jbar'.match(m())[0] === '\u001B[2J');
});
// Testing against extended codes (excluding codes ending in 0-9)
@@ -46,29 +46,27 @@ for (const codeSet of Object.keys(ansiCo
const skipText = skip ? '[SKIP] ' : '';
const ecode = `\u001B${code}`;
- test(`${skipText}${code} → ${codeInfo[0]}`, t => {
+ test(`${skipText}${code} → ${codeInfo[0]}`, function() {
if (skip) {
- t.pass();
return;
}
const string = `hel${ecode}lo`;
- t.regex(string, m());
- t.is(string.match(m())[0], ecode);
- t.is(string.replace(m(), ''), 'hello');
+ assert(m().test(string));
+ assert(string.match(m())[0] == ecode);
+ assert(string.replace(m(), '') === 'hello');
});
- test(`${skipText}${code} should not overconsume`, t => {
+ test(`${skipText}${code} should not overconsume`, function() {
if (skip) {
- t.pass();
return;
}
for (const c of consumptionChars) {
const string = ecode + c;
- t.regex(string, m());
- t.is(string.match(m())[0], ecode);
- t.is(string.replace(m(), ''), c);
+ assert(m().test(string));
+ assert(string.match(m())[0] == ecode);
+ assert(string.replace(m(), '') === c);
}
});
}
|