Fix tests
This commit is contained in:
@@ -75,9 +75,7 @@ export function rgbRelativeLuminance2(r: number, g: number, b: number): number {
|
|||||||
* Gets the contrast ratio between two relative luminance values.
|
* Gets the contrast ratio between two relative luminance values.
|
||||||
* @param l1 The first relative luminance.
|
* @param l1 The first relative luminance.
|
||||||
* @param l2 The first relative luminance.
|
* @param l2 The first relative luminance.
|
||||||
*
|
* @see https://www.w3.org/TR/WCAG20/#contrast-ratiodef
|
||||||
* // TODO: Is this link right?
|
|
||||||
* @see https://www.w3.org/TR/WCAG20/#contrastratio
|
|
||||||
*/
|
*/
|
||||||
export function contrastRatio(l1: number, l2: number): number {
|
export function contrastRatio(l1: number, l2: number): number {
|
||||||
if (l1 < l2) {
|
if (l1 < l2) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { BufferLine, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
|
|||||||
import { IBufferLine } from 'common/Types';
|
import { IBufferLine } from 'common/Types';
|
||||||
import { CellData } from 'common/buffer/CellData';
|
import { CellData } from 'common/buffer/CellData';
|
||||||
import { MockOptionsService } from 'common/TestUtils.test';
|
import { MockOptionsService } from 'common/TestUtils.test';
|
||||||
|
import { fromCss } from 'browser/Color';
|
||||||
|
|
||||||
describe('DomRendererRowFactory', () => {
|
describe('DomRendererRowFactory', () => {
|
||||||
let dom: jsdom.JSDOM;
|
let dom: jsdom.JSDOM;
|
||||||
@@ -19,7 +20,30 @@ describe('DomRendererRowFactory', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
dom = new jsdom.JSDOM('');
|
dom = new jsdom.JSDOM('');
|
||||||
rowFactory = new DomRendererRowFactory(dom.window.document, new MockOptionsService({ drawBoldTextInBrightColors: true }), {} as any);
|
rowFactory = new DomRendererRowFactory(dom.window.document, new MockOptionsService({ drawBoldTextInBrightColors: true }), {
|
||||||
|
background: fromCss('#010101'),
|
||||||
|
foreground: fromCss('#020202'),
|
||||||
|
ansi: [
|
||||||
|
// dark:
|
||||||
|
fromCss('#2e3436'),
|
||||||
|
fromCss('#cc0000'),
|
||||||
|
fromCss('#4e9a06'),
|
||||||
|
fromCss('#c4a000'),
|
||||||
|
fromCss('#3465a4'),
|
||||||
|
fromCss('#75507b'),
|
||||||
|
fromCss('#06989a'),
|
||||||
|
fromCss('#d3d7cf'),
|
||||||
|
// bright:
|
||||||
|
fromCss('#555753'),
|
||||||
|
fromCss('#ef2929'),
|
||||||
|
fromCss('#8ae234'),
|
||||||
|
fromCss('#fce94f'),
|
||||||
|
fromCss('#729fcf'),
|
||||||
|
fromCss('#ad7fa8'),
|
||||||
|
fromCss('#34e2e2'),
|
||||||
|
fromCss('#eeeeec')
|
||||||
|
]
|
||||||
|
} as any);
|
||||||
lineData = createEmptyLineData(2);
|
lineData = createEmptyLineData(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -142,7 +166,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20);
|
const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20);
|
||||||
assert.equal(getFragmentHtml(fragment),
|
assert.equal(getFragmentHtml(fragment),
|
||||||
'<span class="xterm-bg-2 xterm-fg-1">a</span>'
|
'<span class="xterm-fg-1 xterm-bg-2">a</span>'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -153,7 +177,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20);
|
const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20);
|
||||||
assert.equal(getFragmentHtml(fragment),
|
assert.equal(getFragmentHtml(fragment),
|
||||||
'<span class="xterm-bg-257 xterm-fg-1">a</span>'
|
'<span class="xterm-fg-1 xterm-bg-257">a</span>'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -163,7 +187,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20);
|
const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20);
|
||||||
assert.equal(getFragmentHtml(fragment),
|
assert.equal(getFragmentHtml(fragment),
|
||||||
'<span class="xterm-bg-1 xterm-fg-257">a</span>'
|
'<span class="xterm-fg-257 xterm-bg-1">a</span>'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -199,7 +223,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20);
|
const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20);
|
||||||
assert.equal(getFragmentHtml(fragment),
|
assert.equal(getFragmentHtml(fragment),
|
||||||
'<span style="background-color:rgb(1,2,3);color:rgb(4,5,6);">a</span>'
|
'<span style="color:rgb(4,5,6);background-color:rgb(1,2,3);">a</span>'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { AttributeData } from 'common/buffer/AttributeData';
|
|||||||
import { NULL_CELL_CODE, WHITESPACE_CELL_CHAR, Attributes } from 'common/buffer/Constants';
|
import { NULL_CELL_CODE, WHITESPACE_CELL_CHAR, Attributes } from 'common/buffer/Constants';
|
||||||
import { CellData } from 'common/buffer/CellData';
|
import { CellData } from 'common/buffer/CellData';
|
||||||
import { IOptionsService } from 'common/services/Services';
|
import { IOptionsService } from 'common/services/Services';
|
||||||
import { rgbRelativeLuminance, fromCss, contrastRatio, ensureContrastRatio } from 'browser/Color';
|
import { ensureContrastRatio } from 'browser/Color';
|
||||||
import { IColorSet, IColor } from 'browser/Types';
|
import { IColorSet, IColor } from 'browser/Types';
|
||||||
|
|
||||||
export const BOLD_CLASS = 'xterm-bold';
|
export const BOLD_CLASS = 'xterm-bold';
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({
|
|||||||
screenReaderMode: false,
|
screenReaderMode: false,
|
||||||
macOptionIsMeta: false,
|
macOptionIsMeta: false,
|
||||||
macOptionClickForcesSelection: false,
|
macOptionClickForcesSelection: false,
|
||||||
minimumContrastRatio: 6,
|
minimumContrastRatio: 1,
|
||||||
disableStdin: false,
|
disableStdin: false,
|
||||||
allowTransparency: false,
|
allowTransparency: false,
|
||||||
tabStopWidth: 8,
|
tabStopWidth: 8,
|
||||||
|
|||||||
Reference in New Issue
Block a user