fix: change local tests to use chai asserts

This commit is contained in:
Beka Westberg
2022-03-01 17:31:36 +00:00
parent e276745b6b
commit fb57f18f90
3 changed files with 12 additions and 11 deletions

View File

@@ -126,11 +126,11 @@ const createCodeGenerationTestFn_ = (generator) => {
}
}
const assertFunc = (typeof testCase.expectedCode === 'string') ?
assert.equal : assert.match;
chai.assert.equal : chai.assert.match;
assertFunc(code, testCase.expectedCode);
if (!testCase.useWorkspaceToCode &&
testCase.expectedInnerOrder !== undefined) {
assert.equal(innerOrder, testCase.expectedInnerOrder);
chai.assert.equal(innerOrder, testCase.expectedInnerOrder);
}
};
};
@@ -190,7 +190,7 @@ const runSerializationTestSuite = (testCases) => {
testCase.json, this.workspace);
const generatedJson = Blockly.serialization.blocks.save(block);
const expectedJson = testCase.expectedJson || testCase.json;
assert.deepEqual(generatedJson, expectedJson);
chai.assert.deepEqual(generatedJson, expectedJson);
} else {
const block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
testCase.xml), this.workspace);
@@ -198,7 +198,7 @@ const runSerializationTestSuite = (testCases) => {
Blockly.Xml.domToPrettyText(
Blockly.Xml.blockToDom(block));
const expectedXml = testCase.expectedXml || testCase.xml;
assert.equal(generatedXml, expectedXml);
chai.assert.equal(generatedXml, expectedXml);
}
};
};

View File

@@ -75,9 +75,10 @@ function assertFieldValue(field, expectedValue, expectedText = undefined) {
if (expectedText === undefined) {
expectedText = String(expectedValue);
}
assert.equal(actualValue, expectedValue, 'Value');
assert.equal(actualText, expectedText, 'Text');
chai.assert.equal(actualValue, expectedValue, 'Value');
chai.assert.equal(actualText, expectedText, 'Text');
}
exports.assertFieldValue = assertFieldValue;
/**
* Runs provided creation test cases.
@@ -120,7 +121,7 @@ function runCreationTestsAssertThrows_(testCases, creation) {
*/
const createTestFn = (testCase) => {
return function() {
assert.throws(function() {
chai.assert.throws(function() {
creation.call(this, testCase);
}, testCase.errMsgMatcher);
};
@@ -156,7 +157,7 @@ function runConstructorSuiteTests(TestedField, validValueTestCases,
});
} else {
test('Empty', function() {
assert.throws(function() {
chai.assert.throws(function() {
customCreateWithJs ? customCreateWithJs.call(this) :
new TestedField();
});
@@ -211,7 +212,7 @@ function runFromJsonSuiteTests(TestedField, validValueTestCases,
});
} else {
test('Empty', function() {
assert.throws(function() {
chai.assert.throws(function() {
customCreateWithJson ? customCreateWithJson.call(this) :
TestedField.fromJson({});
});

View File

@@ -38,7 +38,7 @@ suite('Test Node.js', function() {
const headlessXml = Blockly.Xml.workspaceToDom(workspace, true);
const headlessText = Blockly.Xml.domToPrettyText(headlessXml);
assert.equal(headlessText, xmlText, 'equal');
chai.assert.equal(headlessText, xmlText, 'equal');
});
test('Generate Code', function() {
const xml = Blockly.Xml.textToDom(xmlText);
@@ -51,7 +51,7 @@ suite('Test Node.js', function() {
const code = Blockly.JavaScript.workspaceToCode(workspace);
// Check output
assert.equal('window.alert(\'Hello from Blockly!\');', code.trim(), 'equal');
chai.assert.equal('window.alert(\'Hello from Blockly!\');', code.trim(), 'equal');
});
});