|
|
|
@@ -86,7 +86,7 @@ describe('xterm-addon-serialize html', () => {
|
|
|
|
|
it('empty terminal with selection turned off', () => {
|
|
|
|
|
const output = serializeAddon.serializeAsHTML();
|
|
|
|
|
assert.notEqual(output, '');
|
|
|
|
|
assert.equal((output.match(new RegExp('<div><span> {10}</span><\/div>', 'g')) || []).length, 2);
|
|
|
|
|
assert.equal((output.match(/<div><span> {10}<\/span><\/div>/g) || []).length, 2);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('empty terminal with no selection', () => {
|
|
|
|
@@ -103,84 +103,84 @@ describe('xterm-addon-serialize html', () => {
|
|
|
|
|
const output = serializeAddon.serializeAsHTML({
|
|
|
|
|
onlySelection: true
|
|
|
|
|
});
|
|
|
|
|
assert.equal((output.match(new RegExp('<div><span>terminal<\/span><\/div>', 'g')) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(/<div><span>terminal<\/span><\/div>/g) || []).length, 1, output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('cells with bold styling', async () => {
|
|
|
|
|
await writeP(terminal, ' ' + sgr('1') + 'terminal' + sgr('22') + ' ');
|
|
|
|
|
|
|
|
|
|
const output = serializeAddon.serializeAsHTML();
|
|
|
|
|
assert.equal((output.match(new RegExp('<span style=\'font-weight: bold;\'>terminal<\/span>', 'g')) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(/<span style='font-weight: bold;'>terminal<\/span>/g) || []).length, 1, output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('cells with italic styling', async () => {
|
|
|
|
|
await writeP(terminal, ' ' + sgr('3') + 'terminal' + sgr('23') + ' ');
|
|
|
|
|
|
|
|
|
|
const output = serializeAddon.serializeAsHTML();
|
|
|
|
|
assert.equal((output.match(new RegExp('<span style=\'font-style: italic;\'>terminal<\/span>', 'g')) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(/<span style='font-style: italic;'>terminal<\/span>/g) || []).length, 1, output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('cells with inverse styling', async () => {
|
|
|
|
|
await writeP(terminal, ' ' + sgr('7') + 'terminal' + sgr('27') + ' ');
|
|
|
|
|
|
|
|
|
|
const output = serializeAddon.serializeAsHTML();
|
|
|
|
|
assert.equal((output.match(new RegExp('<span style=\'color: #000000; background-color: #BFBFBF;\'>terminal<\/span>', 'g')) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(/<span style='color: #000000; background-color: #BFBFBF;'>terminal<\/span>/g) || []).length, 1, output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('cells with underline styling', async () => {
|
|
|
|
|
await writeP(terminal, ' ' + sgr('4') + 'terminal' + sgr('24') + ' ');
|
|
|
|
|
|
|
|
|
|
const output = serializeAddon.serializeAsHTML();
|
|
|
|
|
assert.equal((output.match(new RegExp('<span style=\'text-decoration: underline;\'>terminal<\/span>', 'g')) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(/<span style='text-decoration: underline;'>terminal<\/span>/g) || []).length, 1, output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('cells with invisible styling', async () => {
|
|
|
|
|
await writeP(terminal, ' ' + sgr('8') + 'terminal' + sgr('28') + ' ');
|
|
|
|
|
|
|
|
|
|
const output = serializeAddon.serializeAsHTML();
|
|
|
|
|
assert.equal((output.match(new RegExp('<span style=\'visibility: hidden;\'>terminal<\/span>', 'g')) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(/<span style='visibility: hidden;'>terminal<\/span>/g) || []).length, 1, output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('cells with dim styling', async () => {
|
|
|
|
|
await writeP(terminal, ' ' + sgr('2') + 'terminal' + sgr('22') + ' ');
|
|
|
|
|
|
|
|
|
|
const output = serializeAddon.serializeAsHTML();
|
|
|
|
|
assert.equal((output.match(new RegExp('<span style=\'opacity: 0.5;\'>terminal<\/span>', 'g')) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(/<span style='opacity: 0.5;'>terminal<\/span>/g) || []).length, 1, output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('cells with strikethrough styling', async () => {
|
|
|
|
|
await writeP(terminal, ' ' + sgr('9') + 'terminal' + sgr('29') + ' ');
|
|
|
|
|
|
|
|
|
|
const output = serializeAddon.serializeAsHTML();
|
|
|
|
|
assert.equal((output.match(new RegExp('<span style=\'text-decoration: line-through;\'>terminal<\/span>', 'g')) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(/<span style='text-decoration: line-through;'>terminal<\/span>/g) || []).length, 1, output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('cells with combined styling', async () => {
|
|
|
|
|
await writeP(terminal, sgr('1') + ' ' + sgr('9') + 'termi' + sgr('22') + 'nal' + sgr('29') + ' ');
|
|
|
|
|
|
|
|
|
|
const output = serializeAddon.serializeAsHTML();
|
|
|
|
|
assert.equal((output.match(new RegExp('<span style=\'font-weight: bold;\'> <\/span>', 'g')) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(new RegExp('<span style=\'font-weight: bold; text-decoration: line-through;\'>termi<\/span>', 'g')) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(new RegExp('<span style=\'text-decoration: line-through;\'>nal<\/span>', 'g')) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(/<span style='font-weight: bold;'> <\/span>/g) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(/<span style='font-weight: bold; text-decoration: line-through;'>termi<\/span>/g) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(/<span style='text-decoration: line-through;'>nal<\/span>/g) || []).length, 1, output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('cells with color styling', async () => {
|
|
|
|
|
await writeP(terminal, ' ' + sgr('38;5;46') + 'terminal' + sgr('39') + ' ');
|
|
|
|
|
|
|
|
|
|
const output = serializeAddon.serializeAsHTML();
|
|
|
|
|
assert.equal((output.match(new RegExp('<span style=\'color: #00ff00;\'>terminal<\/span>', 'g')) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(/<span style='color: #00ff00;'>terminal<\/span>/g) || []).length, 1, output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('cells with background styling', async () => {
|
|
|
|
|
await writeP(terminal, ' ' + sgr('48;5;46') + 'terminal' + sgr('49') + ' ');
|
|
|
|
|
|
|
|
|
|
const output = serializeAddon.serializeAsHTML();
|
|
|
|
|
assert.equal((output.match(new RegExp('<span style=\'background-color: #00ff00;\'>terminal<\/span>', 'g')) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(/<span style='background-color: #00ff00;'>terminal<\/span>/g) || []).length, 1, output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('empty terminal with default options', async () => {
|
|
|
|
|
const output = serializeAddon.serializeAsHTML();
|
|
|
|
|
assert.equal((output.match(new RegExp('color: #000000; background-color: #ffffff; font-family: courier-new, courier, monospace; font-size: 15px;', 'g')) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(/color: #000000; background-color: #ffffff; font-family: courier-new, courier, monospace; font-size: 15px;/g) || []).length, 1, output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('empty terminal with custom options', async () => {
|
|
|
|
@@ -193,13 +193,13 @@ describe('xterm-addon-serialize html', () => {
|
|
|
|
|
const output = serializeAddon.serializeAsHTML({
|
|
|
|
|
includeGlobalBackground: true
|
|
|
|
|
});
|
|
|
|
|
assert.equal((output.match(new RegExp('color: #ff00ff; background-color: #00ff00; font-family: verdana; font-size: 20px;', 'g')) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(/color: #ff00ff; background-color: #00ff00; font-family: verdana; font-size: 20px;/g) || []).length, 1, output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('empty terminal with background included', async () => {
|
|
|
|
|
const output = serializeAddon.serializeAsHTML({
|
|
|
|
|
includeGlobalBackground: true
|
|
|
|
|
});
|
|
|
|
|
assert.equal((output.match(new RegExp('color: #ffffff; background-color: #000000; font-family: courier-new, courier, monospace; font-size: 15px;', 'g')) || []).length, 1, output);
|
|
|
|
|
assert.equal((output.match(/color: #ffffff; background-color: #000000; font-family: courier-new, courier, monospace; font-size: 15px;/g) || []).length, 1, output);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|