Replace deprecated assert functions in test files. (#16945)

This commit is contained in:
Cory Rivera
2021-08-31 09:04:17 -07:00
committed by GitHub
parent de3ff30398
commit 0082031f97
79 changed files with 1960 additions and 1965 deletions

View File

@@ -11,48 +11,48 @@ suite('DOM Tests', () => {
test('Convert size should add px', () => {
const expected = '100px';
const actual = convertSize(100);
assert.equal(expected, actual);
assert.strictEqual(expected, actual);
});
test('Convert size should not add px if it already has it', () => {
const expected = '100px';
const actual = convertSize('100px');
assert.equal(expected, actual);
assert.strictEqual(expected, actual);
});
test('Convert size should not add px if it is a percent value', () => {
const expected = '100%';
const actual = convertSize('100%');
assert.equal(expected, actual);
assert.strictEqual(expected, actual);
});
test('Convert size should return the default value given undefined value', () => {
const expected = '200';
const actual = convertSize(undefined, '200');
assert.equal(expected, actual);
assert.strictEqual(expected, actual);
});
test('Convert to number should return size without px', () => {
const expected = 200;
const actual = convertSizeToNumber('200px');
assert.equal(expected, actual);
assert.strictEqual(expected, actual);
});
test('Convert to number should return same value if already plain text number', () => {
const expected = 200;
const actual = convertSizeToNumber('200');
assert.equal(expected, actual);
assert.strictEqual(expected, actual);
});
test('Convert to number should return same value if already plain number', () => {
const expected = 200;
const actual = convertSizeToNumber(200);
assert.equal(expected, actual);
assert.strictEqual(expected, actual);
});
test('Convert to number should return 0 given undefined', () => {
const expected = 0;
const actual = convertSizeToNumber(undefined);
assert.equal(expected, actual);
assert.strictEqual(expected, actual);
});
});

View File

@@ -59,7 +59,7 @@ suite.skip('ScrollableView', () => { // TODO chgagnon Fix these tests
test('creates empty view', () => {
const scrollableView = new ScrollableView(container);
scrollableView.layout(200, 200);
assert.equal(container.firstElementChild!.firstElementChild!.firstElementChild!.childElementCount, 0, 'view should be empty');
assert.strictEqual(container.firstElementChild!.firstElementChild!.firstElementChild!.childElementCount, 0, 'view should be empty');
scrollableView.dispose();
});
@@ -79,12 +79,12 @@ suite.skip('ScrollableView', () => { // TODO chgagnon Fix these tests
await waitForAnimation();
let viewQuery = getViewChildren(container);
assert.equal(viewQuery.length, 3, 'split view should have 3 views');
assert.strictEqual(viewQuery.length, 3, 'split view should have 3 views');
scrollableView.clear();
viewQuery = getViewChildren(container);
assert.equal(viewQuery.length, 0, 'split view should have no views');
assert.strictEqual(viewQuery.length, 0, 'split view should have no views');
view1.dispose();
view2.dispose();
@@ -104,22 +104,22 @@ suite.skip('ScrollableView', () => { // TODO chgagnon Fix these tests
await waitForAnimation();
assert.equal(view1.size, 200, 'view1 is entire size');
assert.strictEqual(view1.size, 200, 'view1 is entire size');
scrollableView.addView(view2);
await waitForAnimation();
assert.equal(view1.size, 100, 'view1 is half size');
assert.equal(view2.size, 100, 'view2 is half size');
assert.strictEqual(view1.size, 100, 'view1 is half size');
assert.strictEqual(view2.size, 100, 'view2 is half size');
scrollableView.addView(view3);
await waitForAnimation();
assert.equal(view1.size, 66, 'view1 is third size');
assert.equal(view2.size, 67, 'view2 is third size');
assert.equal(view3.size, 67, 'view3 is third size');
assert.strictEqual(view1.size, 66, 'view1 is third size');
assert.strictEqual(view2.size, 67, 'view2 is third size');
assert.strictEqual(view3.size, 67, 'view3 is third size');
});
test('honors minimum size', async () => {
@@ -134,9 +134,9 @@ suite.skip('ScrollableView', () => { // TODO chgagnon Fix these tests
await waitForAnimation();
assert.equal(view1.size, 100, 'view1 is minimum size');
assert.equal(view2.size, 100, 'view2 is minimum size');
assert.equal(view3.size, 0, 'view3 should not have been layout yet');
assert.strictEqual(view1.size, 100, 'view1 is minimum size');
assert.strictEqual(view2.size, 100, 'view2 is minimum size');
assert.strictEqual(view3.size, 0, 'view3 should not have been layout yet');
});
test('reacts to changes in views', async () => {
@@ -156,9 +156,9 @@ suite.skip('ScrollableView', () => { // TODO chgagnon Fix these tests
await waitForAnimation();
assert.equal(view1.size, 130, 'view1 should be 130');
assert.equal(view2.size, 100, 'view2 should still be minimum size');
assert.equal(view3.size, 0, 'view3 should not have been layout yet');
assert.strictEqual(view1.size, 130, 'view1 should be 130');
assert.strictEqual(view2.size, 100, 'view2 should still be minimum size');
assert.strictEqual(view3.size, 0, 'view3 should not have been layout yet');
});
test('programmatically scrolls', async () => {
@@ -173,18 +173,18 @@ suite.skip('ScrollableView', () => { // TODO chgagnon Fix these tests
await waitForAnimation();
assert.equal(view1.size, 100, 'view1 is minimum size');
assert.equal(view2.size, 100, 'view2 is minimum size');
assert.equal(view3.size, 0, 'view3 should not have been layout yet');
assert.equal(getViewChildren(container).length, 2, 'only 2 views are rendered');
assert.strictEqual(view1.size, 100, 'view1 is minimum size');
assert.strictEqual(view2.size, 100, 'view2 is minimum size');
assert.strictEqual(view3.size, 0, 'view3 should not have been layout yet');
assert.strictEqual(getViewChildren(container).length, 2, 'only 2 views are rendered');
scrollableView.setScrollTop(100);
await waitForAnimation();
assert.equal(view2.size, 100, 'view2 is minimum size');
assert.equal(view3.size, 100, 'view3 is minimum size');
assert.equal(getViewChildren(container).length, 2, 'only 2 views are rendered');
assert.strictEqual(view2.size, 100, 'view2 is minimum size');
assert.strictEqual(view3.size, 100, 'view3 is minimum size');
assert.strictEqual(getViewChildren(container).length, 2, 'only 2 views are rendered');
});
});

View File

@@ -37,6 +37,6 @@ function verifyFormattedHtml(formattedHtml: string, expectedText: string): void
let spanElement = element.children[0];
// Verify that the span element's text, not its innerHTML, matches the expected text
assert.equal(spanElement.textContent, testText);
assert.notEqual(spanElement.innerHTML, testText);
assert.strictEqual(spanElement.textContent, testText);
assert.notStrictEqual(spanElement.innerHTML, testText);
}

View File

@@ -35,13 +35,13 @@ suite('TableDataView', () => {
expectedFilterStateChangeInvokeCount: number,
stepName: string,
verifyRowCountEventParameter: boolean = true) => {
assert.equal(rowCountEventInvokeCount, expectedRowCountChangeInvokeCount, 'RowCountChange event count - ' + stepName);
assert.strictEqual(rowCountEventInvokeCount, expectedRowCountChangeInvokeCount, 'RowCountChange event count - ' + stepName);
if (verifyRowCountEventParameter) {
assert.equal(rowCountEventParameter, expectedDataLength, 'Row count passed by RowCountChange event - ' + stepName);
assert.strictEqual(rowCountEventParameter, expectedDataLength, 'Row count passed by RowCountChange event - ' + stepName);
}
assert.equal(obj.getLength(), expectedDataLength, 'Data length - ' + stepName);
assert.equal(obj.getLengthNonFiltered(), expectedNonFilteredDataLength, 'Length for all data - ' + stepName);
assert.equal(filterStateChangeEventInvokeCount, expectedFilterStateChangeInvokeCount, 'FilterStateChange event count - ' + stepName);
assert.strictEqual(obj.getLength(), expectedDataLength, 'Data length - ' + stepName);
assert.strictEqual(obj.getLengthNonFiltered(), expectedNonFilteredDataLength, 'Length for all data - ' + stepName);
assert.strictEqual(filterStateChangeEventInvokeCount, expectedFilterStateChangeInvokeCount, 'FilterStateChange event count - ' + stepName);
};
verify(0, rowCount, rowCount, 0, 'after initialization', false);
@@ -95,18 +95,18 @@ suite('TableDataView', () => {
const dataView = new TableDataView(originalData, searchFn);
let findValue = await dataView.find('row 2');
assert.deepEqual(findValue, { row: 2, col: 0 });
assert.deepStrictEqual(findValue, { row: 2, col: 0 });
findValue = await dataView.findNext();
assert.deepEqual(findValue, { row: 2, col: 1 });
assert.deepStrictEqual(findValue, { row: 2, col: 1 });
findValue = await dataView.findNext();
assert.deepEqual(findValue, { row: 2, col: 2 });
assert.deepStrictEqual(findValue, { row: 2, col: 2 });
findValue = await dataView.findNext();
assert.deepEqual(findValue, { row: 2, col: 3 });
assert.deepStrictEqual(findValue, { row: 2, col: 3 });
findValue = await dataView.findNext();
assert.deepEqual(findValue, { row: 2, col: 4 });
assert.deepStrictEqual(findValue, { row: 2, col: 4 });
// find will loop around once it reaches the end
findValue = await dataView.findNext();
assert.deepEqual(findValue, { row: 2, col: 0 });
assert.deepStrictEqual(findValue, { row: 2, col: 0 });
});
test('Search fails correctly', async () => {
@@ -166,12 +166,12 @@ suite('TableDataView', () => {
const dataView = new TableDataView(originalData, searchFn);
let findValue = await dataView.find('row 2', 2);
assert.deepEqual(findValue, { row: 2, col: 0 });
assert.deepStrictEqual(findValue, { row: 2, col: 0 });
findValue = await dataView.findNext();
assert.deepEqual(findValue, { row: 2, col: 1 });
assert.deepStrictEqual(findValue, { row: 2, col: 1 });
// find will loop around once it reaches the end
findValue = await dataView.findNext();
assert.deepEqual(findValue, { row: 2, col: 0 });
assert.deepStrictEqual(findValue, { row: 2, col: 0 });
});
});

View File

@@ -24,7 +24,7 @@ export class EventVerifierSingle<T> {
public assertFired(expectedArgument?: T) {
assert.ok(this._eventFired);
if (expectedArgument) {
assert.equal(this._eventArgument, expectedArgument);
assert.strictEqual(this._eventArgument, expectedArgument);
}
}
@@ -34,7 +34,7 @@ export class EventVerifierSingle<T> {
}
public assertNotFired() {
assert.equal(this._eventFired, false);
assert.strictEqual(this._eventFired, false);
}
public get eventHandler(): (arg: T) => void {