-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02fa893
commit b630317
Showing
8 changed files
with
39 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,11 +47,11 @@ test('match terminal link', t => { | |
t.regex('\u001B]8;;mailto:[email protected]\u0007mail\u001B]8;;\u0007', ansiRegex()); | ||
t.deepEqual('\u001B]8;k=v;https://example-a.com/?a_b=1&c=2#tit%20le\u0007click\u001B]8;;\u0007'.match(ansiRegex()), [ | ||
'\u001B]8;k=v;https://example-a.com/?a_b=1&c=2#tit%20le\u0007', | ||
'\u001B]8;;\u0007' | ||
'\u001B]8;;\u0007', | ||
]); | ||
t.deepEqual('\u001B]8;;mailto:[email protected]\u0007mail-me\u001B]8;;\u0007'.match(ansiRegex()), [ | ||
'\u001B]8;;mailto:[email protected]\u0007', | ||
'\u001B]8;;\u0007' | ||
'\u001B]8;;\u0007', | ||
]); | ||
}); | ||
|
||
|
@@ -60,14 +60,14 @@ test('match "change icon name and window title" in string', t => { | |
}); | ||
|
||
// Testing against extended codes (excluding codes ending in 0-9) | ||
for (const codeSet of Object.keys(ansiCodes)) { | ||
for (const [code, codeInfo] of ansiCodes[codeSet]) { | ||
const skip = /\d$/.test(code); | ||
const skipText = skip ? '[SKIP] ' : ''; | ||
for (const [codeSetKey, codeSetValue] of Object.entries(ansiCodes)) { | ||
for (const [code, codeInfo] of codeSetValue) { | ||
const shouldSkip = /\d$/.test(code); | ||
const skipText = shouldSkip ? '[SKIP] ' : ''; | ||
const ecode = `\u001B${code}`; | ||
|
||
test(`${codeSet} - ${skipText}${code} → ${codeInfo[0]}`, t => { | ||
if (skip) { | ||
test(`${codeSetKey} - ${skipText}${code} → ${codeInfo[0]}`, t => { | ||
if (shouldSkip) { | ||
t.pass(); | ||
return; | ||
} | ||
|
@@ -78,36 +78,34 @@ for (const codeSet of Object.keys(ansiCodes)) { | |
t.is(string.replace(ansiRegex(), ''), 'hello'); | ||
}); | ||
|
||
test(`${codeSet} - ${skipText}${code} should not overconsume`, t => { | ||
if (skip) { | ||
test(`${codeSetKey} - ${skipText}${code} should not overconsume`, t => { | ||
if (shouldSkip) { | ||
t.pass(); | ||
return; | ||
} | ||
|
||
for (const c of consumptionCharacters) { | ||
const string = ecode + c; | ||
for (const character of consumptionCharacters) { | ||
const string = ecode + character; | ||
t.regex(string, ansiRegex()); | ||
t.is(string.match(ansiRegex())[0], ecode); | ||
t.is(string.replace(ansiRegex(), ''), c); | ||
t.is(string.replace(ansiRegex(), ''), character); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
const escapeCodeFunctionArgs = [1, 2]; | ||
const escapeCodeFunctionArguments = [1, 2]; | ||
const escapeCodeIgnoresList = new Set(['beep', 'image', 'iTerm']); | ||
const escapeCodeResultMap = new Map([['link', escapeCodeFunctionArgs[0]]]); | ||
const escapeCodeResultMap = new Map([['link', escapeCodeFunctionArguments[0]]]); | ||
|
||
for (const key of Object.keys(ansiEscapes)) { | ||
for (const [key, escapeCode] of Object.entries(ansiEscapes)) { | ||
if (escapeCodeIgnoresList.has(key)) { | ||
continue; | ||
} | ||
|
||
const escapeCode = ansiEscapes[key]; | ||
|
||
const escapeCodeValue = typeof escapeCode === 'function' ? | ||
escapeCode(...escapeCodeFunctionArgs) : | ||
escapeCode; | ||
const escapeCodeValue = typeof escapeCode === 'function' | ||
? escapeCode(...escapeCodeFunctionArguments) | ||
: escapeCode; | ||
|
||
test(`ansi-escapes ${key}`, t => { | ||
for (const character of consumptionCharacters) { | ||
|