diff --git a/package-lock.json b/package-lock.json index c797446b5..1a68ab82b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "@microsoft/api-extractor": "^7.29.5", "@typescript-eslint/eslint-plugin": "^7.3.1", "async-done": "^2.0.0", - "chai": "^4.2.0", + "chai": "^5.1.1", "concurrently": "^8.0.1", "eslint": "^8.4.1", "eslint-config-google": "^0.14.0", @@ -114,6 +114,75 @@ "blockly": "^10.0.0" } }, + "node_modules/@blockly/dev-tools/node_modules/assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/@blockly/dev-tools/node_modules/chai": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.1.tgz", + "integrity": "sha512-13sOfMv2+DWduEU+/xbun3LScLoqN17nBeTLUsmDfKdoiC1fr0n9PU4guu4AhRcOVFk/sW8LyZWHuhWtQZiF+g==", + "dev": true, + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.3", + "deep-eql": "^4.1.3", + "get-func-name": "^2.0.2", + "loupe": "^2.3.6", + "pathval": "^1.1.1", + "type-detect": "^4.0.8" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@blockly/dev-tools/node_modules/check-error": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", + "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", + "dev": true, + "dependencies": { + "get-func-name": "^2.0.2" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@blockly/dev-tools/node_modules/deep-eql": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.4.tgz", + "integrity": "sha512-SUwdGfqdKOwxCPeVYjwSyRpJ7Z+fhpwIAtmCUdZIWZ/YP5R9WAsyuSgpLVDi9bjWoN2LXHNss/dk3urXtdQxGg==", + "dev": true, + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/@blockly/dev-tools/node_modules/loupe": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", + "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==", + "dev": true, + "dependencies": { + "get-func-name": "^2.0.1" + } + }, + "node_modules/@blockly/dev-tools/node_modules/pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "dev": true, + "engines": { + "node": "*" + } + }, "node_modules/@blockly/theme-dark": { "version": "6.0.5", "resolved": "https://registry.npmjs.org/@blockly/theme-dark/-/theme-dark-6.0.5.tgz", @@ -2521,12 +2590,12 @@ } }, "node_modules/assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", "dev": true, "engines": { - "node": "*" + "node": ">=12" } }, "node_modules/assign-symbols": { @@ -3169,21 +3238,19 @@ } }, "node_modules/chai": { - "version": "4.3.10", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.10.tgz", - "integrity": "sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.1.tgz", + "integrity": "sha512-pT1ZgP8rPNqUgieVaEY+ryQr6Q4HXNg8Ei9UnLUrjN4IA7dvQC5JB+/kxVcPNDHyBcc/26CXPkbNzq3qwrOEKA==", "dev": true, "dependencies": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.3", - "deep-eql": "^4.1.3", - "get-func-name": "^2.0.2", - "loupe": "^2.3.6", - "pathval": "^1.1.1", - "type-detect": "^4.0.8" + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" }, "engines": { - "node": ">=4" + "node": ">=12" } }, "node_modules/chalk": { @@ -3203,15 +3270,12 @@ } }, "node_modules/check-error": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", - "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", + "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", "dev": true, - "dependencies": { - "get-func-name": "^2.0.2" - }, "engines": { - "node": "*" + "node": ">= 16" } }, "node_modules/chokidar": { @@ -4072,13 +4136,10 @@ } }, "node_modules/deep-eql": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", - "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", "dev": true, - "dependencies": { - "type-detect": "^4.0.0" - }, "engines": { "node": ">=6" } @@ -8242,9 +8303,9 @@ "dev": true }, "node_modules/loupe": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", - "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.1.tgz", + "integrity": "sha512-edNu/8D5MKVfGVFRhFf8aAxiTM6Wumfz5XsaatSxlD3w4R1d/WEKUTydCdPGbl9K7QG/Ca3GnDV2sIKIpXRQcw==", "dev": true, "dependencies": { "get-func-name": "^2.0.1" @@ -9612,12 +9673,12 @@ } }, "node_modules/pathval": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", + "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", "dev": true, "engines": { - "node": "*" + "node": ">= 14.16" } }, "node_modules/pend": { diff --git a/package.json b/package.json index f7f7f124a..a972f4e1e 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "@microsoft/api-extractor": "^7.29.5", "@typescript-eslint/eslint-plugin": "^7.3.1", "async-done": "^2.0.0", - "chai": "^4.2.0", + "chai": "^5.1.1", "concurrently": "^8.0.1", "eslint": "^8.4.1", "eslint-config-google": "^0.14.0", diff --git a/tests/browser/.mocharc.js b/tests/browser/.mocharc.js index b11a846fb..879bb4623 100644 --- a/tests/browser/.mocharc.js +++ b/tests/browser/.mocharc.js @@ -2,5 +2,5 @@ module.exports = { ui: 'tdd', - require: __dirname + '/test/hooks.js', + require: __dirname + '/test/hooks.mjs', }; diff --git a/tests/browser/test/basic_block_factory_test.js b/tests/browser/test/basic_block_factory_test.mjs similarity index 93% rename from tests/browser/test/basic_block_factory_test.js rename to tests/browser/test/basic_block_factory_test.mjs index 026f25659..e20892471 100644 --- a/tests/browser/test/basic_block_factory_test.js +++ b/tests/browser/test/basic_block_factory_test.mjs @@ -8,8 +8,8 @@ * @fileoverview Node.js script to run Automated tests in Chrome, via webdriver. */ -const chai = require('chai'); -const {testSetup, testFileLocations} = require('./test_setup'); +import * as chai from 'chai'; +import {testSetup, testFileLocations} from './test_setup.mjs'; suite('Testing Connecting Blocks', function (done) { // Setting timeout to unlimited as the webdriver takes a longer time to run than most mocha test diff --git a/tests/browser/test/basic_block_test.js b/tests/browser/test/basic_block_test.mjs similarity index 89% rename from tests/browser/test/basic_block_test.js rename to tests/browser/test/basic_block_test.mjs index 7d594c50e..515cf5668 100644 --- a/tests/browser/test/basic_block_test.js +++ b/tests/browser/test/basic_block_test.mjs @@ -9,14 +9,14 @@ * webdriver, of basic Blockly block functionality. */ -const chai = require('chai'); -const { +import * as chai from 'chai'; +import { testSetup, testFileLocations, getAllBlocks, dragNthBlockFromFlyout, -} = require('./test_setup'); -const {Key} = require('webdriverio'); +} from './test_setup.mjs'; +import {Key} from 'webdriverio'; suite('Basic block tests', function (done) { // Setting timeout to unlimited as the webdriver takes a longer time diff --git a/tests/browser/test/basic_playground_test.js b/tests/browser/test/basic_playground_test.mjs similarity index 98% rename from tests/browser/test/basic_playground_test.js rename to tests/browser/test/basic_playground_test.mjs index 091f2f6b5..11ad7a368 100644 --- a/tests/browser/test/basic_playground_test.js +++ b/tests/browser/test/basic_playground_test.mjs @@ -8,8 +8,8 @@ * @fileoverview Node.js script to run Automated tests in Chrome, via webdriver. */ -const chai = require('chai'); -const { +import * as chai from 'chai'; +import { testSetup, testFileLocations, dragNthBlockFromFlyout, @@ -17,7 +17,7 @@ const { connect, contextMenuSelect, PAUSE_TIME, -} = require('./test_setup'); +} from './test_setup.mjs'; async function getIsCollapsed(browser, blockId) { return await browser.execute((blockId) => { diff --git a/tests/browser/test/block_undo_test.js b/tests/browser/test/block_undo_test.mjs similarity index 91% rename from tests/browser/test/block_undo_test.js rename to tests/browser/test/block_undo_test.mjs index 3dc5babc5..1c96422dc 100644 --- a/tests/browser/test/block_undo_test.js +++ b/tests/browser/test/block_undo_test.mjs @@ -8,15 +8,15 @@ * @fileoverview Node.js script to run Automated tests in Chrome, via webdriver. */ -const chai = require('chai'); -const {Key} = require('webdriverio'); -const { +import * as chai from 'chai'; +import {Key} from 'webdriverio'; +import { testSetup, testFileLocations, dragBlockTypeFromFlyout, screenDirection, getAllBlocks, -} = require('./test_setup'); +} from './test_setup.mjs'; suite('Testing undo block movement', function (done) { // Setting timeout to unlimited as the webdriver takes a longer time to run than most mocha test diff --git a/tests/browser/test/delete_blocks_test.js b/tests/browser/test/delete_blocks_test.mjs similarity index 98% rename from tests/browser/test/delete_blocks_test.js rename to tests/browser/test/delete_blocks_test.mjs index b25c096a1..1e560dcce 100644 --- a/tests/browser/test/delete_blocks_test.js +++ b/tests/browser/test/delete_blocks_test.mjs @@ -4,8 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -const chai = require('chai'); -const { +import * as chai from 'chai'; +import { testSetup, testFileLocations, getAllBlocks, @@ -13,8 +13,8 @@ const { clickBlock, contextMenuSelect, PAUSE_TIME, -} = require('./test_setup'); -const {Key} = require('webdriverio'); +} from './test_setup.mjs'; +import {Key} from 'webdriverio'; const firstBlockId = 'root_block'; const startBlocks = { diff --git a/tests/browser/test/extensive_test.js b/tests/browser/test/extensive_test.mjs similarity index 98% rename from tests/browser/test/extensive_test.js rename to tests/browser/test/extensive_test.mjs index b16a06bbc..2b1245d2a 100644 --- a/tests/browser/test/extensive_test.js +++ b/tests/browser/test/extensive_test.mjs @@ -8,15 +8,15 @@ * @fileoverview Node.js script to run Automated tests in Chrome, via webdriver. */ -const chai = require('chai'); -const { +import * as chai from 'chai'; +import { testSetup, testFileLocations, getBlockElementById, getAllBlocks, PAUSE_TIME, -} = require('./test_setup'); -const {Key} = require('webdriverio'); +} from './test_setup.mjs'; +import {Key} from 'webdriverio'; suite('This tests loading Large Configuration and Deletion', function (done) { // Setting timeout to unlimited as the webdriver takes a longer time to run than most mocha test diff --git a/tests/browser/test/field_edits_test.js b/tests/browser/test/field_edits_test.mjs similarity index 93% rename from tests/browser/test/field_edits_test.js rename to tests/browser/test/field_edits_test.mjs index bad2e10ed..a4dbbb823 100644 --- a/tests/browser/test/field_edits_test.js +++ b/tests/browser/test/field_edits_test.mjs @@ -8,15 +8,15 @@ * @fileoverview Node.js script to run Automated tests in Chrome, via webdriver. */ -const chai = require('chai'); -const { +import * as chai from 'chai'; +import { testSetup, testFileLocations, dragBlockTypeFromFlyout, screenDirection, clickWorkspace, -} = require('./test_setup'); -const {Key} = require('webdriverio'); +} from './test_setup.mjs'; +import {Key} from 'webdriverio'; suite('Testing Field Edits', function (done) { // Setting timeout to unlimited as the webdriver takes a longer time to run than most mocha test diff --git a/tests/browser/test/hooks.js b/tests/browser/test/hooks.mjs similarity index 80% rename from tests/browser/test/hooks.js rename to tests/browser/test/hooks.mjs index a7f08ed56..5b8615006 100644 --- a/tests/browser/test/hooks.js +++ b/tests/browser/test/hooks.mjs @@ -9,9 +9,9 @@ * These create a shared chromedriver instance, so we don't have to fire up * a new one for every suite. */ -const {driverSetup, driverTeardown} = require('./test_setup'); +import {driverSetup, driverTeardown} from './test_setup.mjs'; -const mochaHooks = { +export const mochaHooks = { async beforeAll() { // Set a long timeout for startup. this.timeout(10000); @@ -21,5 +21,3 @@ const mochaHooks = { return await driverTeardown(); }, }; - -module.exports = {mochaHooks}; diff --git a/tests/browser/test/mutator_test.js b/tests/browser/test/mutator_test.mjs similarity index 97% rename from tests/browser/test/mutator_test.js rename to tests/browser/test/mutator_test.mjs index 93e698af6..46bc2abbe 100644 --- a/tests/browser/test/mutator_test.js +++ b/tests/browser/test/mutator_test.mjs @@ -4,8 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -const chai = require('chai'); -const { +import * as chai from 'chai'; +import { testSetup, testFileLocations, connect, @@ -15,7 +15,7 @@ const { getBlockElementById, dragBlockFromMutatorFlyout, openMutatorForBlock, -} = require('./test_setup'); +} from './test_setup.mjs'; suite('Mutating a block', function (done) { this.timeout(0); diff --git a/tests/browser/test/procedure_test.js b/tests/browser/test/procedure_test.mjs similarity index 97% rename from tests/browser/test/procedure_test.js rename to tests/browser/test/procedure_test.mjs index c36cb9185..4c0e0897c 100644 --- a/tests/browser/test/procedure_test.js +++ b/tests/browser/test/procedure_test.mjs @@ -8,8 +8,8 @@ * @fileoverview Node.js script to run Automated tests in Chrome, via webdriver. */ -const chai = require('chai'); -const { +import * as chai from 'chai'; +import { testSetup, testFileLocations, getSelectedBlockElement, @@ -17,7 +17,7 @@ const { getBlockTypeFromCategory, connect, PAUSE_TIME, -} = require('./test_setup'); +} from './test_setup.mjs'; suite('Testing Connecting Blocks', function (done) { // Setting timeout to unlimited as the webdriver takes a longer time to run than most mocha test diff --git a/tests/browser/test/test_setup.js b/tests/browser/test/test_setup.mjs similarity index 90% rename from tests/browser/test/test_setup.js rename to tests/browser/test/test_setup.mjs index a07b274e4..3888815df 100644 --- a/tests/browser/test/test_setup.js +++ b/tests/browser/test/test_setup.mjs @@ -16,9 +16,10 @@ * identifiers that Selenium can use to find those elements. */ -const webdriverio = require('webdriverio'); -const path = require('path'); -const {posixPath} = require('../../../scripts/helpers'); +import * as webdriverio from 'webdriverio'; +import * as path from 'path'; +import {fileURLToPath} from 'url'; +import {posixPath} from '../../../scripts/helpers.js'; let driver = null; @@ -26,14 +27,14 @@ let driver = null; * The default amount of time to wait during a test. Increase this to make * tests easier to watch; decrease it to make tests run faster. */ -const PAUSE_TIME = 50; +export const PAUSE_TIME = 50; /** * Start up the test page. This should only be done once, to avoid * constantly popping browser windows open and closed. * @return A Promsie that resolves to a webdriverIO browser that tests can manipulate. */ -async function driverSetup() { +export async function driverSetup() { const options = { capabilities: { 'browserName': 'chrome', @@ -67,7 +68,7 @@ async function driverSetup() { * End the webdriverIO session. * @return A Promise that resolves after the actions have been completed. */ -async function driverTeardown() { +export async function driverTeardown() { await driver.deleteSession(); driver = null; return; @@ -79,7 +80,7 @@ async function driverTeardown() { * a Blockly playground with a workspace. * @return A Promsie that resolves to a webdriverIO browser that tests can manipulate. */ -async function testSetup(playgroundUrl) { +export async function testSetup(playgroundUrl) { if (!driver) { await driverSetup(); } @@ -91,7 +92,9 @@ async function testSetup(playgroundUrl) { return driver; } -const testFileLocations = { +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +export const testFileLocations = { BLOCK_FACTORY: 'file://' + posixPath(path.join(__dirname, '..', '..', '..', 'demos', 'blockfactory')) + @@ -116,7 +119,7 @@ const testFileLocations = { * @readonly * @enum {number} */ -const screenDirection = { +export const screenDirection = { RTL: -1, LTR: 1, }; @@ -125,7 +128,7 @@ const screenDirection = { * @param browser The active WebdriverIO Browser object. * @return A Promise that resolves to the ID of the currently selected block. */ -async function getSelectedBlockId(browser) { +export async function getSelectedBlockId(browser) { return await browser.execute(() => { // Note: selected is an ICopyable and I am assuming that it is a BlockSvg. return Blockly.common.getSelected()?.id; @@ -137,7 +140,7 @@ async function getSelectedBlockId(browser) { * @return A Promise that resolves to the selected block's root SVG element, * as an interactable browser element. */ -async function getSelectedBlockElement(browser) { +export async function getSelectedBlockElement(browser) { const id = await getSelectedBlockId(browser); return getBlockElementById(browser, id); } @@ -148,7 +151,7 @@ async function getSelectedBlockElement(browser) { * @return A Promise that resolves to the root SVG element of the block with * the given ID, as an interactable browser element. */ -async function getBlockElementById(browser, id) { +export async function getBlockElementById(browser, id) { const elem = await browser.$(`[data-id="${id}"]`); elem['id'] = id; return elem; @@ -165,7 +168,7 @@ async function getBlockElementById(browser, id) { * @param clickOptions The options to pass to webdriverio's element.click function. * @return A Promise that resolves when the actions are completed. */ -async function clickBlock(browser, block, clickOptions) { +export async function clickBlock(browser, block, clickOptions) { const findableId = 'clickTargetElement'; // In the browser context, find the element that we want and give it a findable ID. await browser.execute( @@ -203,7 +206,7 @@ async function clickBlock(browser, block, clickOptions) { * @param browser The active WebdriverIO Browser object. * @return A Promise that resolves when the actions are completed. */ -async function clickWorkspace(browser) { +export async function clickWorkspace(browser) { const workspace = await browser.$('#blocklyDiv > div > svg.blocklySvg > g'); await workspace.click(); await browser.pause(PAUSE_TIME); @@ -215,7 +218,7 @@ async function clickWorkspace(browser) { * @return A Promise that resolves when the actions are completed. * @throws If the mutator workspace cannot be found. */ -async function clickMutatorWorkspace(browser) { +export async function clickMutatorWorkspace(browser) { const hasMutator = await browser.$('.blocklyMutatorBackground'); if (!hasMutator) { throw new Error('No mutator workspace found'); @@ -234,7 +237,7 @@ async function clickMutatorWorkspace(browser) { * category with the given name, as an interactable browser element. * @throws If the category cannot be found. */ -async function getCategory(browser, categoryName) { +export async function getCategory(browser, categoryName) { const category = browser.$(`.blocklyToolboxCategory*=${categoryName}`); category.waitForExist(); @@ -248,7 +251,7 @@ async function getCategory(browser, categoryName) { * @return A Promise that resolves to the root element of the nth * block in the given category. */ -async function getNthBlockOfCategory(browser, categoryName, n) { +export async function getNthBlockOfCategory(browser, categoryName, n) { const category = await getCategory(browser, categoryName); await category.click(); const block = await browser.$( @@ -265,7 +268,11 @@ async function getNthBlockOfCategory(browser, categoryName, n) { * @return A Promise that resolves to the root element of the first * block with the given type in the given category. */ -async function getBlockTypeFromCategory(browser, categoryName, blockType) { +export async function getBlockTypeFromCategory( + browser, + categoryName, + blockType, +) { if (categoryName) { const category = await getCategory(browser, categoryName); await category.click(); @@ -287,7 +294,7 @@ async function getBlockTypeFromCategory(browser, categoryName, blockType) { * @return A Promise that resolves to the root element of the block with the * given position and type on the workspace. */ -async function getBlockTypeFromWorkspace(browser, blockType, position) { +export async function getBlockTypeFromWorkspace(browser, blockType, position) { const id = await browser.execute( (blockType, position) => { return Blockly.getMainWorkspace().getBlocksByType(blockType, true)[ @@ -372,7 +379,7 @@ async function getLocationOfBlockConnection( * @param dragBlockSelector The selector of the block to drag * @return A Promise that resolves when the actions are completed. */ -async function connect( +export async function connect( browser, draggedBlock, draggedConnection, @@ -411,7 +418,7 @@ async function connect( * @param browser The active WebdriverIO Browser object. * @return A Promise that resolves when the actions are completed. */ -async function switchRTL(browser) { +export async function switchRTL(browser) { const ltrForm = await browser.$('#options > select:nth-child(1)'); await ltrForm.selectByIndex(1); await browser.pause(PAUSE_TIME + 450); @@ -431,7 +438,7 @@ async function switchRTL(browser) { * @return A Promise that resolves to the root element of the newly * created block. */ -async function dragNthBlockFromFlyout(browser, categoryName, n, x, y) { +export async function dragNthBlockFromFlyout(browser, categoryName, n, x, y) { const flyoutBlock = await getNthBlockOfCategory(browser, categoryName, n); await flyoutBlock.dragAndDrop({x: x, y: y}); return await getSelectedBlockElement(browser); @@ -452,7 +459,13 @@ async function dragNthBlockFromFlyout(browser, categoryName, n, x, y) { * @return A Promise that resolves to the root element of the newly * created block. */ -async function dragBlockTypeFromFlyout(browser, categoryName, type, x, y) { +export async function dragBlockTypeFromFlyout( + browser, + categoryName, + type, + x, + y, +) { const flyoutBlock = await getBlockTypeFromCategory( browser, categoryName, @@ -477,7 +490,13 @@ async function dragBlockTypeFromFlyout(browser, categoryName, type, x, y) { * @return A Promise that resolves to the root element of the newly * created block. */ -async function dragBlockFromMutatorFlyout(browser, mutatorBlock, type, x, y) { +export async function dragBlockFromMutatorFlyout( + browser, + mutatorBlock, + type, + x, + y, +) { const id = await browser.execute( (mutatorBlockId, blockType) => { return Blockly.getMainWorkspace() @@ -505,7 +524,7 @@ async function dragBlockFromMutatorFlyout(browser, mutatorBlock, type, x, y) { * @param itemText The display text of the context menu item to click. * @return A Promise that resolves when the actions are completed. */ -async function contextMenuSelect(browser, block, itemText) { +export async function contextMenuSelect(browser, block, itemText) { await clickBlock(browser, block, {button: 2}); const item = await browser.$(`div=${itemText}`); @@ -522,7 +541,7 @@ async function contextMenuSelect(browser, block, itemText) { * @param block The block to click, as an interactable element. * @return A Promise that resolves when the actions are complete. */ -async function openMutatorForBlock(browser, block) { +export async function openMutatorForBlock(browser, block) { const icon = await browser.$(`[data-id="${block.id}"] > g.blocklyIconGroup`); await icon.click(); } @@ -535,7 +554,7 @@ async function openMutatorForBlock(browser, block) { * @param browser The active WebdriverIO Browser object. * @return A Promise that resolves to an array of blocks on the main workspace. */ -async function getAllBlocks(browser) { +export async function getAllBlocks(browser) { return browser.execute(() => { return Blockly.getMainWorkspace() .getAllBlocks(false) @@ -556,7 +575,7 @@ async function getAllBlocks(browser) { * @param yDelta How far to drag the flyout in the y direction. Positive is down. * @return A Promise that resolves when the actions are completed. */ -async function scrollFlyout(browser, xDelta, yDelta) { +export async function scrollFlyout(browser, xDelta, yDelta) { // There are two flyouts on the playground workspace: one for the trash can // and one for the toolbox. We want the second one. // This assumes there is only one scrollbar handle in the flyout, but it could @@ -568,31 +587,3 @@ async function scrollFlyout(browser, xDelta, yDelta) { await scrollbarHandle.dragAndDrop({x: xDelta, y: yDelta}); await browser.pause(PAUSE_TIME); } - -module.exports = { - testSetup, - testFileLocations, - driverSetup, - driverTeardown, - getSelectedBlockElement, - getSelectedBlockId, - getBlockElementById, - clickBlock, - clickWorkspace, - clickMutatorWorkspace, - getCategory, - getNthBlockOfCategory, - getBlockTypeFromCategory, - dragNthBlockFromFlyout, - dragBlockTypeFromFlyout, - dragBlockFromMutatorFlyout, - connect, - switchRTL, - contextMenuSelect, - openMutatorForBlock, - screenDirection, - getBlockTypeFromWorkspace, - getAllBlocks, - scrollFlyout, - PAUSE_TIME, -}; diff --git a/tests/browser/test/toolbox_drag_test.js b/tests/browser/test/toolbox_drag_test.mjs similarity index 98% rename from tests/browser/test/toolbox_drag_test.js rename to tests/browser/test/toolbox_drag_test.mjs index 14a9f0836..ab0fa828f 100644 --- a/tests/browser/test/toolbox_drag_test.js +++ b/tests/browser/test/toolbox_drag_test.mjs @@ -8,15 +8,15 @@ * @fileoverview Tests for the dragging out of the toolbox and flyout. */ -const chai = require('chai'); -const { +import * as chai from 'chai'; +import { testSetup, testFileLocations, getCategory, scrollFlyout, screenDirection, PAUSE_TIME, -} = require('./test_setup'); +} from './test_setup.mjs'; // Categories in the basic toolbox. const basicCategories = [ diff --git a/tests/browser/test/workspace_comment_test.js b/tests/browser/test/workspace_comment_test.mjs similarity index 97% rename from tests/browser/test/workspace_comment_test.js rename to tests/browser/test/workspace_comment_test.mjs index b6adfebcd..0a7b12bf7 100644 --- a/tests/browser/test/workspace_comment_test.js +++ b/tests/browser/test/workspace_comment_test.mjs @@ -4,10 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -const chai = require('chai'); -const sinon = require('sinon'); -const {Key} = require('webdriverio'); -const {testSetup, testFileLocations} = require('./test_setup'); +import * as chai from 'chai'; +import * as sinon from 'sinon'; +import {Key} from 'webdriverio'; +import {testSetup, testFileLocations} from './test_setup.mjs'; suite('Workspace comments', function () { // Setting timeout to unlimited as the webdriver takes a longer time diff --git a/tests/mocha/astnode_test.js b/tests/mocha/astnode_test.js index a9f0de0d3..4c449b7fa 100644 --- a/tests/mocha/astnode_test.js +++ b/tests/mocha/astnode_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import {ASTNode} from '../../build/src/core/keyboard_nav/ast_node.js'; import { sharedTestSetup, @@ -110,7 +111,7 @@ suite('ASTNode', function () { const connection = input.connection; const node = ASTNode.createConnectionNode(connection); const newASTNode = node.findNextForInput(input); - chai.assert.equal(newASTNode.getLocation(), input2.connection); + assert.equal(newASTNode.getLocation(), input2.connection); }); test('findPrevForInput', function () { @@ -119,7 +120,7 @@ suite('ASTNode', function () { const connection = input2.connection; const node = ASTNode.createConnectionNode(connection); const newASTNode = node.findPrevForInput(input2); - chai.assert.equal(newASTNode.getLocation(), input.connection); + assert.equal(newASTNode.getLocation(), input.connection); }); test('findNextForField', function () { @@ -127,7 +128,7 @@ suite('ASTNode', function () { const field2 = this.blocks.statementInput1.inputList[0].fieldRow[1]; const node = ASTNode.createFieldNode(field); const newASTNode = node.findNextForField(field); - chai.assert.equal(newASTNode.getLocation(), field2); + assert.equal(newASTNode.getLocation(), field2); }); test('findPrevForField', function () { @@ -135,7 +136,7 @@ suite('ASTNode', function () { const field2 = this.blocks.statementInput1.inputList[0].fieldRow[1]; const node = ASTNode.createFieldNode(field2); const newASTNode = node.findPrevForField(field2); - chai.assert.equal(newASTNode.getLocation(), field); + assert.equal(newASTNode.getLocation(), field); }); test('navigateBetweenStacks_Forward', function () { @@ -144,7 +145,7 @@ suite('ASTNode', function () { this.blocks.statementInput1.nextConnection, ); const newASTNode = node.navigateBetweenStacks(true); - chai.assert.equal(newASTNode.getLocation(), this.blocks.statementInput4); + assert.equal(newASTNode.getLocation(), this.blocks.statementInput4); }); test('navigateBetweenStacks_Backward', function () { @@ -153,7 +154,7 @@ suite('ASTNode', function () { this.blocks.statementInput4, ); const newASTNode = node.navigateBetweenStacks(false); - chai.assert.equal(newASTNode.getLocation(), this.blocks.statementInput1); + assert.equal(newASTNode.getLocation(), this.blocks.statementInput1); }); test('getOutAstNodeForBlock', function () { const node = new ASTNode( @@ -163,7 +164,7 @@ suite('ASTNode', function () { const newASTNode = node.getOutAstNodeForBlock( this.blocks.statementInput2, ); - chai.assert.equal(newASTNode.getLocation(), this.blocks.statementInput1); + assert.equal(newASTNode.getLocation(), this.blocks.statementInput1); }); test('getOutAstNodeForBlock_OneBlock', function () { const node = new ASTNode( @@ -173,7 +174,7 @@ suite('ASTNode', function () { const newASTNode = node.getOutAstNodeForBlock( this.blocks.statementInput4, ); - chai.assert.equal(newASTNode.getLocation(), this.blocks.statementInput4); + assert.equal(newASTNode.getLocation(), this.blocks.statementInput4); }); test('findFirstFieldOrInput_', function () { const node = new ASTNode( @@ -184,7 +185,7 @@ suite('ASTNode', function () { const newASTNode = node.findFirstFieldOrInput( this.blocks.statementInput4, ); - chai.assert.equal(newASTNode.getLocation(), field); + assert.equal(newASTNode.getLocation(), field); }); }); @@ -345,31 +346,31 @@ suite('ASTNode', function () { const prevConnection = this.blocks.statementInput1.previousConnection; const node = ASTNode.createConnectionNode(prevConnection); const nextNode = node.next(); - chai.assert.equal(nextNode.getLocation(), this.blocks.statementInput1); + assert.equal(nextNode.getLocation(), this.blocks.statementInput1); }); test('fromBlockToNext', function () { const nextConnection = this.blocks.statementInput1.nextConnection; const node = ASTNode.createBlockNode(this.blocks.statementInput1); const nextNode = node.next(); - chai.assert.equal(nextNode.getLocation(), nextConnection); + assert.equal(nextNode.getLocation(), nextConnection); }); test('fromBlockToNull', function () { const node = ASTNode.createBlockNode(this.blocks.noNextConnection); const nextNode = node.next(); - chai.assert.isNull(nextNode); + assert.isNull(nextNode); }); test('fromNextToPrevious', function () { const nextConnection = this.blocks.statementInput1.nextConnection; const prevConnection = this.blocks.statementInput2.previousConnection; const node = ASTNode.createConnectionNode(nextConnection); const nextNode = node.next(); - chai.assert.equal(nextNode.getLocation(), prevConnection); + assert.equal(nextNode.getLocation(), prevConnection); }); test('fromNextToNull', function () { const nextConnection = this.blocks.statementInput2.nextConnection; const node = ASTNode.createConnectionNode(nextConnection); const nextNode = node.next(); - chai.assert.isNull(nextNode); + assert.isNull(nextNode); }); test('fromInputToInput', function () { const input = this.blocks.statementInput1.inputList[0]; @@ -377,7 +378,7 @@ suite('ASTNode', function () { this.blocks.statementInput1.inputList[1].connection; const node = ASTNode.createInputNode(input); const nextNode = node.next(); - chai.assert.equal(nextNode.getLocation(), inputConnection); + assert.equal(nextNode.getLocation(), inputConnection); }); test('fromInputToStatementInput', function () { const input = this.blocks.fieldAndInputs2.inputList[1]; @@ -385,26 +386,26 @@ suite('ASTNode', function () { this.blocks.fieldAndInputs2.inputList[2].connection; const node = ASTNode.createInputNode(input); const nextNode = node.next(); - chai.assert.equal(nextNode.getLocation(), inputConnection); + assert.equal(nextNode.getLocation(), inputConnection); }); test('fromInputToField', function () { const input = this.blocks.fieldAndInputs2.inputList[0]; const field = this.blocks.fieldAndInputs2.inputList[1].fieldRow[0]; const node = ASTNode.createInputNode(input); const nextNode = node.next(); - chai.assert.equal(nextNode.getLocation(), field); + assert.equal(nextNode.getLocation(), field); }); test('fromInputToNull', function () { const input = this.blocks.fieldAndInputs2.inputList[2]; const node = ASTNode.createInputNode(input); const nextNode = node.next(); - chai.assert.isNull(nextNode); + assert.isNull(nextNode); }); test('fromOutputToBlock', function () { const output = this.blocks.fieldWithOutput.outputConnection; const node = ASTNode.createConnectionNode(output); const nextNode = node.next(); - chai.assert.equal(nextNode.getLocation(), this.blocks.fieldWithOutput); + assert.equal(nextNode.getLocation(), this.blocks.fieldWithOutput); }); test('fromFieldToInput', function () { const field = this.blocks.statementInput1.inputList[0].fieldRow[1]; @@ -412,31 +413,31 @@ suite('ASTNode', function () { this.blocks.statementInput1.inputList[0].connection; const node = ASTNode.createFieldNode(field); const nextNode = node.next(); - chai.assert.equal(nextNode.getLocation(), inputConnection); + assert.equal(nextNode.getLocation(), inputConnection); }); test('fromFieldToField', function () { const field = this.blocks.fieldAndInputs.inputList[0].fieldRow[0]; const node = ASTNode.createFieldNode(field); const field2 = this.blocks.fieldAndInputs.inputList[1].fieldRow[0]; const nextNode = node.next(); - chai.assert.equal(nextNode.getLocation(), field2); + assert.equal(nextNode.getLocation(), field2); }); test('fromFieldToNull', function () { const field = this.blocks.twoFields.inputList[0].fieldRow[0]; const node = ASTNode.createFieldNode(field); const nextNode = node.next(); - chai.assert.isNull(nextNode); + assert.isNull(nextNode); }); test('fromStackToStack', function () { const node = ASTNode.createStackNode(this.blocks.statementInput1); const nextNode = node.next(); - chai.assert.equal(nextNode.getLocation(), this.blocks.statementInput4); - chai.assert.equal(nextNode.getType(), ASTNode.types.STACK); + assert.equal(nextNode.getLocation(), this.blocks.statementInput4); + assert.equal(nextNode.getType(), ASTNode.types.STACK); }); test('fromStackToNull', function () { const node = ASTNode.createStackNode(this.blocks.singleBlock); const nextNode = node.next(); - chai.assert.isNull(nextNode); + assert.isNull(nextNode); }); }); @@ -445,55 +446,55 @@ suite('ASTNode', function () { const prevConnection = this.blocks.statementInput1.previousConnection; const node = ASTNode.createConnectionNode(prevConnection); const prevNode = node.prev(); - chai.assert.isNull(prevNode); + assert.isNull(prevNode); }); test('fromPreviousToNext', function () { const prevConnection = this.blocks.statementInput2.previousConnection; const node = ASTNode.createConnectionNode(prevConnection); const prevNode = node.prev(); const nextConnection = this.blocks.statementInput1.nextConnection; - chai.assert.equal(prevNode.getLocation(), nextConnection); + assert.equal(prevNode.getLocation(), nextConnection); }); test('fromPreviousToInput', function () { const prevConnection = this.blocks.statementInput3.previousConnection; const node = ASTNode.createConnectionNode(prevConnection); const prevNode = node.prev(); - chai.assert.isNull(prevNode); + assert.isNull(prevNode); }); test('fromBlockToPrevious', function () { const node = ASTNode.createBlockNode(this.blocks.statementInput1); const prevNode = node.prev(); const prevConnection = this.blocks.statementInput1.previousConnection; - chai.assert.equal(prevNode.getLocation(), prevConnection); + assert.equal(prevNode.getLocation(), prevConnection); }); test('fromBlockToNull', function () { const node = ASTNode.createBlockNode(this.blocks.noPrevConnection); const prevNode = node.prev(); - chai.assert.isNull(prevNode); + assert.isNull(prevNode); }); test('fromBlockToOutput', function () { const node = ASTNode.createBlockNode(this.blocks.fieldWithOutput); const prevNode = node.prev(); const outputConnection = this.blocks.fieldWithOutput.outputConnection; - chai.assert.equal(prevNode.getLocation(), outputConnection); + assert.equal(prevNode.getLocation(), outputConnection); }); test('fromNextToBlock', function () { const nextConnection = this.blocks.statementInput1.nextConnection; const node = ASTNode.createConnectionNode(nextConnection); const prevNode = node.prev(); - chai.assert.equal(prevNode.getLocation(), this.blocks.statementInput1); + assert.equal(prevNode.getLocation(), this.blocks.statementInput1); }); test('fromInputToField', function () { const input = this.blocks.statementInput1.inputList[0]; const node = ASTNode.createInputNode(input); const prevNode = node.prev(); - chai.assert.equal(prevNode.getLocation(), input.fieldRow[1]); + assert.equal(prevNode.getLocation(), input.fieldRow[1]); }); test('fromInputToNull', function () { const input = this.blocks.fieldAndInputs2.inputList[0]; const node = ASTNode.createInputNode(input); const prevNode = node.prev(); - chai.assert.isNull(prevNode); + assert.isNull(prevNode); }); test('fromInputToInput', function () { const input = this.blocks.fieldAndInputs2.inputList[2]; @@ -501,19 +502,19 @@ suite('ASTNode', function () { this.blocks.fieldAndInputs2.inputList[1].connection; const node = ASTNode.createInputNode(input); const prevNode = node.prev(); - chai.assert.equal(prevNode.getLocation(), inputConnection); + assert.equal(prevNode.getLocation(), inputConnection); }); test('fromOutputToNull', function () { const output = this.blocks.fieldWithOutput.outputConnection; const node = ASTNode.createConnectionNode(output); const prevNode = node.prev(); - chai.assert.isNull(prevNode); + assert.isNull(prevNode); }); test('fromFieldToNull', function () { const field = this.blocks.statementInput1.inputList[0].fieldRow[0]; const node = ASTNode.createFieldNode(field); const prevNode = node.prev(); - chai.assert.isNull(prevNode); + assert.isNull(prevNode); }); test('fromFieldToInput', function () { const field = this.blocks.fieldAndInputs2.inputList[1].fieldRow[0]; @@ -521,20 +522,20 @@ suite('ASTNode', function () { this.blocks.fieldAndInputs2.inputList[0].connection; const node = ASTNode.createFieldNode(field); const prevNode = node.prev(); - chai.assert.equal(prevNode.getLocation(), inputConnection); + assert.equal(prevNode.getLocation(), inputConnection); }); test('fromFieldToField', function () { const field = this.blocks.fieldAndInputs.inputList[1].fieldRow[0]; const field2 = this.blocks.fieldAndInputs.inputList[0].fieldRow[0]; const node = ASTNode.createFieldNode(field); const prevNode = node.prev(); - chai.assert.equal(prevNode.getLocation(), field2); + assert.equal(prevNode.getLocation(), field2); }); test('fromStackToStack', function () { const node = ASTNode.createStackNode(this.blocks.statementInput4); const prevNode = node.prev(); - chai.assert.equal(prevNode.getLocation(), this.blocks.statementInput1); - chai.assert.equal(prevNode.getType(), ASTNode.types.STACK); + assert.equal(prevNode.getLocation(), this.blocks.statementInput1); + assert.equal(prevNode.getType(), ASTNode.types.STACK); }); }); @@ -551,13 +552,13 @@ suite('ASTNode', function () { const node = ASTNode.createInputNode(input); const inNode = node.in(); const outputConnection = this.blocks.fieldWithOutput.outputConnection; - chai.assert.equal(inNode.getLocation(), outputConnection); + assert.equal(inNode.getLocation(), outputConnection); }); test('fromInputToNull', function () { const input = this.blocks.statementInput2.inputList[0]; const node = ASTNode.createInputNode(input); const inNode = node.in(); - chai.assert.isNull(inNode); + assert.isNull(inNode); }); test('fromInputToPrevious', function () { const input = this.blocks.statementInput2.inputList[1]; @@ -565,60 +566,57 @@ suite('ASTNode', function () { this.blocks.statementInput3.previousConnection; const node = ASTNode.createInputNode(input); const inNode = node.in(); - chai.assert.equal(inNode.getLocation(), previousConnection); + assert.equal(inNode.getLocation(), previousConnection); }); test('fromBlockToInput', function () { const input = this.blocks.valueInput.inputList[0]; const node = ASTNode.createBlockNode(this.blocks.valueInput); const inNode = node.in(); - chai.assert.equal(inNode.getLocation(), input.connection); + assert.equal(inNode.getLocation(), input.connection); }); test('fromBlockToField', function () { const node = ASTNode.createBlockNode(this.blocks.statementInput1); const inNode = node.in(); const field = this.blocks.statementInput1.inputList[0].fieldRow[0]; - chai.assert.equal(inNode.getLocation(), field); + assert.equal(inNode.getLocation(), field); }); test('fromBlockToPrevious', function () { const prevConnection = this.blocks.statementInput4.previousConnection; const node = ASTNode.createStackNode(this.blocks.statementInput4); const inNode = node.in(); - chai.assert.equal(inNode.getLocation(), prevConnection); - chai.assert.equal(inNode.getType(), ASTNode.types.PREVIOUS); + assert.equal(inNode.getLocation(), prevConnection); + assert.equal(inNode.getType(), ASTNode.types.PREVIOUS); }); test('fromBlockToNull_DummyInput', function () { const node = ASTNode.createBlockNode(this.blocks.dummyInput); const inNode = node.in(); - chai.assert.isNull(inNode); + assert.isNull(inNode); }); test('fromBlockToInput_DummyInputValue', function () { const node = ASTNode.createBlockNode(this.blocks.dummyInputValue); const inputConnection = this.blocks.dummyInputValue.inputList[1].connection; const inNode = node.in(); - chai.assert.equal(inNode.getLocation(), inputConnection); + assert.equal(inNode.getLocation(), inputConnection); }); test('fromOuputToNull', function () { const output = this.blocks.fieldWithOutput.outputConnection; const node = ASTNode.createConnectionNode(output); const inNode = node.in(); - chai.assert.isNull(inNode); + assert.isNull(inNode); }); test('fromFieldToNull', function () { const field = this.blocks.statementInput1.inputList[0].fieldRow[0]; const node = ASTNode.createFieldNode(field); const inNode = node.in(); - chai.assert.isNull(inNode); + assert.isNull(inNode); }); test('fromWorkspaceToStack', function () { const coordinate = new Blockly.utils.Coordinate(100, 100); const node = ASTNode.createWorkspaceNode(this.workspace, coordinate); const inNode = node.in(); - chai.assert.equal( - inNode.getLocation(), - this.workspace.getTopBlocks()[0], - ); - chai.assert.equal(inNode.getType(), ASTNode.types.STACK); + assert.equal(inNode.getLocation(), this.workspace.getTopBlocks()[0]); + assert.equal(inNode.getType(), ASTNode.types.STACK); }); test('fromWorkspaceToNull', function () { const coordinate = new Blockly.utils.Coordinate(100, 100); @@ -627,27 +625,27 @@ suite('ASTNode', function () { coordinate, ); const inNode = node.in(); - chai.assert.isNull(inNode); + assert.isNull(inNode); }); test('fromStackToPrevious', function () { const node = ASTNode.createStackNode(this.blocks.statementInput1); const previous = this.blocks.statementInput1.previousConnection; const inNode = node.in(); - chai.assert.equal(inNode.getLocation(), previous); - chai.assert.equal(inNode.getType(), ASTNode.types.PREVIOUS); + assert.equal(inNode.getLocation(), previous); + assert.equal(inNode.getType(), ASTNode.types.PREVIOUS); }); test('fromStackToOutput', function () { const node = ASTNode.createStackNode(this.blocks.fieldWithOutput2); const output = this.blocks.fieldWithOutput2.outputConnection; const inNode = node.in(); - chai.assert.equal(inNode.getLocation(), output); - chai.assert.equal(inNode.getType(), ASTNode.types.OUTPUT); + assert.equal(inNode.getLocation(), output); + assert.equal(inNode.getType(), ASTNode.types.OUTPUT); }); test('fromStackToBlock', function () { const node = ASTNode.createStackNode(this.blocks.dummyInput); const inNode = node.in(); - chai.assert.equal(inNode.getLocation(), this.blocks.dummyInput); - chai.assert.equal(inNode.getType(), ASTNode.types.BLOCK); + assert.equal(inNode.getLocation(), this.blocks.dummyInput); + assert.equal(inNode.getType(), ASTNode.types.BLOCK); }); }); @@ -667,15 +665,15 @@ suite('ASTNode', function () { const input = this.blocks.statementInput1.inputList[0]; const node = ASTNode.createInputNode(input); const outNode = node.out(); - chai.assert.equal(outNode.getType(), ASTNode.types.BLOCK); - chai.assert.equal(outNode.getLocation(), this.blocks.statementInput1); + assert.equal(outNode.getType(), ASTNode.types.BLOCK); + assert.equal(outNode.getLocation(), this.blocks.statementInput1); }); test('fromOutputToInput', function () { const output = this.blocks.fieldWithOutput.outputConnection; const node = ASTNode.createConnectionNode(output); const outNode = node.out(); - chai.assert.equal(outNode.getType(), ASTNode.types.INPUT); - chai.assert.equal( + assert.equal(outNode.getType(), ASTNode.types.INPUT); + assert.equal( outNode.getLocation(), this.blocks.statementInput1.inputList[0].connection, ); @@ -684,15 +682,15 @@ suite('ASTNode', function () { const output = this.blocks.fieldWithOutput2.outputConnection; const node = ASTNode.createConnectionNode(output); const outNode = node.out(); - chai.assert.equal(outNode.getType(), ASTNode.types.STACK); - chai.assert.equal(outNode.getLocation(), this.blocks.fieldWithOutput2); + assert.equal(outNode.getType(), ASTNode.types.STACK); + assert.equal(outNode.getLocation(), this.blocks.fieldWithOutput2); }); test('fromFieldToBlock', function () { const field = this.blocks.statementInput1.inputList[0].fieldRow[0]; const node = ASTNode.createFieldNode(field); const outNode = node.out(); - chai.assert.equal(outNode.getType(), ASTNode.types.BLOCK); - chai.assert.equal(outNode.getLocation(), this.blocks.statementInput1); + assert.equal(outNode.getType(), ASTNode.types.BLOCK); + assert.equal(outNode.getLocation(), this.blocks.statementInput1); }); test('fromStackToWorkspace', function () { const stub = sinon @@ -700,9 +698,9 @@ suite('ASTNode', function () { .returns({x: 10, y: 10}); const node = ASTNode.createStackNode(this.blocks.statementInput4); const outNode = node.out(); - chai.assert.equal(outNode.getType(), ASTNode.types.WORKSPACE); - chai.assert.equal(outNode.wsCoordinate.x, 10); - chai.assert.equal(outNode.wsCoordinate.y, -10); + assert.equal(outNode.getType(), ASTNode.types.WORKSPACE); + assert.equal(outNode.wsCoordinate.x, 10); + assert.equal(outNode.wsCoordinate.y, -10); stub.restore(); }); test('fromPreviousToInput', function () { @@ -711,15 +709,15 @@ suite('ASTNode', function () { this.blocks.statementInput2.inputList[1].connection; const node = ASTNode.createConnectionNode(previous); const outNode = node.out(); - chai.assert.equal(outNode.getType(), ASTNode.types.INPUT); - chai.assert.equal(outNode.getLocation(), inputConnection); + assert.equal(outNode.getType(), ASTNode.types.INPUT); + assert.equal(outNode.getLocation(), inputConnection); }); test('fromPreviousToStack', function () { const previous = this.blocks.statementInput2.previousConnection; const node = ASTNode.createConnectionNode(previous); const outNode = node.out(); - chai.assert.equal(outNode.getType(), ASTNode.types.STACK); - chai.assert.equal(outNode.getLocation(), this.blocks.statementInput1); + assert.equal(outNode.getType(), ASTNode.types.STACK); + assert.equal(outNode.getLocation(), this.blocks.statementInput1); }); test('fromNextToInput', function () { const next = this.blocks.statementInput3.nextConnection; @@ -727,22 +725,22 @@ suite('ASTNode', function () { this.blocks.statementInput2.inputList[1].connection; const node = ASTNode.createConnectionNode(next); const outNode = node.out(); - chai.assert.equal(outNode.getType(), ASTNode.types.INPUT); - chai.assert.equal(outNode.getLocation(), inputConnection); + assert.equal(outNode.getType(), ASTNode.types.INPUT); + assert.equal(outNode.getLocation(), inputConnection); }); test('fromNextToStack', function () { const next = this.blocks.statementInput2.nextConnection; const node = ASTNode.createConnectionNode(next); const outNode = node.out(); - chai.assert.equal(outNode.getType(), ASTNode.types.STACK); - chai.assert.equal(outNode.getLocation(), this.blocks.statementInput1); + assert.equal(outNode.getType(), ASTNode.types.STACK); + assert.equal(outNode.getLocation(), this.blocks.statementInput1); }); test('fromNextToStack_NoPreviousConnection', function () { const next = this.blocks.secondBlock.nextConnection; const node = ASTNode.createConnectionNode(next); const outNode = node.out(); - chai.assert.equal(outNode.getType(), ASTNode.types.STACK); - chai.assert.equal(outNode.getLocation(), this.blocks.noPrevConnection); + assert.equal(outNode.getType(), ASTNode.types.STACK); + assert.equal(outNode.getLocation(), this.blocks.noPrevConnection); }); /** * This is where there is a block with both an output connection and a @@ -752,8 +750,8 @@ suite('ASTNode', function () { const next = this.blocks.outputNextBlock.nextConnection; const node = ASTNode.createConnectionNode(next); const outNode = node.out(); - chai.assert.equal(outNode.getType(), ASTNode.types.INPUT); - chai.assert.equal( + assert.equal(outNode.getType(), ASTNode.types.INPUT); + assert.equal( outNode.getLocation(), this.blocks.secondBlock.inputList[0].connection, ); @@ -761,34 +759,34 @@ suite('ASTNode', function () { test('fromBlockToStack', function () { const node = ASTNode.createBlockNode(this.blocks.statementInput2); const outNode = node.out(); - chai.assert.equal(outNode.getType(), ASTNode.types.STACK); - chai.assert.equal(outNode.getLocation(), this.blocks.statementInput1); + assert.equal(outNode.getType(), ASTNode.types.STACK); + assert.equal(outNode.getLocation(), this.blocks.statementInput1); }); test('fromBlockToInput', function () { const input = this.blocks.statementInput2.inputList[1].connection; const node = ASTNode.createBlockNode(this.blocks.statementInput3); const outNode = node.out(); - chai.assert.equal(outNode.getType(), ASTNode.types.INPUT); - chai.assert.equal(outNode.getLocation(), input); + assert.equal(outNode.getType(), ASTNode.types.INPUT); + assert.equal(outNode.getLocation(), input); }); test('fromTopBlockToStack', function () { const node = ASTNode.createBlockNode(this.blocks.statementInput1); const outNode = node.out(); - chai.assert.equal(outNode.getType(), ASTNode.types.STACK); - chai.assert.equal(outNode.getLocation(), this.blocks.statementInput1); + assert.equal(outNode.getType(), ASTNode.types.STACK); + assert.equal(outNode.getLocation(), this.blocks.statementInput1); }); test('fromBlockToStack_OutputConnection', function () { const node = ASTNode.createBlockNode(this.blocks.fieldWithOutput2); const outNode = node.out(); - chai.assert.equal(outNode.getType(), ASTNode.types.STACK); - chai.assert.equal(outNode.getLocation(), this.blocks.fieldWithOutput2); + assert.equal(outNode.getType(), ASTNode.types.STACK); + assert.equal(outNode.getLocation(), this.blocks.fieldWithOutput2); }); test('fromBlockToInput_OutputConnection', function () { const node = ASTNode.createBlockNode(this.blocks.outputNextBlock); const inputConnection = this.blocks.secondBlock.inputList[0].connection; const outNode = node.out(); - chai.assert.equal(outNode.getType(), ASTNode.types.INPUT); - chai.assert.equal(outNode.getLocation(), inputConnection); + assert.equal(outNode.getType(), ASTNode.types.INPUT); + assert.equal(outNode.getLocation(), inputConnection); }); }); @@ -796,31 +794,31 @@ suite('ASTNode', function () { test('createFieldNode', function () { const field = this.blocks.statementInput1.inputList[0].fieldRow[0]; const node = ASTNode.createFieldNode(field); - chai.assert.equal(node.getLocation(), field); - chai.assert.equal(node.getType(), ASTNode.types.FIELD); - chai.assert.isFalse(node.isConnection()); + assert.equal(node.getLocation(), field); + assert.equal(node.getType(), ASTNode.types.FIELD); + assert.isFalse(node.isConnection()); }); test('createConnectionNode', function () { const prevConnection = this.blocks.statementInput4.previousConnection; const node = ASTNode.createConnectionNode(prevConnection); - chai.assert.equal(node.getLocation(), prevConnection); - chai.assert.equal(node.getType(), ASTNode.types.PREVIOUS); - chai.assert.isTrue(node.isConnection()); + assert.equal(node.getLocation(), prevConnection); + assert.equal(node.getType(), ASTNode.types.PREVIOUS); + assert.isTrue(node.isConnection()); }); test('createInputNode', function () { const input = this.blocks.statementInput1.inputList[0]; const node = ASTNode.createInputNode(input); - chai.assert.equal(node.getLocation(), input.connection); - chai.assert.equal(node.getType(), ASTNode.types.INPUT); - chai.assert.isTrue(node.isConnection()); + assert.equal(node.getLocation(), input.connection); + assert.equal(node.getType(), ASTNode.types.INPUT); + assert.isTrue(node.isConnection()); }); test('createWorkspaceNode', function () { const coordinate = new Blockly.utils.Coordinate(100, 100); const node = ASTNode.createWorkspaceNode(this.workspace, coordinate); - chai.assert.equal(node.getLocation(), this.workspace); - chai.assert.equal(node.getType(), ASTNode.types.WORKSPACE); - chai.assert.equal(node.getWsCoordinate(), coordinate); - chai.assert.isFalse(node.isConnection()); + assert.equal(node.getLocation(), this.workspace); + assert.equal(node.getType(), ASTNode.types.WORKSPACE); + assert.equal(node.getWsCoordinate(), coordinate); + assert.isFalse(node.isConnection()); }); test('createStatementConnectionNode', function () { const nextConnection = @@ -828,24 +826,24 @@ suite('ASTNode', function () { const inputConnection = this.blocks.statementInput1.inputList[1].connection; const node = ASTNode.createConnectionNode(nextConnection); - chai.assert.equal(node.getLocation(), inputConnection); - chai.assert.equal(node.getType(), ASTNode.types.INPUT); - chai.assert.isTrue(node.isConnection()); + assert.equal(node.getLocation(), inputConnection); + assert.equal(node.getType(), ASTNode.types.INPUT); + assert.isTrue(node.isConnection()); }); test('createTopNode-previous', function () { const block = this.blocks.statementInput1; const topNode = ASTNode.createTopNode(block); - chai.assert.equal(topNode.getLocation(), block.previousConnection); + assert.equal(topNode.getLocation(), block.previousConnection); }); test('createTopNode-block', function () { const block = this.blocks.noPrevConnection; const topNode = ASTNode.createTopNode(block); - chai.assert.equal(topNode.getLocation(), block); + assert.equal(topNode.getLocation(), block); }); test('createTopNode-output', function () { const block = this.blocks.outputNextBlock; const topNode = ASTNode.createTopNode(block); - chai.assert.equal(topNode.getLocation(), block.outputConnection); + assert.equal(topNode.getLocation(), block.outputConnection); }); }); }); diff --git a/tests/mocha/block_json_test.js b/tests/mocha/block_json_test.js index e89c68e7c..9d6dfb738 100644 --- a/tests/mocha/block_json_test.js +++ b/tests/mocha/block_json_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import {Align} from '../../build/src/core/inputs/align.js'; import { sharedTestSetup, @@ -27,7 +28,7 @@ suite('Block JSON initialization', function () { type: 'test', validateTokens_: Blockly.Block.prototype.validateTokens_, }; - chai.assert.throws(function () { + assert.throws(function () { block.validateTokens_(tokens, count); }, error); }; @@ -37,7 +38,7 @@ suite('Block JSON initialization', function () { type: 'test', validateTokens_: Blockly.Block.prototype.validateTokens_, }; - chai.assert.doesNotThrow(function () { + assert.doesNotThrow(function () { block.validateTokens_(tokens, count); }); }; @@ -105,7 +106,7 @@ suite('Block JSON initialization', function () { stringToFieldJson_: Blockly.Block.prototype.stringToFieldJson_, isInputKeyword_: Blockly.Block.prototype.isInputKeyword_, }; - chai.assert.deepEqual( + assert.deepEqual( block.interpolateArguments_(tokens, args, lastAlign), elements, ); @@ -405,7 +406,7 @@ suite('Block JSON initialization', function () { fieldFromJson_: Blockly.Block.prototype.fieldFromJson_, stringToFieldJson_: Blockly.Block.prototype.stringToFieldJson_, }; - chai.assert.strictEqual(block.fieldFromJson_(json), expectedType); + assert.strictEqual(block.fieldFromJson_(json), expectedType); }; }); @@ -573,34 +574,34 @@ suite('Block JSON initialization', function () { const input = block.inputFromJson_(json); switch (type) { case 'input_dummy': - chai.assert.isTrue( + assert.isTrue( block.appendDummyInput.calledOnce, 'Expected a dummy input to be created.', ); break; case 'input_value': - chai.assert.isTrue( + assert.isTrue( block.appendValueInput.calledOnce, 'Expected a value input to be created.', ); break; case 'input_statement': - chai.assert.isTrue( + assert.isTrue( block.appendStatementInput.calledOnce, 'Expected a statement input to be created.', ); break; default: - chai.assert.isNull(input, 'Expected input to be null'); - chai.assert.isTrue( + assert.isNull(input, 'Expected input to be null'); + assert.isTrue( block.appendDummyInput.notCalled, 'Expected no input to be created', ); - chai.assert.isTrue( + assert.isTrue( block.appendValueInput.notCalled, 'Expected no input to be created', ); - chai.assert.isTrue( + assert.isTrue( block.appendStatementInput.notCalled, 'Expected no input to be created', ); @@ -608,13 +609,13 @@ suite('Block JSON initialization', function () { } if (check) { if (Array.isArray(check)) { - chai.assert.deepEqual(check, input.connection.getCheck()); + assert.deepEqual(check, input.connection.getCheck()); } else { - chai.assert.deepEqual([check], input.connection.getCheck()); + assert.deepEqual([check], input.connection.getCheck()); } } if (align !== undefined) { - chai.assert.equal(align, input.align); + assert.equal(align, input.align); } }; }); @@ -667,7 +668,7 @@ suite('Block JSON initialization', function () { ); const block = this.workspace.newBlock('test_basic_empty'); block.inputFromJson_({'type': 'custom'}); - chai.assert.instanceOf( + assert.instanceOf( block.inputList[0], CustomInput, 'Expected the registered input to be constructed', diff --git a/tests/mocha/block_test.js b/tests/mocha/block_test.js index e158391fc..dd070f86c 100644 --- a/tests/mocha/block_test.js +++ b/tests/mocha/block_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import {ConnectionType} from '../../build/src/core/connection_type.js'; import {createDeprecationWarningStub} from './test_helpers/warnings.js'; import {createRenderedBlock} from './test_helpers/block_definitions.js'; @@ -80,7 +81,7 @@ suite('Blocks', function () { blockB.nextConnection.connect(blockC.previousConnection); } - chai.assert.equal(blockC.getParent(), blockB); + assert.equal(blockC.getParent(), blockB); return { A: blockA /* Parent */, @@ -92,30 +93,30 @@ suite('Blocks', function () { suite('Unplug', function () { function assertUnpluggedNoheal(blocks) { // A has nothing connected to it. - chai.assert.equal(blocks.A.getChildren().length, 0); + assert.equal(blocks.A.getChildren().length, 0); // B and C are still connected. - chai.assert.equal(blocks.C.getParent(), blocks.B); + assert.equal(blocks.C.getParent(), blocks.B); // B is the top of its stack. - chai.assert.isNull(blocks.B.getParent()); + assert.isNull(blocks.B.getParent()); } function assertUnpluggedHealed(blocks) { // A and C are connected. - chai.assert.equal(blocks.A.getChildren().length, 1); - chai.assert.equal(blocks.C.getParent(), blocks.A); + assert.equal(blocks.A.getChildren().length, 1); + assert.equal(blocks.C.getParent(), blocks.A); // B has nothing connected to it. - chai.assert.equal(blocks.B.getChildren().length, 0); + assert.equal(blocks.B.getChildren().length, 0); // B is the top of its stack. - chai.assert.isNull(blocks.B.getParent()); + assert.isNull(blocks.B.getParent()); } function assertUnpluggedHealFailed(blocks) { // A has nothing connected to it. - chai.assert.equal(blocks.A.getChildren().length, 0); + assert.equal(blocks.A.getChildren().length, 0); // B has nothing connected to it. - chai.assert.equal(blocks.B.getChildren().length, 0); + assert.equal(blocks.B.getChildren().length, 0); // B is the top of its stack. - chai.assert.isNull(blocks.B.getParent()); + assert.isNull(blocks.B.getParent()); // C is the top of its stack. - chai.assert.isNull(blocks.C.getParent()); + assert.isNull(blocks.C.getParent()); } suite('Row', function () { @@ -232,7 +233,7 @@ suite('Blocks', function () { this.block.dispose(); - chai.assert.isTrue(spy.calledOnce, 'Expected destroy to be called.'); + assert.isTrue(spy.calledOnce, 'Expected destroy to be called.'); }); test('disposing is set before destroy', function () { @@ -243,7 +244,7 @@ suite('Blocks', function () { this.block.dispose(); - chai.assert.isTrue( + assert.isTrue( disposing, 'Expected disposing to be set to true before destroy is called.', ); @@ -257,7 +258,7 @@ suite('Blocks', function () { this.block.dispose(); - chai.assert.isFalse( + assert.isFalse( disposed, 'Expected disposed to be false when destroy is called', ); @@ -273,7 +274,7 @@ suite('Blocks', function () { this.block.dispose(); this.clock.runAll(); - chai.assert.isTrue( + assert.isTrue( spy.calledWith(mockEvent), 'Expected to be able to fire events from destroy', ); @@ -293,7 +294,7 @@ suite('Blocks', function () { this.block.dispose(); this.clock.runAll(); - chai.assert.isTrue( + assert.isTrue( spy.calledWith(mockEvent), 'Expected to be able to fire events from destroy', ); @@ -302,34 +303,34 @@ suite('Blocks', function () { suite('stack/row healing', function () { function assertDisposedNoheal(blocks) { - chai.assert.isFalse(blocks.A.disposed); + assert.isFalse(blocks.A.disposed); // A has nothing connected to it. - chai.assert.equal(blocks.A.getChildren().length, 0); + assert.equal(blocks.A.getChildren().length, 0); // B is disposed. - chai.assert.isTrue(blocks.B.disposed); + assert.isTrue(blocks.B.disposed); // And C is disposed. - chai.assert.isTrue(blocks.C.disposed); + assert.isTrue(blocks.C.disposed); } function assertDisposedHealed(blocks) { - chai.assert.isFalse(blocks.A.disposed); - chai.assert.isFalse(blocks.C.disposed); + assert.isFalse(blocks.A.disposed); + assert.isFalse(blocks.C.disposed); // A and C are connected. - chai.assert.equal(blocks.A.getChildren().length, 1); - chai.assert.equal(blocks.C.getParent(), blocks.A); + assert.equal(blocks.A.getChildren().length, 1); + assert.equal(blocks.C.getParent(), blocks.A); // B is disposed. - chai.assert.isTrue(blocks.B.disposed); + assert.isTrue(blocks.B.disposed); } function assertDisposedHealFailed(blocks) { - chai.assert.isFalse(blocks.A.disposed); - chai.assert.isFalse(blocks.C.disposed); + assert.isFalse(blocks.A.disposed); + assert.isFalse(blocks.C.disposed); // A has nothing connected to it. - chai.assert.equal(blocks.A.getChildren().length, 0); + assert.equal(blocks.A.getChildren().length, 0); // B is disposed. - chai.assert.isTrue(blocks.B.disposed); + assert.isTrue(blocks.B.disposed); // C is the top of its stack. - chai.assert.isNull(blocks.C.getParent()); + assert.isNull(blocks.C.getParent()); } suite('Row', function () { @@ -469,7 +470,7 @@ suite('Blocks', function () { test('No Connected', function () { this.blockA.removeInput('VALUE'); - chai.assert.isNull(this.blockA.getInput('VALUE')); + assert.isNull(this.blockA.getInput('VALUE')); }); test('Block Connected', function () { const blockB = this.workspace.newBlock('row_block'); @@ -478,8 +479,8 @@ suite('Blocks', function () { .connection.connect(blockB.outputConnection); this.blockA.removeInput('VALUE'); - chai.assert.isFalse(blockB.disposed); - chai.assert.equal(this.blockA.getChildren().length, 0); + assert.isFalse(blockB.disposed); + assert.equal(this.blockA.getChildren().length, 0); }); test('Shadow Connected', function () { const blockB = this.workspace.newBlock('row_block'); @@ -489,8 +490,8 @@ suite('Blocks', function () { .connection.connect(blockB.outputConnection); this.blockA.removeInput('VALUE'); - chai.assert.isTrue(blockB.disposed); - chai.assert.equal(this.blockA.getChildren().length, 0); + assert.isTrue(blockB.disposed); + assert.equal(this.blockA.getChildren().length, 0); }); }); suite('Statement', function () { @@ -500,7 +501,7 @@ suite('Blocks', function () { test('No Connected', function () { this.blockA.removeInput('STATEMENT'); - chai.assert.isNull(this.blockA.getInput('STATEMENT')); + assert.isNull(this.blockA.getInput('STATEMENT')); }); test('Block Connected', function () { const blockB = this.workspace.newBlock('stack_block'); @@ -509,8 +510,8 @@ suite('Blocks', function () { .connection.connect(blockB.previousConnection); this.blockA.removeInput('STATEMENT'); - chai.assert.isFalse(blockB.disposed); - chai.assert.equal(this.blockA.getChildren().length, 0); + assert.isFalse(blockB.disposed); + assert.equal(this.blockA.getChildren().length, 0); }); test('Shadow Connected', function () { const blockB = this.workspace.newBlock('stack_block'); @@ -520,8 +521,8 @@ suite('Blocks', function () { .connection.connect(blockB.previousConnection); this.blockA.removeInput('STATEMENT'); - chai.assert.isTrue(blockB.disposed); - chai.assert.equal(this.blockA.getChildren().length, 0); + assert.isTrue(blockB.disposed); + assert.equal(this.blockA.getChildren().length, 0); }); }); }); @@ -549,10 +550,10 @@ suite('Blocks', function () { }; this.assertConnectionsEmpty = function () { - chai.assert.isEmpty(this.getInputs()); - chai.assert.isEmpty(this.getOutputs()); - chai.assert.isEmpty(this.getNext()); - chai.assert.isEmpty(this.getPrevious()); + assert.isEmpty(this.getInputs()); + assert.isEmpty(this.getOutputs()); + assert.isEmpty(this.getNext()); + assert.isEmpty(this.getPrevious()); }; }); teardown(function () { @@ -572,8 +573,8 @@ suite('Blocks', function () { this.deserializationHelper( '' + ' ' + '', ); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 1); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 1); }); test('Multi-Stack', function () { this.deserializationHelper( @@ -589,15 +590,15 @@ suite('Blocks', function () { ' ' + '', ); - chai.assert.equal(this.getPrevious().length, 3); - chai.assert.equal(this.getNext().length, 3); + assert.equal(this.getPrevious().length, 3); + assert.equal(this.getNext().length, 3); }); test('Collapsed Stack', function () { this.deserializationHelper( '' + ' ' + '', ); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 1); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 1); }); test('Collapsed Multi-Stack', function () { this.deserializationHelper( @@ -613,15 +614,15 @@ suite('Blocks', function () { ' ' + '', ); - chai.assert.equal(this.getPrevious().length, 3); - chai.assert.equal(this.getNext().length, 3); + assert.equal(this.getPrevious().length, 3); + assert.equal(this.getNext().length, 3); }); test('Row', function () { this.deserializationHelper( '' + ' ' + '', ); - chai.assert.equal(this.getOutputs().length, 1); - chai.assert.equal(this.getInputs().length, 1); + assert.equal(this.getOutputs().length, 1); + assert.equal(this.getInputs().length, 1); }); test('Multi-Row', function () { this.deserializationHelper( @@ -637,15 +638,15 @@ suite('Blocks', function () { ' ' + '', ); - chai.assert.equal(this.getOutputs().length, 3); - chai.assert.equal(this.getInputs().length, 3); + assert.equal(this.getOutputs().length, 3); + assert.equal(this.getInputs().length, 3); }); test('Collapsed Row', function () { this.deserializationHelper( '' + ' ' + '', ); - chai.assert.equal(this.getOutputs().length, 1); - chai.assert.equal(this.getInputs().length, 0); + assert.equal(this.getOutputs().length, 1); + assert.equal(this.getInputs().length, 0); }); test('Collapsed Multi-Row', function () { this.deserializationHelper( @@ -661,8 +662,8 @@ suite('Blocks', function () { ' ' + '', ); - chai.assert.equal(this.getOutputs().length, 1); - chai.assert.equal(this.getInputs().length, 0); + assert.equal(this.getOutputs().length, 1); + assert.equal(this.getInputs().length, 0); }); test('Collapsed Multi-Row Middle', function () { Blockly.Xml.appendDomToWorkspace( @@ -683,15 +684,15 @@ suite('Blocks', function () { ); this.assertConnectionsEmpty(); this.clock.runAll(); - chai.assert.equal(this.getOutputs().length, 2); - chai.assert.equal(this.getInputs().length, 1); + assert.equal(this.getOutputs().length, 2); + assert.equal(this.getInputs().length, 1); }); test('Statement', function () { this.deserializationHelper( '' + ' ' + '', ); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 2); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 2); }); test('Multi-Statement', function () { this.deserializationHelper( @@ -707,8 +708,8 @@ suite('Blocks', function () { ' ' + '', ); - chai.assert.equal(this.getPrevious().length, 3); - chai.assert.equal(this.getNext().length, 6); + assert.equal(this.getPrevious().length, 3); + assert.equal(this.getNext().length, 6); }); test('Collapsed Statement', function () { this.deserializationHelper( @@ -716,8 +717,8 @@ suite('Blocks', function () { ' ' + '', ); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 1); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 1); }); test('Collapsed Multi-Statement', function () { this.deserializationHelper( @@ -733,8 +734,8 @@ suite('Blocks', function () { ' ' + '', ); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 1); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 1); }); test('Collapsed Multi-Statement Middle', function () { this.deserializationHelper( @@ -750,8 +751,8 @@ suite('Blocks', function () { ' ' + '', ); - chai.assert.equal(this.getPrevious().length, 2); - chai.assert.equal(this.getNext().length, 3); + assert.equal(this.getPrevious().length, 2); + assert.equal(this.getNext().length, 3); }); }); suite('Programmatic Block Creation', function () { @@ -761,8 +762,8 @@ suite('Blocks', function () { block.initSvg(); block.render(); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 1); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 1); }); test('Row', function () { const block = this.workspace.newBlock('row_block'); @@ -770,8 +771,8 @@ suite('Blocks', function () { block.initSvg(); block.render(); - chai.assert.equal(this.getOutputs().length, 1); - chai.assert.equal(this.getInputs().length, 1); + assert.equal(this.getOutputs().length, 1); + assert.equal(this.getInputs().length, 1); }); test('Statement', function () { const block = this.workspace.newBlock('statement_block'); @@ -779,8 +780,8 @@ suite('Blocks', function () { block.initSvg(); block.render(); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 2); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 2); }); }); suite('setCollapsed', function () { @@ -790,16 +791,16 @@ suite('Blocks', function () { this.workspace, ); this.clock.runAll(); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 1); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 1); block.setCollapsed(true); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 1); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 1); block.setCollapsed(false); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 1); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 1); }); test('Multi-Stack', function () { const block = Blockly.Xml.domToBlock( @@ -818,16 +819,16 @@ suite('Blocks', function () { ); this.assertConnectionsEmpty(); this.clock.runAll(); - chai.assert.equal(this.getPrevious().length, 3); - chai.assert.equal(this.getNext().length, 3); + assert.equal(this.getPrevious().length, 3); + assert.equal(this.getNext().length, 3); block.setCollapsed(true); - chai.assert.equal(this.getPrevious().length, 3); - chai.assert.equal(this.getNext().length, 3); + assert.equal(this.getPrevious().length, 3); + assert.equal(this.getNext().length, 3); block.setCollapsed(false); - chai.assert.equal(this.getPrevious().length, 3); - chai.assert.equal(this.getNext().length, 3); + assert.equal(this.getPrevious().length, 3); + assert.equal(this.getNext().length, 3); }); test('Row', function () { const block = Blockly.Xml.domToBlock( @@ -835,16 +836,16 @@ suite('Blocks', function () { this.workspace, ); this.clock.runAll(); - chai.assert.equal(this.getOutputs().length, 1); - chai.assert.equal(this.getInputs().length, 1); + assert.equal(this.getOutputs().length, 1); + assert.equal(this.getInputs().length, 1); block.setCollapsed(true); - chai.assert.equal(this.getOutputs().length, 1); - chai.assert.equal(this.getInputs().length, 0); + assert.equal(this.getOutputs().length, 1); + assert.equal(this.getInputs().length, 0); block.setCollapsed(false); - chai.assert.equal(this.getOutputs().length, 1); - chai.assert.equal(this.getInputs().length, 1); + assert.equal(this.getOutputs().length, 1); + assert.equal(this.getInputs().length, 1); }); test('Multi-Row', function () { const block = Blockly.Xml.domToBlock( @@ -862,16 +863,16 @@ suite('Blocks', function () { this.workspace, ); this.clock.runAll(); - chai.assert.equal(this.getOutputs().length, 3); - chai.assert.equal(this.getInputs().length, 3); + assert.equal(this.getOutputs().length, 3); + assert.equal(this.getInputs().length, 3); block.setCollapsed(true); - chai.assert.equal(this.getOutputs().length, 1); - chai.assert.equal(this.getInputs().length, 0); + assert.equal(this.getOutputs().length, 1); + assert.equal(this.getInputs().length, 0); block.setCollapsed(false); - chai.assert.equal(this.getOutputs().length, 3); - chai.assert.equal(this.getInputs().length, 3); + assert.equal(this.getOutputs().length, 3); + assert.equal(this.getInputs().length, 3); }); test('Multi-Row Middle', function () { let block = Blockly.Xml.domToBlock( @@ -889,17 +890,17 @@ suite('Blocks', function () { this.workspace, ); this.clock.runAll(); - chai.assert.equal(this.getOutputs().length, 3); - chai.assert.equal(this.getInputs().length, 3); + assert.equal(this.getOutputs().length, 3); + assert.equal(this.getInputs().length, 3); block = block.getInputTargetBlock('INPUT'); block.setCollapsed(true); - chai.assert.equal(this.getOutputs().length, 2); - chai.assert.equal(this.getInputs().length, 1); + assert.equal(this.getOutputs().length, 2); + assert.equal(this.getInputs().length, 1); block.setCollapsed(false); - chai.assert.equal(this.getOutputs().length, 3); - chai.assert.equal(this.getInputs().length, 3); + assert.equal(this.getOutputs().length, 3); + assert.equal(this.getInputs().length, 3); }); test('Multi-Row Double Collapse', function () { // Collapse middle -> Collapse top -> @@ -919,25 +920,25 @@ suite('Blocks', function () { this.workspace, ); this.clock.runAll(); - chai.assert.equal(this.getOutputs().length, 3); - chai.assert.equal(this.getInputs().length, 3); + assert.equal(this.getOutputs().length, 3); + assert.equal(this.getInputs().length, 3); const middleBlock = block.getInputTargetBlock('INPUT'); middleBlock.setCollapsed(true); - chai.assert.equal(this.getOutputs().length, 2); - chai.assert.equal(this.getInputs().length, 1); + assert.equal(this.getOutputs().length, 2); + assert.equal(this.getInputs().length, 1); block.setCollapsed(true); - chai.assert.equal(this.getOutputs().length, 1); - chai.assert.equal(this.getInputs().length, 0); + assert.equal(this.getOutputs().length, 1); + assert.equal(this.getInputs().length, 0); block.setCollapsed(false); - chai.assert.equal(this.getOutputs().length, 2); - chai.assert.equal(this.getInputs().length, 1); + assert.equal(this.getOutputs().length, 2); + assert.equal(this.getInputs().length, 1); middleBlock.setCollapsed(false); - chai.assert.equal(this.getOutputs().length, 3); - chai.assert.equal(this.getInputs().length, 3); + assert.equal(this.getOutputs().length, 3); + assert.equal(this.getInputs().length, 3); }); test('Statement', function () { const block = Blockly.Xml.domToBlock( @@ -945,16 +946,16 @@ suite('Blocks', function () { this.workspace, ); this.clock.runAll(); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 2); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 2); block.setCollapsed(true); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 1); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 1); block.setCollapsed(false); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 2); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 2); }); test('Multi-Statement', function () { const block = Blockly.Xml.domToBlock( @@ -973,16 +974,16 @@ suite('Blocks', function () { ); this.assertConnectionsEmpty(); this.clock.runAll(); - chai.assert.equal(this.getPrevious().length, 3); - chai.assert.equal(this.getNext().length, 6); + assert.equal(this.getPrevious().length, 3); + assert.equal(this.getNext().length, 6); block.setCollapsed(true); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 1); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 1); block.setCollapsed(false); - chai.assert.equal(this.getPrevious().length, 3); - chai.assert.equal(this.getNext().length, 6); + assert.equal(this.getPrevious().length, 3); + assert.equal(this.getNext().length, 6); }); test('Multi-Statement Middle', function () { let block = Blockly.Xml.domToBlock( @@ -1001,17 +1002,17 @@ suite('Blocks', function () { ); this.assertConnectionsEmpty(); this.clock.runAll(); - chai.assert.equal(this.getPrevious().length, 3); - chai.assert.equal(this.getNext().length, 6); + assert.equal(this.getPrevious().length, 3); + assert.equal(this.getNext().length, 6); block = block.getInputTargetBlock('STATEMENT'); block.setCollapsed(true); - chai.assert.equal(this.getPrevious().length, 2); - chai.assert.equal(this.getNext().length, 3); + assert.equal(this.getPrevious().length, 2); + assert.equal(this.getNext().length, 3); block.setCollapsed(false); - chai.assert.equal(this.getPrevious().length, 3); - chai.assert.equal(this.getNext().length, 6); + assert.equal(this.getPrevious().length, 3); + assert.equal(this.getNext().length, 6); }); test('Multi-Statement Double Collapse', function () { const block = Blockly.Xml.domToBlock( @@ -1030,25 +1031,25 @@ suite('Blocks', function () { ); this.assertConnectionsEmpty(); this.clock.runAll(); - chai.assert.equal(this.getPrevious().length, 3); - chai.assert.equal(this.getNext().length, 6); + assert.equal(this.getPrevious().length, 3); + assert.equal(this.getNext().length, 6); const middleBlock = block.getInputTargetBlock('STATEMENT'); middleBlock.setCollapsed(true); - chai.assert.equal(this.getPrevious().length, 2); - chai.assert.equal(this.getNext().length, 3); + assert.equal(this.getPrevious().length, 2); + assert.equal(this.getNext().length, 3); block.setCollapsed(true); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 1); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 1); block.setCollapsed(false); - chai.assert.equal(this.getPrevious().length, 2); - chai.assert.equal(this.getNext().length, 3); + assert.equal(this.getPrevious().length, 2); + assert.equal(this.getNext().length, 3); middleBlock.setCollapsed(false); - chai.assert.equal(this.getPrevious().length, 3); - chai.assert.equal(this.getNext().length, 6); + assert.equal(this.getPrevious().length, 3); + assert.equal(this.getNext().length, 6); }); }); suite('Setting Parent Block', function () { @@ -1074,14 +1075,14 @@ suite('Blocks', function () { }); function assertBlockIsOnlyChild(parent, child, inputName) { - chai.assert.equal(parent.getChildren().length, 1); - chai.assert.equal(parent.getInputTargetBlock(inputName), child); - chai.assert.equal(child.getParent(), parent); + assert.equal(parent.getChildren().length, 1); + assert.equal(parent.getInputTargetBlock(inputName), child); + assert.equal(child.getParent(), parent); } function assertNonParentAndOrphan(nonParent, orphan, inputName) { - chai.assert.equal(nonParent.getChildren().length, 0); - chai.assert.isNull(nonParent.getInputTargetBlock('TEXT')); - chai.assert.isNull(orphan.getParent()); + assert.equal(nonParent.getChildren().length, 0); + assert.isNull(nonParent.getInputTargetBlock('TEXT')); + assert.isNull(orphan.getParent()); } function assertOriginalSetup() { assertBlockIsOnlyChild(this.printBlock, this.textJoinBlock, 'TEXT'); @@ -1089,7 +1090,7 @@ suite('Blocks', function () { } test('Setting to connected parent', function () { - chai.assert.doesNotThrow( + assert.doesNotThrow( this.textJoinBlock.setParent.bind( this.textJoinBlock, this.printBlock, @@ -1102,19 +1103,19 @@ suite('Blocks', function () { this.textBlock.outputConnection.connect( this.printBlock.getInput('TEXT').connection, ); - chai.assert.doesNotThrow( + assert.doesNotThrow( this.textBlock.setParent.bind(this.textBlock, this.printBlock), ); assertBlockIsOnlyChild(this.printBlock, this.textBlock, 'TEXT'); }); test('Setting to new parent while connected to other block', function () { // Setting to grandparent with no available input connection. - chai.assert.throws( + assert.throws( this.textBlock.setParent.bind(this.textBlock, this.printBlock), ); this.textJoinBlock.outputConnection.disconnect(); // Setting to block with available input connection. - chai.assert.throws( + assert.throws( this.textBlock.setParent.bind(this.textBlock, this.printBlock), ); assertNonParentAndOrphan(this.printBlock, this.textJoinBlock, 'TEXT'); @@ -1122,7 +1123,7 @@ suite('Blocks', function () { }); test('Setting to same parent after disconnecting from it', function () { this.textJoinBlock.outputConnection.disconnect(); - chai.assert.throws( + assert.throws( this.textJoinBlock.setParent.bind( this.textJoinBlock, this.printBlock, @@ -1133,12 +1134,12 @@ suite('Blocks', function () { test('Setting to new parent when orphan', function () { this.textBlock.outputConnection.disconnect(); // When new parent has no available input connection. - chai.assert.throws( + assert.throws( this.textBlock.setParent.bind(this.textBlock, this.printBlock), ); this.textJoinBlock.outputConnection.disconnect(); // When new parent has available input connection. - chai.assert.throws( + assert.throws( this.textBlock.setParent.bind(this.textBlock, this.printBlock), ); @@ -1148,13 +1149,13 @@ suite('Blocks', function () { }); test('Setting parent to null after disconnecting', function () { this.textBlock.outputConnection.disconnect(); - chai.assert.doesNotThrow( + assert.doesNotThrow( this.textBlock.setParent.bind(this.textBlock, null), ); assertNonParentAndOrphan(this.textJoinBlock, this.textBlock, 'ADD0'); }); test('Setting parent to null without disconnecting', function () { - chai.assert.throws(this.textBlock.setParent.bind(this.textBlock, null)); + assert.throws(this.textBlock.setParent.bind(this.textBlock, null)); assertOriginalSetup.call(this); }); }); @@ -1164,40 +1165,40 @@ suite('Blocks', function () { block.setOutput(false); - chai.assert.equal(this.getOutputs().length, 0); - chai.assert.equal(this.getInputs().length, 1); + assert.equal(this.getOutputs().length, 0); + assert.equal(this.getInputs().length, 1); }); test('Value', function () { const block = createRenderedBlock(this.workspace, 'row_block'); block.removeInput('INPUT'); - chai.assert.equal(this.getOutputs().length, 1); - chai.assert.equal(this.getInputs().length, 0); + assert.equal(this.getOutputs().length, 1); + assert.equal(this.getInputs().length, 0); }); test('Previous', function () { const block = createRenderedBlock(this.workspace, 'stack_block'); block.setPreviousStatement(false); - chai.assert.equal(this.getPrevious().length, 0); - chai.assert.equal(this.getNext().length, 1); + assert.equal(this.getPrevious().length, 0); + assert.equal(this.getNext().length, 1); }); test('Next', function () { const block = createRenderedBlock(this.workspace, 'stack_block'); block.setNextStatement(false); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 0); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 0); }); test('Statement', function () { const block = createRenderedBlock(this.workspace, 'statement_block'); block.removeInput('STATEMENT'); - chai.assert.equal(this.getPrevious().length, 1); - chai.assert.equal(this.getNext().length, 1); + assert.equal(this.getPrevious().length, 1); + assert.equal(this.getNext().length, 1); }); }); suite('Add Connections Programmatically', function () { @@ -1208,7 +1209,7 @@ suite('Blocks', function () { this.clock.runAll(); this.clock.runAll(); - chai.assert.equal(this.getOutputs().length, 1); + assert.equal(this.getOutputs().length, 1); }); test('Value', function () { const block = createRenderedBlock(this.workspace, 'empty_block'); @@ -1216,7 +1217,7 @@ suite('Blocks', function () { block.appendValueInput('INPUT'); this.clock.runAll(); - chai.assert.equal(this.getInputs().length, 1); + assert.equal(this.getInputs().length, 1); }); test('Previous', function () { const block = createRenderedBlock(this.workspace, 'empty_block'); @@ -1225,7 +1226,7 @@ suite('Blocks', function () { this.clock.runAll(); this.clock.runAll(); - chai.assert.equal(this.getPrevious().length, 1); + assert.equal(this.getPrevious().length, 1); }); test('Next', function () { const block = createRenderedBlock(this.workspace, 'empty_block'); @@ -1234,7 +1235,7 @@ suite('Blocks', function () { this.clock.runAll(); this.clock.runAll(); - chai.assert.equal(this.getNext().length, 1); + assert.equal(this.getNext().length, 1); }); test('Statement', function () { const block = createRenderedBlock(this.workspace, 'empty_block'); @@ -1242,7 +1243,7 @@ suite('Blocks', function () { block.appendStatementInput('STATEMENT'); this.clock.runAll(); - chai.assert.equal(this.getNext().length, 1); + assert.equal(this.getNext().length, 1); }); }); }); @@ -1252,18 +1253,18 @@ suite('Blocks', function () { function assertCommentEvent(eventSpy, oldValue, newValue) { const calls = eventSpy.getCalls(); const event = calls[calls.length - 1].args[0]; - chai.assert.equal(event.type, eventUtils.BLOCK_CHANGE); - chai.assert.equal( + assert.equal(event.type, eventUtils.BLOCK_CHANGE); + assert.equal( event.element, 'comment', 'Expected the element to be a comment', ); - chai.assert.equal( + assert.equal( event.oldValue, oldValue, 'Expected the old values to match', ); - chai.assert.equal( + assert.equal( event.newValue, newValue, 'Expected the new values to match', @@ -1272,7 +1273,7 @@ suite('Blocks', function () { function assertNoCommentEvent(eventSpy) { const calls = eventSpy.getCalls(); const event = calls[calls.length - 1].args[0]; - chai.assert.notEqual(event.type, eventUtils.BLOCK_CHANGE); + assert.notEqual(event.type, eventUtils.BLOCK_CHANGE); } setup(function () { this.eventsFireSpy = sinon.spy(eventUtils.TEST_ONLY, 'fireInternal'); @@ -1289,24 +1290,24 @@ suite('Blocks', function () { }); test('Text', function () { this.block.setCommentText('test text'); - chai.assert.equal(this.block.getCommentText(), 'test text'); + assert.equal(this.block.getCommentText(), 'test text'); assertCommentEvent(this.eventsFireSpy, null, 'test text'); }); test('Text Empty', function () { this.block.setCommentText(''); - chai.assert.equal(this.block.getCommentText(), ''); + assert.equal(this.block.getCommentText(), ''); assertCommentEvent(this.eventsFireSpy, null, ''); }); test('Text Null', function () { this.block.setCommentText(null); - chai.assert.isNull(this.block.getCommentText()); + assert.isNull(this.block.getCommentText()); assertNoCommentEvent(this.eventsFireSpy); }); test('Text -> Null', function () { this.block.setCommentText('first text'); this.block.setCommentText(null); - chai.assert.isNull(this.block.getCommentText()); + assert.isNull(this.block.getCommentText()); assertCommentEvent(this.eventsFireSpy, 'first text', null); }); }); @@ -1326,24 +1327,24 @@ suite('Blocks', function () { }); test('Text', function () { this.block.setCommentText('test text'); - chai.assert.equal(this.block.getCommentText(), 'test text'); + assert.equal(this.block.getCommentText(), 'test text'); assertCommentEvent(this.eventsFireSpy, null, 'test text'); }); test('Text Empty', function () { this.block.setCommentText(''); - chai.assert.equal(this.block.getCommentText(), ''); + assert.equal(this.block.getCommentText(), ''); assertCommentEvent(this.eventsFireSpy, null, ''); }); test('Text Null', function () { this.block.setCommentText(null); - chai.assert.isNull(this.block.getCommentText()); + assert.isNull(this.block.getCommentText()); assertNoCommentEvent(this.eventsFireSpy); }); test('Text -> Null', function () { this.block.setCommentText('first text'); this.block.setCommentText(null); - chai.assert.isNull(this.block.getCommentText()); + assert.isNull(this.block.getCommentText()); assertCommentEvent(this.eventsFireSpy, 'first text', null); }); test('Set While Visible - Editable', function () { @@ -1352,7 +1353,7 @@ suite('Blocks', function () { icon.setBubbleVisible(true); this.block.setCommentText('test2'); - chai.assert.equal(this.block.getCommentText(), 'test2'); + assert.equal(this.block.getCommentText(), 'test2'); assertCommentEvent(this.eventsFireSpy, 'test1', 'test2'); }); test('Set While Visible - NonEditable', function () { @@ -1363,7 +1364,7 @@ suite('Blocks', function () { icon.setBubbleVisible(true); this.block.setCommentText('test2'); - chai.assert.equal(this.block.getCommentText(), 'test2'); + assert.equal(this.block.getCommentText(), 'test2'); assertCommentEvent(this.eventsFireSpy, 'test1', 'test2'); }); }); @@ -1431,7 +1432,7 @@ suite('Blocks', function () { this.block.setCommentText('test text'); - chai.assert.instanceOf( + assert.instanceOf( this.block.getIcon(Blockly.icons.IconType.COMMENT), MockComment, ); @@ -1442,7 +1443,7 @@ suite('Blocks', function () { Blockly.icons.IconType.COMMENT.toString(), ); - chai.assert.throws(() => { + assert.throws(() => { this.block.setCommentText('test text'); }, 'No comment icon class is registered, so a comment cannot be set'); }); @@ -1456,7 +1457,7 @@ suite('Blocks', function () { MockIcon, ); - chai.assert.throws(() => { + assert.throws(() => { this.block.setCommentText('test text'); }, 'The class registered as a comment icon does not conform to the ICommentIcon interface'); }); @@ -1479,13 +1480,13 @@ suite('Blocks', function () { }); test('Getting Field', function () { - chai.assert.instanceOf(this.block.getField('TEXT'), Blockly.Field); + assert.instanceOf(this.block.getField('TEXT'), Blockly.Field); }); test('Getting Field without Name', function () { - chai.assert.throws(this.block.getField.bind(this.block), TypeError); + assert.throws(this.block.getField.bind(this.block), TypeError); }); test('Getting Value of Field without Name', function () { - chai.assert.throws(this.block.getFieldValue.bind(this.block), TypeError); + assert.throws(this.block.getFieldValue.bind(this.block), TypeError); }); test('Getting Field with Wrong Type', function () { const testFunction = function () { @@ -1499,7 +1500,7 @@ suite('Blocks', function () { ['TEXT'], ]; for (let i = 0; i < inputs.length; i++) { - chai.assert.throws( + assert.throws( this.block.getField.bind(this.block, inputs[i]), TypeError, ); @@ -1517,19 +1518,19 @@ suite('Blocks', function () { ['TEXT'], ]; for (let i = 0; i < inputs.length; i++) { - chai.assert.throws( + assert.throws( this.block.getFieldValue.bind(this.block, inputs[i]), TypeError, ); } }); test('Getting/Setting Field Value', function () { - chai.assert.equal(this.block.getFieldValue('TEXT'), 'test'); + assert.equal(this.block.getFieldValue('TEXT'), 'test'); this.block.setFieldValue('abc', 'TEXT'); - chai.assert.equal(this.block.getFieldValue('TEXT'), 'abc'); + assert.equal(this.block.getFieldValue('TEXT'), 'abc'); }); test('Setting Field without Name', function () { - chai.assert.throws(this.block.setFieldValue.bind(this.block, 'test')); + assert.throws(this.block.setFieldValue.bind(this.block, 'test')); }); test('Setting Field with Wrong Type', function () { const testFunction = function () { @@ -1543,7 +1544,7 @@ suite('Blocks', function () { ['TEXT'], ]; for (let i = 0; i < inputs.length; i++) { - chai.assert.throws( + assert.throws( this.block.setFieldValue.bind(this.block, 'test', inputs[i]), TypeError, ); @@ -1589,15 +1590,12 @@ suite('Blocks', function () { test('icons get added to the block', function () { this.block.addIcon(new MockIconA()); - chai.assert.isTrue( - this.block.hasIcon('A'), - 'Expected the icon to be added', - ); + assert.isTrue(this.block.hasIcon('A'), 'Expected the icon to be added'); }); test('adding two icons of the same type throws', function () { this.block.addIcon(new MockIconA()); - chai.assert.throws( + assert.throws( () => { this.block.addIcon(new MockIconA()); }, @@ -1610,7 +1608,7 @@ suite('Blocks', function () { test('adding an icon triggers a render', function () { this.renderSpy.resetHistory(); this.block.addIcon(new MockIconA()); - chai.assert.isTrue( + assert.isTrue( this.renderSpy.calledOnce, 'Expected adding an icon to trigger a render', ); @@ -1634,18 +1632,18 @@ suite('Blocks', function () { test('icons get removed from the block', function () { this.block.addIcon(new MockIconA()); - chai.assert.isTrue( + assert.isTrue( this.block.removeIcon(new Blockly.icons.IconType('A')), 'Expected removeIcon to return true', ); - chai.assert.isFalse( + assert.isFalse( this.block.hasIcon('A'), 'Expected the icon to be removed', ); }); test('removing an icon that does not exist returns false', function () { - chai.assert.isFalse( + assert.isFalse( this.block.removeIcon(new Blockly.icons.IconType('B')), 'Expected removeIcon to return false', ); @@ -1655,7 +1653,7 @@ suite('Blocks', function () { this.block.addIcon(new MockIconA()); this.renderSpy.resetHistory(); this.block.removeIcon(new Blockly.icons.IconType('A')); - chai.assert.isTrue( + assert.isTrue( this.renderSpy.calledOnce, 'Expected removing an icon to trigger a render', ); @@ -1672,7 +1670,7 @@ suite('Blocks', function () { const iconB = new MockIconB(); this.block.addIcon(iconB); this.block.addIcon(iconA); - chai.assert.sameOrderedMembers( + assert.sameOrderedMembers( this.block.getIcons(), [iconA, iconB], 'Expected getIcon to return both icons in order of weight', @@ -1680,7 +1678,7 @@ suite('Blocks', function () { }); test('if there are no icons, getIcons returns an empty array', function () { - chai.assert.isEmpty( + assert.isEmpty( this.block.getIcons(), 'Expected getIcons to return an empty array ' + 'for a block with no icons', @@ -1688,7 +1686,7 @@ suite('Blocks', function () { }); test('if there are no icons, getIcons returns an empty array', function () { - chai.assert.isEmpty( + assert.isEmpty( this.block.getIcons(), 'Expected getIcons to return an empty array ' + 'for a block with no icons', @@ -1700,7 +1698,7 @@ suite('Blocks', function () { const iconB = new MockIconB(); this.block.addIcon(iconA); this.block.addIcon(iconB); - chai.assert.equal( + assert.equal( this.block.getIcon('B'), iconB, 'Expected getIcon to return the icon with the given type', @@ -1709,7 +1707,7 @@ suite('Blocks', function () { test('if there is no matching icon, getIcon returns undefined', function () { this.block.addIcon(new MockIconA()); - chai.assert.isUndefined( + assert.isUndefined( this.block.getIcon('B'), 'Expected getIcon to return null if there is no ' + 'icon with a matching type', @@ -1733,7 +1731,7 @@ suite('Blocks', function () { test('Block with no warning text does not have warning icon', function () { const icon = this.block.getIcon(Blockly.icons.WarningIcon.TYPE); - chai.assert.isUndefined( + assert.isUndefined( icon, 'Block with no warning should not have warning icon', ); @@ -1745,7 +1743,7 @@ suite('Blocks', function () { this.block.setWarningText(text); const icon = this.block.getIcon(Blockly.icons.WarningIcon.TYPE); - chai.assert.equal( + assert.equal( icon.getText(), text, 'Expected warning icon text to be set', @@ -1760,7 +1758,7 @@ suite('Blocks', function () { this.block.setWarningText(text2, '2'); const icon = this.block.getIcon(Blockly.icons.WarningIcon.TYPE); - chai.assert.equal(icon.getText(), `${text1}\n${text2}`); + assert.equal(icon.getText(), `${text1}\n${text2}`); }); test('Clearing all warning text deletes the warning icon', function () { @@ -1770,7 +1768,7 @@ suite('Blocks', function () { this.block.setWarningText(null); const icon = this.block.getIcon(Blockly.icons.WarningIcon.TYPE); - chai.assert.isUndefined( + assert.isUndefined( icon, 'Expected warning icon to be undefined after deleting all warning text', ); @@ -1785,7 +1783,7 @@ suite('Blocks', function () { this.block.setWarningText(null, '1'); const icon = this.block.getIcon(Blockly.icons.WarningIcon.TYPE); - chai.assert.equal( + assert.equal( icon.getText(), text2, 'Expected first warning text to be deleted', @@ -1802,7 +1800,7 @@ suite('Blocks', function () { this.block.setWarningText(null, '2'); const icon = this.block.getIcon(Blockly.icons.WarningIcon.TYPE); - chai.assert.isUndefined( + assert.isUndefined( icon, 'Expected warning icon to be deleted after all warning text is cleared', ); @@ -1839,7 +1837,7 @@ suite('Blocks', function () { parentBlock.setCollapsed(true); - chai.assert.isFalse( + assert.isFalse( icon.bubbleIsVisible(), "Expected collapsing the parent block to hide the child block's " + "icon's bubble", @@ -1865,7 +1863,7 @@ suite('Blocks', function () { parentBlock.setCollapsed(true); - chai.assert.isTrue( + assert.isTrue( icon.bubbleIsVisible(), 'Expected collapsing the parent block to not hide the next ' + "block's bubble", @@ -1876,45 +1874,45 @@ suite('Blocks', function () { suite('Collapsing and Expanding', function () { function assertCollapsed(block, opt_string) { - chai.assert.isTrue(block.isCollapsed()); + assert.isTrue(block.isCollapsed()); for (let i = 0, input; (input = block.inputList[i]); i++) { if (input.name == Blockly.Block.COLLAPSED_INPUT_NAME) { continue; } - chai.assert.isFalse(input.isVisible()); + assert.isFalse(input.isVisible()); for (let j = 0, field; (field = input.fieldRow[j]); j++) { - chai.assert.isFalse(field.isVisible()); + assert.isFalse(field.isVisible()); } } const icons = block.getIcons(); for (let i = 0, icon; (icon = icons[i]); i++) { - chai.assert.isFalse(icon.bubbleIsVisible()); + assert.isFalse(icon.bubbleIsVisible()); } const input = block.getInput(Blockly.Block.COLLAPSED_INPUT_NAME); - chai.assert.isNotNull(input); - chai.assert.isTrue(input.isVisible()); + assert.isNotNull(input); + assert.isTrue(input.isVisible()); const field = block.getField(Blockly.Block.COLLAPSED_FIELD_NAME); - chai.assert.isNotNull(field); - chai.assert.isTrue(field.isVisible()); + assert.isNotNull(field); + assert.isTrue(field.isVisible()); if (opt_string) { - chai.assert.equal(field.getText(), opt_string); + assert.equal(field.getText(), opt_string); } } function assertNotCollapsed(block) { - chai.assert.isFalse(block.isCollapsed()); + assert.isFalse(block.isCollapsed()); for (let i = 0, input; (input = block.inputList[i]); i++) { - chai.assert.isTrue(input.isVisible()); + assert.isTrue(input.isVisible()); for (let j = 0, field; (field = input.fieldRow[j]); j++) { - chai.assert.isTrue(field.isVisible()); + assert.isTrue(field.isVisible()); } } const input = block.getInput(Blockly.Block.COLLAPSED_INPUT_NAME); - chai.assert.isNull(input); + assert.isNull(input); const field = block.getField(Blockly.Block.COLLAPSED_FIELD_NAME); - chai.assert.isNull(field); + assert.isNull(field); } function isBlockHidden(block) { let node = block.getSvgRoot(); @@ -1967,10 +1965,10 @@ suite('Blocks', function () { blockA.setCollapsed(true); assertCollapsed(blockA); blockA.getInput('INPUT').connection.connect(blockB.outputConnection); - chai.assert.isTrue(isBlockHidden(blockB)); + assert.isTrue(isBlockHidden(blockB)); blockA.setCollapsed(false); assertNotCollapsed(blockA); - chai.assert.isFalse(isBlockHidden(blockB)); + assert.isFalse(isBlockHidden(blockB)); }); test('Connect Block to Statement Input', function () { const blockA = createRenderedBlock(this.workspace, 'statement_block'); @@ -1981,10 +1979,10 @@ suite('Blocks', function () { blockA .getInput('STATEMENT') .connection.connect(blockB.previousConnection); - chai.assert.isTrue(isBlockHidden(blockB)); + assert.isTrue(isBlockHidden(blockB)); blockA.setCollapsed(false); assertNotCollapsed(blockA); - chai.assert.isFalse(isBlockHidden(blockB)); + assert.isFalse(isBlockHidden(blockB)); }); test('Connect Block to Child of Collapsed - Input', function () { const blockA = createRenderedBlock(this.workspace, 'row_block'); @@ -1994,14 +1992,14 @@ suite('Blocks', function () { blockA.getInput('INPUT').connection.connect(blockB.outputConnection); blockA.setCollapsed(true); assertCollapsed(blockA); - chai.assert.isTrue(isBlockHidden(blockB)); + assert.isTrue(isBlockHidden(blockB)); blockB.getInput('INPUT').connection.connect(blockC.outputConnection); - chai.assert.isTrue(isBlockHidden(blockC)); + assert.isTrue(isBlockHidden(blockC)); blockA.setCollapsed(false); assertNotCollapsed(blockA); - chai.assert.isFalse(isBlockHidden(blockB)); - chai.assert.isFalse(isBlockHidden(blockC)); + assert.isFalse(isBlockHidden(blockB)); + assert.isFalse(isBlockHidden(blockC)); }); test('Connect Block to Child of Collapsed - Next', function () { const blockA = createRenderedBlock(this.workspace, 'statement_block'); @@ -2013,14 +2011,14 @@ suite('Blocks', function () { .connection.connect(blockB.previousConnection); blockA.setCollapsed(true); assertCollapsed(blockA); - chai.assert.isTrue(isBlockHidden(blockB)); + assert.isTrue(isBlockHidden(blockB)); blockB.nextConnection.connect(blockC.previousConnection); - chai.assert.isTrue(isBlockHidden(blockC)); + assert.isTrue(isBlockHidden(blockC)); blockA.setCollapsed(false); assertNotCollapsed(blockA); - chai.assert.isFalse(isBlockHidden(blockB)); - chai.assert.isFalse(isBlockHidden(blockC)); + assert.isFalse(isBlockHidden(blockB)); + assert.isFalse(isBlockHidden(blockC)); }); test('Connect Block to Value Input Already Taken', function () { const blockA = createRenderedBlock(this.workspace, 'row_block'); @@ -2030,16 +2028,16 @@ suite('Blocks', function () { blockA.getInput('INPUT').connection.connect(blockB.outputConnection); blockA.setCollapsed(true); assertCollapsed(blockA); - chai.assert.isTrue(isBlockHidden(blockB)); + assert.isTrue(isBlockHidden(blockB)); blockA.getInput('INPUT').connection.connect(blockC.outputConnection); - chai.assert.isTrue(isBlockHidden(blockC)); + assert.isTrue(isBlockHidden(blockC)); // Still hidden after C is inserted between. - chai.assert.isTrue(isBlockHidden(blockB)); + assert.isTrue(isBlockHidden(blockB)); blockA.setCollapsed(false); assertNotCollapsed(blockA); - chai.assert.isFalse(isBlockHidden(blockB)); - chai.assert.isFalse(isBlockHidden(blockC)); + assert.isFalse(isBlockHidden(blockB)); + assert.isFalse(isBlockHidden(blockC)); }); test('Connect Block to Statement Input Already Taken', function () { const blockA = createRenderedBlock(this.workspace, 'statement_block'); @@ -2051,18 +2049,18 @@ suite('Blocks', function () { .connection.connect(blockB.previousConnection); blockA.setCollapsed(true); assertCollapsed(blockA); - chai.assert.isTrue(isBlockHidden(blockB)); + assert.isTrue(isBlockHidden(blockB)); blockA .getInput('STATEMENT') .connection.connect(blockC.previousConnection); - chai.assert.isTrue(isBlockHidden(blockC)); + assert.isTrue(isBlockHidden(blockC)); // Still hidden after C is inserted between. - chai.assert.isTrue(isBlockHidden(blockB)); + assert.isTrue(isBlockHidden(blockB)); blockA.setCollapsed(false); assertNotCollapsed(blockA); - chai.assert.isFalse(isBlockHidden(blockB)); - chai.assert.isFalse(isBlockHidden(blockC)); + assert.isFalse(isBlockHidden(blockB)); + assert.isFalse(isBlockHidden(blockC)); }); test('Connect Block with Child - Input', function () { const blockA = createRenderedBlock(this.workspace, 'row_block'); @@ -2073,13 +2071,13 @@ suite('Blocks', function () { blockA.setCollapsed(true); assertCollapsed(blockA); blockA.getInput('INPUT').connection.connect(blockB.outputConnection); - chai.assert.isTrue(isBlockHidden(blockC)); - chai.assert.isTrue(isBlockHidden(blockB)); + assert.isTrue(isBlockHidden(blockC)); + assert.isTrue(isBlockHidden(blockB)); blockA.setCollapsed(false); assertNotCollapsed(blockA); - chai.assert.isFalse(isBlockHidden(blockB)); - chai.assert.isFalse(isBlockHidden(blockC)); + assert.isFalse(isBlockHidden(blockB)); + assert.isFalse(isBlockHidden(blockC)); }); test('Connect Block with Child - Statement', function () { const blockA = createRenderedBlock(this.workspace, 'statement_block'); @@ -2092,13 +2090,13 @@ suite('Blocks', function () { blockA .getInput('STATEMENT') .connection.connect(blockB.previousConnection); - chai.assert.isTrue(isBlockHidden(blockC)); - chai.assert.isTrue(isBlockHidden(blockB)); + assert.isTrue(isBlockHidden(blockC)); + assert.isTrue(isBlockHidden(blockB)); blockA.setCollapsed(false); assertNotCollapsed(blockA); - chai.assert.isFalse(isBlockHidden(blockB)); - chai.assert.isFalse(isBlockHidden(blockC)); + assert.isFalse(isBlockHidden(blockB)); + assert.isFalse(isBlockHidden(blockC)); }); test('Disconnect Block from Value Input', function () { const blockA = createRenderedBlock(this.workspace, 'row_block'); @@ -2107,9 +2105,9 @@ suite('Blocks', function () { blockA.getInput('INPUT').connection.connect(blockB.outputConnection); blockA.setCollapsed(true); assertCollapsed(blockA); - chai.assert.isTrue(isBlockHidden(blockB)); + assert.isTrue(isBlockHidden(blockB)); blockB.outputConnection.disconnect(); - chai.assert.isFalse(isBlockHidden(blockB)); + assert.isFalse(isBlockHidden(blockB)); }); test('Disconnect Block from Statement Input', function () { const blockA = createRenderedBlock(this.workspace, 'statement_block'); @@ -2120,9 +2118,9 @@ suite('Blocks', function () { .connection.connect(blockB.previousConnection); blockA.setCollapsed(true); assertCollapsed(blockA); - chai.assert.isTrue(isBlockHidden(blockB)); + assert.isTrue(isBlockHidden(blockB)); blockB.previousConnection.disconnect(); - chai.assert.isFalse(isBlockHidden(blockB)); + assert.isFalse(isBlockHidden(blockB)); }); test('Disconnect Block from Child of Collapsed - Input', function () { const blockA = createRenderedBlock(this.workspace, 'row_block'); @@ -2133,11 +2131,11 @@ suite('Blocks', function () { blockB.getInput('INPUT').connection.connect(blockC.outputConnection); blockA.setCollapsed(true); assertCollapsed(blockA); - chai.assert.isTrue(isBlockHidden(blockB)); - chai.assert.isTrue(isBlockHidden(blockC)); + assert.isTrue(isBlockHidden(blockB)); + assert.isTrue(isBlockHidden(blockC)); blockC.outputConnection.disconnect(); - chai.assert.isFalse(isBlockHidden(blockC)); + assert.isFalse(isBlockHidden(blockC)); }); test('Disconnect Block from Child of Collapsed - Next', function () { const blockA = createRenderedBlock(this.workspace, 'statement_block'); @@ -2150,11 +2148,11 @@ suite('Blocks', function () { blockB.nextConnection.connect(blockC.previousConnection); blockA.setCollapsed(true); assertCollapsed(blockA); - chai.assert.isTrue(isBlockHidden(blockB)); - chai.assert.isTrue(isBlockHidden(blockC)); + assert.isTrue(isBlockHidden(blockB)); + assert.isTrue(isBlockHidden(blockC)); blockC.previousConnection.disconnect(); - chai.assert.isFalse(isBlockHidden(blockC)); + assert.isFalse(isBlockHidden(blockC)); }); test('Disconnect Block with Child - Input', function () { const blockA = createRenderedBlock(this.workspace, 'row_block'); @@ -2165,12 +2163,12 @@ suite('Blocks', function () { blockA.getInput('INPUT').connection.connect(blockB.outputConnection); blockA.setCollapsed(true); assertCollapsed(blockA); - chai.assert.isTrue(isBlockHidden(blockB)); - chai.assert.isTrue(isBlockHidden(blockC)); + assert.isTrue(isBlockHidden(blockB)); + assert.isTrue(isBlockHidden(blockC)); blockB.outputConnection.disconnect(); - chai.assert.isFalse(isBlockHidden(blockB)); - chai.assert.isFalse(isBlockHidden(blockC)); + assert.isFalse(isBlockHidden(blockB)); + assert.isFalse(isBlockHidden(blockC)); }); test('Disconnect Block with Child - Statement', function () { const blockA = createRenderedBlock(this.workspace, 'statement_block'); @@ -2183,12 +2181,12 @@ suite('Blocks', function () { .connection.connect(blockB.previousConnection); blockA.setCollapsed(true); assertCollapsed(blockA); - chai.assert.isTrue(isBlockHidden(blockC)); - chai.assert.isTrue(isBlockHidden(blockB)); + assert.isTrue(isBlockHidden(blockC)); + assert.isTrue(isBlockHidden(blockB)); blockB.previousConnection.disconnect(); - chai.assert.isFalse(isBlockHidden(blockB)); - chai.assert.isFalse(isBlockHidden(blockC)); + assert.isFalse(isBlockHidden(blockB)); + assert.isFalse(isBlockHidden(blockC)); }); }); suite('Adding and Removing Block Parts', function () { @@ -2198,7 +2196,7 @@ suite('Blocks', function () { assertCollapsed(blockA); blockA.setPreviousStatement(true); assertCollapsed(blockA); - chai.assert.isNotNull(blockA.previousConnection); + assert.isNotNull(blockA.previousConnection); }); test('Add Next Connection', function () { const blockA = createRenderedBlock(this.workspace, 'empty_block'); @@ -2206,7 +2204,7 @@ suite('Blocks', function () { assertCollapsed(blockA); blockA.setNextStatement(true); assertCollapsed(blockA); - chai.assert.isNotNull(blockA.nextConnection); + assert.isNotNull(blockA.nextConnection); }); test('Add Input', function () { const blockA = createRenderedBlock(this.workspace, 'empty_block'); @@ -2216,7 +2214,7 @@ suite('Blocks', function () { this.clock.runAll(); assertCollapsed(blockA); - chai.assert.isNotNull(blockA.getInput('NAME')); + assert.isNotNull(blockA.getInput('NAME')); }); test('Add Field', function () { const blockA = createRenderedBlock(this.workspace, 'empty_block'); @@ -2226,8 +2224,8 @@ suite('Blocks', function () { input.appendField(new Blockly.FieldLabel('test'), 'FIELD'); assertCollapsed(blockA); const field = blockA.getField('FIELD'); - chai.assert.isNotNull(field); - chai.assert.equal(field.getText(), 'test'); + assert.isNotNull(field); + assert.equal(field.getText(), 'test'); }); test('Add Icon', function () { const blockA = createRenderedBlock(this.workspace, 'empty_block'); @@ -2243,7 +2241,7 @@ suite('Blocks', function () { assertCollapsed(blockA); blockA.setPreviousStatement(false); assertCollapsed(blockA); - chai.assert.isNull(blockA.previousConnection); + assert.isNull(blockA.previousConnection); }); test('Remove Next Connection', function () { const blockA = createRenderedBlock(this.workspace, 'empty_block'); @@ -2252,7 +2250,7 @@ suite('Blocks', function () { assertCollapsed(blockA); blockA.setNextStatement(false); assertCollapsed(blockA); - chai.assert.isNull(blockA.nextConnection); + assert.isNull(blockA.nextConnection); }); test('Remove Input', function () { const blockA = createRenderedBlock(this.workspace, 'empty_block'); @@ -2261,7 +2259,7 @@ suite('Blocks', function () { assertCollapsed(blockA); blockA.removeInput('NAME'); assertCollapsed(blockA); - chai.assert.isNull(blockA.getInput('NAME')); + assert.isNull(blockA.getInput('NAME')); }); test('Remove Field', function () { const blockA = createRenderedBlock(this.workspace, 'empty_block'); @@ -2272,7 +2270,7 @@ suite('Blocks', function () { input.removeField('FIELD'); assertCollapsed(blockA); const field = blockA.getField('FIELD'); - chai.assert.isNull(field); + assert.isNull(field); }); test('Remove Icon', function () { const blockA = createRenderedBlock(this.workspace, 'empty_block'); @@ -2321,8 +2319,8 @@ suite('Blocks', function () { blockA.setCollapsed(false); // The child blocks should be enabled. - chai.assert.isTrue(blockB.isEnabled()); - chai.assert.isFalse( + assert.isTrue(blockB.isEnabled()); + assert.isFalse( blockB.getSvgRoot().classList.contains('blocklyDisabled'), ); }); @@ -2345,7 +2343,7 @@ suite('Blocks', function () { blockA.setCollapsed(true); // Child blocks should stay disabled if they have been set. - chai.assert.isFalse(blockB.isEnabled()); + assert.isFalse(blockB.isEnabled()); }); test('Disabled blocks from JSON should have proper disabled status', function () { // Nested c-shaped blocks, inner block is disabled @@ -2364,11 +2362,11 @@ suite('Blocks', function () { const innerBlock = this.workspace .getTopBlocks(false)[0] .getChildren()[0]; - chai.assert.isTrue( + assert.isTrue( innerBlock.visuallyDisabled, 'block should have visuallyDisabled set because it is disabled', ); - chai.assert.isFalse( + assert.isFalse( innerBlock.isEnabled(), 'block should be marked disabled because enabled json property was set to false', ); @@ -2389,11 +2387,11 @@ suite('Blocks', function () { const innerBlock = this.workspace .getTopBlocks(false)[0] .getChildren()[0]; - chai.assert.isTrue( + assert.isTrue( innerBlock.visuallyDisabled, 'block should have visuallyDisabled set because it is disabled', ); - chai.assert.isFalse( + assert.isFalse( innerBlock.isEnabled(), 'block should be marked disabled because enabled xml property was set to false', ); @@ -2443,7 +2441,7 @@ suite('Blocks', function () { this.parent.setDisabledReason(true, 'test reason'); await Blockly.renderManagement.finishQueuedRenders(); for (const child of this.parent.getDescendants(false)) { - chai.assert.isTrue( + assert.isTrue( child.visuallyDisabled, `block ${child.id} should be visually disabled`, ); @@ -2456,38 +2454,26 @@ suite('Blocks', function () { await Blockly.renderManagement.finishQueuedRenders(); // child2 is disabled, rest should be enabled - chai.assert.isTrue( - this.child1.isEnabled(), - 'child1 should be enabled', - ); - chai.assert.isFalse( + assert.isTrue(this.child1.isEnabled(), 'child1 should be enabled'); + assert.isFalse( this.child1.visuallyDisabled, 'child1 should not be visually disabled', ); - chai.assert.isFalse( - this.child2.isEnabled(), - 'child2 should be disabled', - ); - chai.assert.isTrue( + assert.isFalse(this.child2.isEnabled(), 'child2 should be disabled'); + assert.isTrue( this.child2.visuallyDisabled, 'child2 should be visually disabled', ); - chai.assert.isTrue( - this.child3.isEnabled(), - 'child3 should be enabled', - ); - chai.assert.isFalse( + assert.isTrue(this.child3.isEnabled(), 'child3 should be enabled'); + assert.isFalse( this.child3.visuallyDisabled, 'child3 should not be visually disabled', ); - chai.assert.isTrue( - this.child4.isEnabled(), - 'child34 should be enabled', - ); - chai.assert.isFalse( + assert.isTrue(this.child4.isEnabled(), 'child34 should be enabled'); + assert.isFalse( this.child4.visuallyDisabled, 'child4 should not be visually disabled', ); @@ -2506,16 +2492,16 @@ suite('Blocks', function () { }); test('Set colour', function () { this.block.setColour('20'); - chai.assert.equal(this.block.getColour(), '#a5745b'); - chai.assert.equal(this.block.colour_, this.block.getColour()); - chai.assert.equal(this.block.hue_, '20'); + assert.equal(this.block.getColour(), '#a5745b'); + assert.equal(this.block.colour_, this.block.getColour()); + assert.equal(this.block.hue_, '20'); }); test('Set style', function () { this.block.setStyle('styleOne'); - chai.assert.equal(this.block.getStyleName(), 'styleOne'); - chai.assert.isNull(this.block.hue_); + assert.equal(this.block.getStyleName(), 'styleOne'); + assert.isNull(this.block.hue_); // Calling setStyle does not update the colour on a headless block. - chai.assert.equal(this.block.getColour(), '#000000'); + assert.equal(this.block.getColour(), '#000000'); }); }); suite('Rendered', function () { @@ -2544,23 +2530,23 @@ suite('Blocks', function () { }); test('Set colour hue', function () { this.block.setColour('20'); - chai.assert.equal(this.block.getStyleName(), 'auto_#a5745b'); - chai.assert.equal(this.block.getColour(), '#a5745b'); - chai.assert.equal(this.block.colour_, this.block.getColour()); - chai.assert.equal(this.block.hue_, '20'); + assert.equal(this.block.getStyleName(), 'auto_#a5745b'); + assert.equal(this.block.getColour(), '#a5745b'); + assert.equal(this.block.colour_, this.block.getColour()); + assert.equal(this.block.hue_, '20'); }); test('Set colour hex', function () { this.block.setColour('#000000'); - chai.assert.equal(this.block.getStyleName(), 'auto_#000000'); - chai.assert.equal(this.block.getColour(), '#000000'); - chai.assert.equal(this.block.colour_, this.block.getColour()); - chai.assert.isNull(this.block.hue_); + assert.equal(this.block.getStyleName(), 'auto_#000000'); + assert.equal(this.block.getColour(), '#000000'); + assert.equal(this.block.colour_, this.block.getColour()); + assert.isNull(this.block.hue_); }); test('Set style', function () { this.block.setStyle('styleOne'); - chai.assert.equal(this.block.getStyleName(), 'styleOne'); - chai.assert.equal(this.block.getColour(), '#000000'); - chai.assert.equal(this.block.colour_, this.block.getColour()); + assert.equal(this.block.getStyleName(), 'styleOne'); + assert.equal(this.block.getColour(), '#000000'); + assert.equal(this.block.colour_, this.block.getColour()); }); }); }); @@ -2689,7 +2675,7 @@ suite('Blocks', function () { Blockly.utils.xml.textToDom(t.xml), this.workspace, ); - chai.assert.equal(block.toString(), t.toString); + assert.equal(block.toString(), t.toString); }); }); }); @@ -2713,20 +2699,20 @@ suite('Blocks', function () { recordUndoDuringInit = eventUtils.getRecordUndo(); throw new Error(); }; - chai.assert.throws( + assert.throws( function () { this.workspace.newBlock('init_test_block'); }.bind(this), ); - chai.assert.isFalse( + assert.isFalse( recordUndoDuringInit, 'recordUndo should be false during block init function', ); - chai.assert.isTrue( + assert.isTrue( eventUtils.getRecordUndo(), 'recordUndo should be reset to true after init', ); - chai.assert.isTrue(initCalled, 'expected init function to be called'); + assert.isTrue(initCalled, 'expected init function to be called'); }); }); @@ -2742,12 +2728,12 @@ suite('Blocks', function () { }); test('Newline is converted to an end-row input', function () { const block = this.workspace.newBlock('end_row_test_block'); - chai.assert.equal(block.inputList[0].fieldRow[0].getValue(), 'Row1'); - chai.assert.isTrue( + assert.equal(block.inputList[0].fieldRow[0].getValue(), 'Row1'); + assert.isTrue( block.inputList[0] instanceof EndRowInput, 'newline should be converted to an end-row input', ); - chai.assert.equal(block.inputList[1].fieldRow[0].getValue(), 'Row2'); + assert.equal(block.inputList[1].fieldRow[0].getValue(), 'Row2'); }); }); }); diff --git a/tests/mocha/blocks/lists_test.js b/tests/mocha/blocks/lists_test.js index 07510513b..cecf3c808 100644 --- a/tests/mocha/blocks/lists_test.js +++ b/tests/mocha/blocks/lists_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../../node_modules/chai/chai.js'; import {runSerializationTestSuite} from '../test_helpers/serialization.js'; import { sharedTestSetup, @@ -37,8 +38,8 @@ suite('Lists', function () { fields: {MODE: 'GET', WHERE: 'FIRST'}, }, assertBlockStructure: (block) => { - chai.assert.equal(block.type, 'lists_getIndex'); - chai.assert.exists(block.outputConnection); + assert.equal(block.type, 'lists_getIndex'); + assert.exists(block.outputConnection); }, }, { @@ -50,9 +51,9 @@ suite('Lists', function () { fields: {MODE: 'REMOVE', WHERE: 'FROM_START'}, }, assertBlockStructure: (block) => { - chai.assert.equal(block.type, 'lists_getIndex'); - chai.assert.isNotTrue(block.outputConnection); - chai.assert.isTrue( + assert.equal(block.type, 'lists_getIndex'); + assert.isNotTrue(block.outputConnection); + assert.isTrue( block.getInput('AT').type === ConnectionType.INPUT_VALUE, ); }, @@ -122,7 +123,7 @@ suite('Lists', function () { title: 'JSON not requiring mutations', json: serializedJson, assertBlockStructure: (block) => { - chai.assert.equal(block.type, serializedJson.type); + assert.equal(block.type, serializedJson.type); }, }, { diff --git a/tests/mocha/blocks/logic_ternary_test.js b/tests/mocha/blocks/logic_ternary_test.js index 2afa51f7a..6661bd5d4 100644 --- a/tests/mocha/blocks/logic_ternary_test.js +++ b/tests/mocha/blocks/logic_ternary_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../../node_modules/chai/chai.js'; import * as eventUtils from '../../../build/src/core/events/utils.js'; import {runSerializationTestSuite} from '../test_helpers/serialization.js'; import { @@ -28,21 +29,21 @@ suite('Logic ternary', function () { * inline. */ function assertBlockStructure(block, inputsInline = false) { - chai.assert.equal(block.type, 'logic_ternary'); + assert.equal(block.type, 'logic_ternary'); const inputs = block.inputList; - chai.assert.exists(inputs, 'Has inputList'); - chai.assert.lengthOf(inputs, 3); + assert.exists(inputs, 'Has inputList'); + assert.lengthOf(inputs, 3); const ifInput = block.getInput('IF'); - chai.assert.exists(ifInput, 'Has "IF" input'); + assert.exists(ifInput, 'Has "IF" input'); const checkList = ifInput.connection.getCheck(); - chai.assert.equal(checkList.length, 1); - chai.assert.equal(checkList[0], 'Boolean'); - chai.assert.exists(block.onchangeWrapper_, 'Has onchange handler'); + assert.equal(checkList.length, 1); + assert.equal(checkList[0], 'Boolean'); + assert.exists(block.onchangeWrapper_, 'Has onchange handler'); if (inputsInline) { - chai.assert.isTrue(block.inputsInline); + assert.isTrue(block.inputsInline); } else { // inputsInline can be undefined - chai.assert.isNotTrue(block.inputsInline); + assert.isNotTrue(block.inputsInline); } } @@ -90,20 +91,20 @@ suite('Logic ternary', function () { .getInput(parentInputName) .connection.connect(block.outputConnection); eventUtils.TEST_ONLY.fireNow(); // Force synchronous onchange() call. - chai.assert.equal( + assert.equal( block.getParent(), parent, 'Successful connection to parent', ); if (opt_thenInput) { - chai.assert.equal( + assert.equal( opt_thenInput.getParent(), block, 'Input THEN still connected after connecting parent', ); } if (opt_elseInput) { - chai.assert.equal( + assert.equal( opt_elseInput.getParent(), block, 'Input ELSE still connected after connecting parent', @@ -118,16 +119,16 @@ suite('Logic ternary', function () { ) { block.getInput('THEN').connection.connect(thenInput.outputConnection); eventUtils.TEST_ONLY.fireNow(); // Force synchronous onchange() call. - chai.assert.equal(thenInput.getParent(), block, 'THEN is connected'); + assert.equal(thenInput.getParent(), block, 'THEN is connected'); if (opt_parent) { - chai.assert.equal( + assert.equal( block.getParent(), opt_parent, 'Still connected to parent after connecting THEN', ); } if (opt_elseInput) { - chai.assert.equal( + assert.equal( opt_elseInput.getParent(), block, 'Input ELSE still connected after connecting THEN', @@ -142,16 +143,16 @@ suite('Logic ternary', function () { ) { block.getInput('ELSE').connection.connect(elseInput.outputConnection); eventUtils.TEST_ONLY.fireNow(); // Force synchronous onchange() call. - chai.assert.equal(elseInput.getParent(), block, 'ELSE is connected'); + assert.equal(elseInput.getParent(), block, 'ELSE is connected'); if (opt_parent) { - chai.assert.equal( + assert.equal( block.getParent(), opt_parent, 'Still connected to parent after connecting ELSE', ); } if (opt_thenInput) { - chai.assert.equal( + assert.equal( opt_thenInput.getParent(), block, 'Input THEN still connected after connecting ELSE', @@ -232,7 +233,7 @@ suite('Logic ternary', function () { // Adding mismatching number. connectThenInputAndCheckConnections(this.block, number, string); - chai.assert.equal( + assert.equal( this.block.getRootBlock(), this.block, 'Disconnected from parent', @@ -250,7 +251,7 @@ suite('Logic ternary', function () { // Adding mismatching number. connectElseInputAndCheckConnections(this.block, number, string); - chai.assert.equal( + assert.equal( this.block.getRootBlock(), this.block, 'Disconnected from parent', @@ -302,11 +303,7 @@ suite('Logic ternary', function () { null, string, ); - chai.assert.equal( - number.getRootBlock(), - number, - 'Input THEN disconnected', - ); + assert.equal(number.getRootBlock(), number, 'Input THEN disconnected'); }); test('Mismatch with else causes break with else', function () { const string = this.workspace.newBlock('text'); @@ -316,11 +313,7 @@ suite('Logic ternary', function () { const parent = this.workspace.newBlock('text_trim'); connectParentAndCheckConnections(this.block, parent, 'TEXT', string); - chai.assert.equal( - number.getRootBlock(), - number, - 'Input ELSE disconnected', - ); + assert.equal(number.getRootBlock(), number, 'Input ELSE disconnected'); }); }); }); diff --git a/tests/mocha/blocks/loops_test.js b/tests/mocha/blocks/loops_test.js index 3bbfdac10..8f4897e00 100644 --- a/tests/mocha/blocks/loops_test.js +++ b/tests/mocha/blocks/loops_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../../node_modules/chai/chai.js'; import * as Blockly from '../../../build/src/core/blockly.js'; import { sharedTestSetup, @@ -27,7 +28,7 @@ suite('Loops', function () { this.workspace, ); this.clock.runAll(); - chai.assert.isFalse( + assert.isFalse( breakBlock.isEnabled(), 'Expected the break block to be disabled', ); @@ -46,7 +47,7 @@ suite('Loops', function () { .getInput('DO') .connection.connect(breakBlock.previousConnection); this.clock.runAll(); - chai.assert.isTrue( + assert.isTrue( breakBlock.isEnabled(), 'Expected the break block to be enabled', ); diff --git a/tests/mocha/blocks/procedures_test.js b/tests/mocha/blocks/procedures_test.js index 109d3b2d4..684237006 100644 --- a/tests/mocha/blocks/procedures_test.js +++ b/tests/mocha/blocks/procedures_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../../node_modules/chai/chai.js'; import * as Blockly from '../../../build/src/core/blockly.js'; import { assertCallBlockStructure, @@ -45,7 +46,7 @@ suite('Procedures', function () { defBlock.setFieldValue('new name', 'NAME'); - chai.assert.equal( + assert.equal( callBlock.getFieldValue('NAME'), 'new name', 'Expected the procedure block to be renamed', @@ -71,12 +72,12 @@ suite('Procedures', function () { defBlockB.setFieldValue('procA', 'NAME'); - chai.assert.notEqual( + assert.notEqual( defBlockB.getFieldValue('NAME'), 'procA', 'Expected the procedure def block to have a legal name', ); - chai.assert.notEqual( + assert.notEqual( callBlockB.getFieldValue('NAME'), 'procA', 'Expected the procedure call block to have a legal name', @@ -112,7 +113,7 @@ suite('Procedures', function () { .getWorkspace() .getTopBlocks(true)[0] .getFieldValue('NAME'); - chai.assert.notEqual( + assert.notEqual( newFlyoutParamName, origFlyoutParamName, 'Expected the flyout param to have updated to not conflict', @@ -133,11 +134,11 @@ suite('Procedures', function () { .connection.connect(paramBlock.previousConnection); this.clock.runAll(); - chai.assert.isNotNull( + assert.isNotNull( defBlock.getField('PARAMS'), 'Expected the params field to exist', ); - chai.assert.isTrue( + assert.isTrue( defBlock.getFieldValue('PARAMS').includes('param1'), 'Expected the params field to contain the name of the new param', ); @@ -158,11 +159,11 @@ suite('Procedures', function () { .connection.connect(paramBlock.previousConnection); this.clock.runAll(); - chai.assert.isNotNull( + assert.isNotNull( callBlock.getInput('ARG0'), 'Expected the param input to exist', ); - chai.assert.equal( + assert.equal( callBlock.getFieldValue('ARGNAME0'), 'param1', 'Expected the params field to match the name of the new param', @@ -185,7 +186,7 @@ suite('Procedures', function () { this.workspace.undo(); - chai.assert.isFalse( + assert.isFalse( defBlock.getFieldValue('PARAMS').includes('param1'), 'Expected the params field to not contain the name of the new param', ); @@ -211,11 +212,11 @@ suite('Procedures', function () { this.workspace.undo(); this.workspace.undo(/* redo= */ true); - chai.assert.isNotNull( + assert.isNotNull( defBlock.getField('PARAMS'), 'Expected the params field to exist', ); - chai.assert.isTrue( + assert.isTrue( defBlock.getFieldValue('PARAMS').includes('param1'), 'Expected the params field to contain the name of the new param', ); @@ -241,7 +242,7 @@ suite('Procedures', function () { paramBlock.checkAndDelete(); this.clock.runAll(); - chai.assert.isFalse( + assert.isFalse( defBlock.getFieldValue('PARAMS').includes('param1'), 'Expected the params field to not contain the name of the new param', ); @@ -265,7 +266,7 @@ suite('Procedures', function () { paramBlock.checkAndDelete(); this.clock.runAll(); - chai.assert.isNull( + assert.isNull( callBlock.getInput('ARG0'), 'Expected the param input to not exist', ); @@ -289,7 +290,7 @@ suite('Procedures', function () { this.workspace.undo(); - chai.assert.isTrue( + assert.isTrue( defBlock.getFieldValue('PARAMS').includes('param1'), 'Expected the params field to contain the name of the new param', ); @@ -317,7 +318,7 @@ suite('Procedures', function () { this.workspace.undo(); this.workspace.undo(/* redo= */ true); - chai.assert.isFalse( + assert.isFalse( defBlock.getFieldValue('PARAMS').includes('param1'), 'Expected the params field to not contain the name of the new param', ); @@ -343,11 +344,11 @@ suite('Procedures', function () { paramBlock.setFieldValue('new name', 'NAME'); this.clock.runAll(); - chai.assert.isNotNull( + assert.isNotNull( defBlock.getField('PARAMS'), 'Expected the params field to exist', ); - chai.assert.isTrue( + assert.isTrue( defBlock.getFieldValue('PARAMS').includes('new name'), 'Expected the params field to contain the new name of the param', ); @@ -373,11 +374,11 @@ suite('Procedures', function () { paramBlock1.setFieldValue('new name', 'NAME'); this.clock.runAll(); - chai.assert.isNotNull( + assert.isNotNull( defBlock.getField('PARAMS'), 'Expected the params field to exist', ); - chai.assert.isTrue( + assert.isTrue( defBlock.getFieldValue('PARAMS').includes('new name'), 'Expected the params field to contain the new name of the param', ); @@ -401,11 +402,11 @@ suite('Procedures', function () { paramBlock.setFieldValue('new name', 'NAME'); this.clock.runAll(); - chai.assert.isNotNull( + assert.isNotNull( callBlock.getInput('ARG0'), 'Expected the param input to exist', ); - chai.assert.equal( + assert.equal( callBlock.getFieldValue('ARGNAME0'), 'new name', 'Expected the params field to match the name of the new param', @@ -430,7 +431,7 @@ suite('Procedures', function () { paramBlock.setFieldValue('param2', 'NAME'); this.clock.runAll(); - chai.assert.isNotNull( + assert.isNotNull( this.workspace.getVariable('param1', ''), 'Expected the old variable to continue to exist', ); @@ -454,11 +455,11 @@ suite('Procedures', function () { const variable = this.workspace.getVariable('param1', ''); this.workspace.renameVariableById(variable.getId(), 'new name'); - chai.assert.isNotNull( + assert.isNotNull( defBlock.getField('PARAMS'), 'Expected the params field to exist', ); - chai.assert.isTrue( + assert.isTrue( defBlock.getFieldValue('PARAMS').includes('new name'), 'Expected the params field to contain the new name of the param', ); @@ -481,7 +482,7 @@ suite('Procedures', function () { const variable = this.workspace.getVariable('param1', ''); this.workspace.renameVariableById(variable.getId(), 'new name'); - chai.assert.equal( + assert.equal( paramBlock.getFieldValue('NAME'), 'new name', 'Expected the params field to contain the new name of the param', @@ -507,11 +508,11 @@ suite('Procedures', function () { const variable = this.workspace.getVariable('param1', ''); this.workspace.renameVariableById(variable.getId(), 'new name'); - chai.assert.isNotNull( + assert.isNotNull( callBlock.getInput('ARG0'), 'Expected the param input to exist', ); - chai.assert.equal( + assert.equal( callBlock.getFieldValue('ARGNAME0'), 'new name', 'Expected the params field to match the name of the new param', @@ -536,11 +537,11 @@ suite('Procedures', function () { const variable = this.workspace.getVariable('param1', ''); this.workspace.renameVariableById(variable.getId(), 'preCreatedVar'); - chai.assert.isNotNull( + assert.isNotNull( defBlock.getField('PARAMS'), 'Expected the params field to exist', ); - chai.assert.isTrue( + assert.isTrue( defBlock.getFieldValue('PARAMS').includes('preCreatedVar'), 'Expected the params field to contain the new name of the param', ); @@ -563,7 +564,7 @@ suite('Procedures', function () { const variable = this.workspace.getVariable('param1', ''); this.workspace.renameVariableById(variable.getId(), 'preCreatedVar'); - chai.assert.equal( + assert.equal( paramBlock.getFieldValue('NAME'), 'preCreatedVar', 'Expected the params field to contain the new name of the param', @@ -589,11 +590,11 @@ suite('Procedures', function () { const variable = this.workspace.getVariable('param1', ''); this.workspace.renameVariableById(variable.getId(), 'preCreatedVar'); - chai.assert.isNotNull( + assert.isNotNull( callBlock.getInput('ARG0'), 'Expected the param input to exist', ); - chai.assert.equal( + assert.equal( callBlock.getFieldValue('ARGNAME0'), 'preCreatedVar', 'Expected the params field to match the name of the new param', @@ -631,7 +632,7 @@ suite('Procedures', function () { this.workspace.undo(); this.clock.runAll(); - chai.assert.isTrue( + assert.isTrue( defBlock.getFieldValue('PARAMS').includes('param1'), 'Expected the params field to contain the old name of the param', ); @@ -662,7 +663,7 @@ suite('Procedures', function () { this.workspace.undo(); this.workspace.undo(/* redo= */ true); - chai.assert.isTrue( + assert.isTrue( defBlock.getFieldValue('PARAMS').includes('new'), 'Expected the params field to contain the new name of the param', ); @@ -696,11 +697,11 @@ suite('Procedures', function () { paramBlock2.nextConnection.connect(paramBlock1.previousConnection); this.clock.runAll(); - chai.assert.isNotNull( + assert.isNotNull( defBlock.getField('PARAMS'), 'Expected the params field to exist', ); - chai.assert.isTrue( + assert.isTrue( defBlock.getFieldValue('PARAMS').includes('param2, param1'), 'Expected the params field order to match the parameter order', ); @@ -733,20 +734,20 @@ suite('Procedures', function () { paramBlock2.nextConnection.connect(paramBlock1.previousConnection); this.clock.runAll(); - chai.assert.isNotNull( + assert.isNotNull( callBlock.getInput('ARG0'), 'Expected the param input to exist', ); - chai.assert.equal( + assert.equal( callBlock.getFieldValue('ARGNAME0'), 'param2', 'Expected the params field to match the name of the second param', ); - chai.assert.isNotNull( + assert.isNotNull( callBlock.getInput('ARG1'), 'Expected the param input to exist', ); - chai.assert.equal( + assert.equal( callBlock.getFieldValue('ARGNAME1'), 'param1', 'Expected the params field to match the name of the first param', @@ -789,12 +790,12 @@ suite('Procedures', function () { paramBlock2.nextConnection.connect(paramBlock1.previousConnection); this.clock.runAll(); - chai.assert.equal( + assert.equal( callBlock.getInputTargetBlock('ARG0'), block2, 'Expected the second block to be in the first slot', ); - chai.assert.equal( + assert.equal( callBlock.getInputTargetBlock('ARG1'), block1, 'Expected the first block to be in the second slot', @@ -814,7 +815,7 @@ suite('Procedures', function () { defBlock.setDisabledReason(true, 'MANUALLY_DISABLED'); this.clock.runAll(); - chai.assert.isFalse( + assert.isFalse( callBlock.isEnabled(), 'Expected the caller block to be disabled', ); @@ -831,7 +832,7 @@ suite('Procedures', function () { defBlock.setDisabledReason(true, 'test reason'); this.clock.runAll(); - chai.assert.isFalse( + assert.isFalse( callBlock.isEnabled(), 'Expected the caller block to be invalid', ); @@ -850,7 +851,7 @@ suite('Procedures', function () { defBlock.setDisabledReason(false, 'MANUALLY_DISABLED'); this.clock.runAll(); - chai.assert.isTrue( + assert.isTrue( callBlock.isEnabled(), 'Expected the caller block to be enabled', ); @@ -872,7 +873,7 @@ suite('Procedures', function () { defBlock.setDisabledReason(false, 'MANUALLY_DISABLED'); this.clock.runAll(); - chai.assert.isFalse( + assert.isFalse( callBlock.isEnabled(), 'Expected the caller block to continue to be disabled', ); @@ -887,7 +888,7 @@ suite('Procedures', function () { this.workspace, ); this.clock.runAll(); - chai.assert.isFalse( + assert.isFalse( ifreturnBlock.isEnabled(), 'Expected the ifreturn block to be invalid', ); @@ -903,7 +904,7 @@ suite('Procedures', function () { .getInput('STACK') .connection.connect(ifreturnBlock.previousConnection); this.clock.runAll(); - chai.assert.isTrue( + assert.isTrue( ifreturnBlock.isEnabled(), 'Expected the ifreturn block to be valid', ); @@ -923,11 +924,11 @@ suite('Procedures', function () { defBlock.dispose(); this.clock.runAll(); - chai.assert.isTrue( + assert.isTrue( callBlock1.disposed, 'Expected the first caller to be disposed', ); - chai.assert.isTrue( + assert.isTrue( callBlock2.disposed, 'Expected the second caller to be disposed', ); @@ -1233,7 +1234,7 @@ suite('Procedures', function () { const options = []; def.customContextMenu(options); - chai.assert.isTrue( + assert.isTrue( options[0].text.includes('test name'), 'Expected the context menu to have an option to create the caller', ); @@ -1267,11 +1268,11 @@ suite('Procedures', function () { const options = []; def.customContextMenu(options); - chai.assert.isTrue( + assert.isTrue( options[1].text.includes('testParam1'), 'Expected the context menu to have an option to create the first param', ); - chai.assert.isTrue( + assert.isTrue( options[2].text.includes('testParam2'), 'Expected the context menu to have an option to create the second param', ); @@ -1286,13 +1287,13 @@ suite('Procedures', function () { returnBlock.setFieldValue('return', 'NAME'); const allProcedures = Blockly.Procedures.allProcedures(this.workspace); - chai.assert.lengthOf(allProcedures, 2); + assert.lengthOf(allProcedures, 2); - chai.assert.lengthOf(allProcedures[0], 1); - chai.assert.equal(allProcedures[0][0][0], 'no return'); + assert.lengthOf(allProcedures[0], 1); + assert.equal(allProcedures[0][0][0], 'no return'); - chai.assert.lengthOf(allProcedures[1], 1); - chai.assert.equal(allProcedures[1][0][0], 'return'); + assert.lengthOf(allProcedures[1], 1); + assert.equal(allProcedures[1][0][0], 'return'); }); test('Multiple Blocks', function () { @@ -1305,26 +1306,26 @@ suite('Procedures', function () { const _ = this.workspace.newBlock('controls_if'); const allProcedures = Blockly.Procedures.allProcedures(this.workspace); - chai.assert.lengthOf(allProcedures, 2); + assert.lengthOf(allProcedures, 2); - chai.assert.lengthOf(allProcedures[0], 1); - chai.assert.equal(allProcedures[0][0][0], 'no return'); + assert.lengthOf(allProcedures[0], 1); + assert.equal(allProcedures[0][0][0], 'no return'); - chai.assert.lengthOf(allProcedures[1], 2); - chai.assert.equal(allProcedures[1][0][0], 'return'); - chai.assert.equal(allProcedures[1][1][0], 'return2'); + assert.lengthOf(allProcedures[1], 2); + assert.equal(allProcedures[1][0][0], 'return'); + assert.equal(allProcedures[1][1][0], 'return2'); }); test('No Procedures', function () { const _ = this.workspace.newBlock('controls_if'); const allProcedures = Blockly.Procedures.allProcedures(this.workspace); - chai.assert.lengthOf(allProcedures, 2); - chai.assert.lengthOf( + assert.lengthOf(allProcedures, 2); + assert.lengthOf( allProcedures[0], 0, 'No procedures_defnoreturn blocks expected', ); - chai.assert.lengthOf( + assert.lengthOf( allProcedures[1], 0, 'No procedures_defreturn blocks expected', @@ -1334,21 +1335,19 @@ suite('Procedures', function () { suite('isNameUsed', function () { test('returns false if no blocks or models exists', function () { - chai.assert.isFalse( + assert.isFalse( Blockly.Procedures.isNameUsed('proc name', this.workspace), ); }); test('returns true if an associated block exists', function () { createProcDefBlock(this.workspace, false, [], 'proc name'); - chai.assert.isTrue( - Blockly.Procedures.isNameUsed('proc name', this.workspace), - ); + assert.isTrue(Blockly.Procedures.isNameUsed('proc name', this.workspace)); }); test('return false if an associated block does not exist', function () { createProcDefBlock(this.workspace, false, [], 'proc name'); - chai.assert.isFalse( + assert.isFalse( Blockly.Procedures.isNameUsed('other proc name', this.workspace), ); }); @@ -1357,16 +1356,14 @@ suite('Procedures', function () { this.workspace .getProcedureMap() .add(new MockProcedureModel().setName('proc name')); - chai.assert.isTrue( - Blockly.Procedures.isNameUsed('proc name', this.workspace), - ); + assert.isTrue(Blockly.Procedures.isNameUsed('proc name', this.workspace)); }); test('returns false if an associated procedure model exists', function () { this.workspace .getProcedureMap() .add(new MockProcedureModel().setName('proc name')); - chai.assert.isFalse( + assert.isFalse( Blockly.Procedures.isNameUsed('other proc name', this.workspace), ); }); @@ -1381,20 +1378,20 @@ suite('Procedures', function () { ) { const allProcedures = Blockly.Procedures.allProcedures(workspace); const defNoReturnBlocks = allProcedures[0]; - chai.assert.lengthOf( + assert.lengthOf( defNoReturnBlocks, noReturnNames.length, `Expected the number of no return blocks to be ${noReturnNames.length}`, ); for (let i = 0; i < noReturnNames.length; i++) { const expectedName = noReturnNames[i]; - chai.assert.equal(defNoReturnBlocks[i][0], expectedName); + assert.equal(defNoReturnBlocks[i][0], expectedName); if (hasCallers) { const callers = Blockly.Procedures.getCallers( expectedName, workspace, ); - chai.assert.lengthOf( + assert.lengthOf( callers, 1, `Expected there to be one caller of the ${expectedName} block`, @@ -1402,20 +1399,20 @@ suite('Procedures', function () { } } const defReturnBlocks = allProcedures[1]; - chai.assert.lengthOf( + assert.lengthOf( defReturnBlocks, returnNames.length, `Expected the number of return blocks to be ${returnNames.length}`, ); for (let i = 0; i < returnNames.length; i++) { const expectedName = returnNames[i]; - chai.assert.equal(defReturnBlocks[i][0], expectedName); + assert.equal(defReturnBlocks[i][0], expectedName); if (hasCallers) { const callers = Blockly.Procedures.getCallers( expectedName, workspace, ); - chai.assert.lengthOf( + assert.lengthOf( callers, 1, `Expected there to be one caller of the ${expectedName} block`, @@ -1429,7 +1426,7 @@ suite('Procedures', function () { expectedCount *= 2; } const blocks = workspace.getAllBlocks(false); - chai.assert.lengthOf(blocks, expectedCount); + assert.lengthOf(blocks, expectedCount); } suite('no name renamed to unnamed', function () { @@ -1532,7 +1529,7 @@ suite('Procedures', function () { // Do not require procedures to be the built-in procedures. const defBlock = this.workspace.newBlock('new_proc'); const def = Blockly.Procedures.getDefinition('test', this.workspace); - chai.assert.equal(def, defBlock); + assert.equal(def, defBlock); }); test('Stacked procedures', function () { @@ -1542,7 +1539,7 @@ suite('Procedures', function () { blockB.name = 'b'; blockA.nextConnection.connect(blockB.previousConnection); const def = Blockly.Procedures.getDefinition('b', this.workspace); - chai.assert.equal(def, blockB); + assert.equal(def, blockB); }); }); @@ -1612,8 +1609,8 @@ suite('Procedures', function () { this.defBlock.getFieldValue('NAME') + '2', 'NAME', ); - chai.assert.equal(this.defBlock.getFieldValue('NAME'), 'proc name2'); - chai.assert.equal(this.callBlock.getFieldValue('NAME'), 'proc name2'); + assert.equal(this.defBlock.getFieldValue('NAME'), 'proc name2'); + assert.equal(this.callBlock.getFieldValue('NAME'), 'proc name2'); }); test('Simple, Input', function () { const defInput = this.defBlock.getField('NAME'); @@ -1625,8 +1622,8 @@ suite('Procedures', function () { defInput.htmlInput_.value = 'proc name2'; defInput.onHtmlInputChange_(null); - chai.assert.equal(this.defBlock.getFieldValue('NAME'), 'proc name2'); - chai.assert.equal(this.callBlock.getFieldValue('NAME'), 'proc name2'); + assert.equal(this.defBlock.getFieldValue('NAME'), 'proc name2'); + assert.equal(this.callBlock.getFieldValue('NAME'), 'proc name2'); }); test('lower -> CAPS', function () { const defInput = this.defBlock.getField('NAME'); @@ -1638,8 +1635,8 @@ suite('Procedures', function () { defInput.htmlInput_.value = 'PROC NAME'; defInput.onHtmlInputChange_(null); - chai.assert.equal(this.defBlock.getFieldValue('NAME'), 'PROC NAME'); - chai.assert.equal(this.callBlock.getFieldValue('NAME'), 'PROC NAME'); + assert.equal(this.defBlock.getFieldValue('NAME'), 'PROC NAME'); + assert.equal(this.callBlock.getFieldValue('NAME'), 'PROC NAME'); }); test('CAPS -> lower', function () { this.defBlock.setFieldValue('PROC NAME', 'NAME'); @@ -1653,8 +1650,8 @@ suite('Procedures', function () { defInput.htmlInput_.value = 'proc name'; defInput.onHtmlInputChange_(null); - chai.assert.equal(this.defBlock.getFieldValue('NAME'), 'proc name'); - chai.assert.equal(this.callBlock.getFieldValue('NAME'), 'proc name'); + assert.equal(this.defBlock.getFieldValue('NAME'), 'proc name'); + assert.equal(this.callBlock.getFieldValue('NAME'), 'proc name'); }); test('Whitespace', function () { const defInput = this.defBlock.getField('NAME'); @@ -1666,8 +1663,8 @@ suite('Procedures', function () { defInput.htmlInput_.value = 'proc name '; defInput.onHtmlInputChange_(null); - chai.assert.equal(this.defBlock.getFieldValue('NAME'), 'proc name'); - chai.assert.equal(this.callBlock.getFieldValue('NAME'), 'proc name'); + assert.equal(this.defBlock.getFieldValue('NAME'), 'proc name'); + assert.equal(this.callBlock.getFieldValue('NAME'), 'proc name'); }); test('Whitespace then Text', function () { const defInput = this.defBlock.getField('NAME'); @@ -1681,11 +1678,8 @@ suite('Procedures', function () { defInput.onHtmlInputChange_(null); defInput.htmlInput_.value = 'proc name 2'; defInput.onHtmlInputChange_(null); - chai.assert.equal(this.defBlock.getFieldValue('NAME'), 'proc name 2'); - chai.assert.equal( - this.callBlock.getFieldValue('NAME'), - 'proc name 2', - ); + assert.equal(this.defBlock.getFieldValue('NAME'), 'proc name 2'); + assert.equal(this.callBlock.getFieldValue('NAME'), 'proc name 2'); }); test('Set Empty', function () { const defInput = this.defBlock.getField('NAME'); @@ -1697,11 +1691,11 @@ suite('Procedures', function () { defInput.htmlInput_.value = ''; defInput.onHtmlInputChange_(null); - chai.assert.equal( + assert.equal( this.defBlock.getFieldValue('NAME'), Blockly.Msg['UNNAMED_KEY'], ); - chai.assert.equal( + assert.equal( this.callBlock.getFieldValue('NAME'), Blockly.Msg['UNNAMED_KEY'], ); @@ -1718,11 +1712,11 @@ suite('Procedures', function () { defInput.onHtmlInputChange_(null); const newDefBlock = this.workspace.newBlock(testSuite.defType); newDefBlock.setFieldValue('new name', 'NAME'); - chai.assert.equal( + assert.equal( this.defBlock.getFieldValue('NAME'), Blockly.Msg['UNNAMED_KEY'], ); - chai.assert.equal( + assert.equal( this.callBlock.getFieldValue('NAME'), Blockly.Msg['UNNAMED_KEY'], ); @@ -1754,8 +1748,8 @@ suite('Procedures', function () { 'proc name', this.workspace, ); - chai.assert.equal(callers.length, 1); - chai.assert.equal(callers[0], this.callBlock); + assert.equal(callers.length, 1); + assert.equal(callers[0], this.callBlock); }); test('Multiple Callers', function () { const caller2 = this.workspace.newBlock(testSuite.callType); @@ -1767,10 +1761,10 @@ suite('Procedures', function () { 'proc name', this.workspace, ); - chai.assert.equal(callers.length, 3); - chai.assert.equal(callers[0], this.callBlock); - chai.assert.equal(callers[1], caller2); - chai.assert.equal(callers[2], caller3); + assert.equal(callers.length, 3); + assert.equal(callers[0], this.callBlock); + assert.equal(callers[1], caller2); + assert.equal(callers[2], caller3); }); test('Multiple Procedures', function () { const def2 = this.workspace.newBlock(testSuite.defType); @@ -1782,8 +1776,8 @@ suite('Procedures', function () { 'proc name', this.workspace, ); - chai.assert.equal(callers.length, 1); - chai.assert.equal(callers[0], this.callBlock); + assert.equal(callers.length, 1); + assert.equal(callers[0], this.callBlock); }); // This can occur if you: // 1) Create an uppercase definition and call block. @@ -1799,8 +1793,8 @@ suite('Procedures', function () { 'proc name', this.workspace, ); - chai.assert.equal(callers.length, 1); - chai.assert.equal(callers[0], this.callBlock); + assert.equal(callers.length, 1); + assert.equal(callers[0], this.callBlock); }); test('Multiple Workspaces', function () { const workspace = new Blockly.Workspace(); @@ -1814,12 +1808,12 @@ suite('Procedures', function () { 'proc name', this.workspace, ); - chai.assert.equal(callers.length, 1); - chai.assert.equal(callers[0], this.callBlock); + assert.equal(callers.length, 1); + assert.equal(callers[0], this.callBlock); callers = Blockly.Procedures.getCallers('proc name', workspace); - chai.assert.equal(callers.length, 1); - chai.assert.equal(callers[0], caller2); + assert.equal(callers.length, 1); + assert.equal(callers[0], caller2); } finally { workspaceTeardown.call(this, workspace); } @@ -1851,7 +1845,7 @@ suite('Procedures', function () { 'proc name', this.workspace, ); - chai.assert.equal(def, this.defBlock); + assert.equal(def, this.defBlock); }); test('Multiple Procedures', function () { const def2 = this.workspace.newBlock(testSuite.defType); @@ -1863,7 +1857,7 @@ suite('Procedures', function () { 'proc name', this.workspace, ); - chai.assert.equal(def, this.defBlock); + assert.equal(def, this.defBlock); }); test('Multiple Workspaces', function () { const workspace = new Blockly.Workspace(); @@ -1877,10 +1871,10 @@ suite('Procedures', function () { 'proc name', this.workspace, ); - chai.assert.equal(def, this.defBlock); + assert.equal(def, this.defBlock); def = Blockly.Procedures.getDefinition('proc name', workspace); - chai.assert.equal(def, def2); + assert.equal(def, def2); } finally { workspaceTeardown.call(this, workspace); } @@ -1925,11 +1919,11 @@ suite('Procedures', function () { if (testSuite.defType === 'procedures_defreturn') { test('Has Statements', function () { setStatementValue(this.workspace, this.defBlock, true); - chai.assert.isTrue(this.defBlock.hasStatements_); + assert.isTrue(this.defBlock.hasStatements_); }); test('Has No Statements', function () { setStatementValue(this.workspace, this.defBlock, false); - chai.assert.isFalse(this.defBlock.hasStatements_); + assert.isFalse(this.defBlock.hasStatements_); }); test('Saving Statements', function () { const blockXml = Blockly.utils.xml.textToDom( @@ -1944,14 +1938,14 @@ suite('Procedures', function () { this.workspace, ); setStatementValue(this.workspace, defBlock, false); - chai.assert.isNull(defBlock.getInput('STACK')); + assert.isNull(defBlock.getInput('STACK')); setStatementValue(this.workspace, defBlock, true); - chai.assert.isNotNull(defBlock.getInput('STACK')); + assert.isNotNull(defBlock.getInput('STACK')); const statementBlocks = defBlock.getChildren(); - chai.assert.equal(statementBlocks.length, 1); + assert.equal(statementBlocks.length, 1); const block = statementBlocks[0]; - chai.assert.equal(block.type, 'procedures_ifreturn'); - chai.assert.equal(block.id, 'test'); + assert.equal(block.type, 'procedures_ifreturn'); + assert.equal(block.id, 'test'); }); } }); @@ -1976,21 +1970,21 @@ suite('Procedures', function () { this.clock.runAll(); } function assertArgs(argArray) { - chai.assert.equal( + assert.equal( this.defBlock.getVars().length, argArray.length, 'Expected the def to have the right number of arguments', ); for (let i = 0; i < argArray.length; i++) { - chai.assert.equal(this.defBlock.getVars()[i], argArray[i]); + assert.equal(this.defBlock.getVars()[i], argArray[i]); } - chai.assert.equal( + assert.equal( this.callBlock.getVars().length, argArray.length, 'Expected the call to have the right number of arguments', ); for (let i = 0; i < argArray.length; i++) { - chai.assert.equal(this.callBlock.getVars()[i], argArray[i]); + assert.equal(this.callBlock.getVars()[i], argArray[i]); } } test('Simple Add Arg', async function () { @@ -2062,7 +2056,7 @@ suite('Procedures', function () { const statementInput = mutatorWorkspace .getTopBlocks()[0] .getInput('STATEMENT_INPUT'); - chai.assert.isNotNull(statementInput); + assert.isNotNull(statementInput); }); test('Has Statements', function () { this.defBlock.hasStatements_ = true; @@ -2076,7 +2070,7 @@ suite('Procedures', function () { .getTopBlocks()[0] .getField('STATEMENTS') .getValueBoolean(); - chai.assert.isTrue(statementValue); + assert.isTrue(statementValue); }); test('No Has Statements', function () { this.defBlock.hasStatements_ = false; @@ -2090,7 +2084,7 @@ suite('Procedures', function () { .getTopBlocks()[0] .getField('STATEMENTS') .getValueBoolean(); - chai.assert.isFalse(statementValue); + assert.isFalse(statementValue); }); } else { test('Has no Statement Input', function () { @@ -2103,7 +2097,7 @@ suite('Procedures', function () { const statementInput = mutatorWorkspace .getTopBlocks()[0] .getInput('STATEMENT_INPUT'); - chai.assert.isNull(statementInput); + assert.isNull(statementInput); }); } }); diff --git a/tests/mocha/blocks/variables_test.js b/tests/mocha/blocks/variables_test.js index caee68aec..ea45d59c3 100644 --- a/tests/mocha/blocks/variables_test.js +++ b/tests/mocha/blocks/variables_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -64,7 +65,7 @@ suite('Variables', function () { createTestVarBlock(this.workspace, '3'); const result = Blockly.Variables.allUsedVarModels(this.workspace); - chai.assert.equal( + assert.equal( result.length, 3, 'Expected three variables in the list of used variables', @@ -75,12 +76,12 @@ suite('Variables', function () { createTestVarBlock(this.workspace, '2'); const result = Blockly.Variables.allUsedVarModels(this.workspace); - chai.assert.equal( + assert.equal( result.length, 1, 'Expected one variable in the list of used variables', ); - chai.assert.equal( + assert.equal( result[0].getId(), '2', 'Expected variable with ID 2 in the list of used variables', @@ -94,12 +95,12 @@ suite('Variables', function () { const result = Blockly.Variables.allUsedVarModels(this.workspace); // Using the same variable multiple times should not change the number of // elements in the list. - chai.assert.equal( + assert.equal( result.length, 1, 'Expected one variable in the list of used variables', ); - chai.assert.equal( + assert.equal( result[0].getId(), '2', 'Expected variable with ID 2 in the list of used variables', @@ -108,7 +109,7 @@ suite('Variables', function () { test('All unused', function () { const result = Blockly.Variables.allUsedVarModels(this.workspace); - chai.assert.equal( + assert.equal( result.length, 0, 'Expected no variables in the list of used variables', @@ -125,9 +126,9 @@ suite('Variables', function () { const result2 = Blockly.Variables.getVariable(this.workspace, 'id2'); const result3 = Blockly.Variables.getVariable(this.workspace, 'id3'); - chai.assert.equal(var1, result1); - chai.assert.equal(var2, result2); - chai.assert.equal(var3, result3); + assert.equal(var1, result1); + assert.equal(var2, result2); + assert.equal(var3, result3); }); test('By name and type', function () { @@ -154,9 +155,9 @@ suite('Variables', function () { ); // Searching by name + type is correct. - chai.assert.equal(var1, result1); - chai.assert.equal(var2, result2); - chai.assert.equal(var3, result3); + assert.equal(var1, result1); + assert.equal(var2, result2); + assert.equal(var3, result3); }); test('Bad ID with name and type fallback', function () { @@ -183,9 +184,9 @@ suite('Variables', function () { ); // Searching by ID failed, but falling back onto name + type is correct. - chai.assert.equal(var1, result1); - chai.assert.equal(var2, result2); - chai.assert.equal(var3, result3); + assert.equal(var1, result1); + assert.equal(var2, result2); + assert.equal(var3, result3); }); }); @@ -214,7 +215,7 @@ suite('Variables', function () { this.workspace, ); - chai.assert.equal( + assert.equal( 'test name', nameUsedWithConflictingParam('x', 'y', this.workspace), 'Expected the name of the procedure with the conflicting ' + @@ -248,7 +249,7 @@ suite('Variables', function () { this.workspace, ); - chai.assert.isNull( + assert.isNull( nameUsedWithConflictingParam('x', 'y', this.workspace), 'Expected there to be no conflict', ); @@ -270,7 +271,7 @@ suite('Variables', function () { ), ); - chai.assert.equal( + assert.equal( 'test name', nameUsedWithConflictingParam('x', 'y', this.workspace), 'Expected the name of the procedure with the conflicting ' + @@ -299,7 +300,7 @@ suite('Variables', function () { ), ); - chai.assert.isNull( + assert.isNull( nameUsedWithConflictingParam('x', 'y', this.workspace), 'Expected there to be no conflict', ); diff --git a/tests/mocha/clipboard_test.js b/tests/mocha/clipboard_test.js index fb0c41882..37145de07 100644 --- a/tests/mocha/clipboard_test.js +++ b/tests/mocha/clipboard_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -30,7 +31,7 @@ suite('Clipboard', function () { Blockly.clipboard.registry.register('test-paster', paster); Blockly.clipboard.paste({paster: 'test-paster'}, this.workspace); - chai.assert.isTrue(paster.paste.calledOnce); + assert.isTrue(paster.paste.calledOnce); Blockly.clipboard.registry.unregister('test-paster'); }); @@ -73,7 +74,7 @@ suite('Clipboard', function () { const data = block.toCopyData(); const newBlock = Blockly.clipboard.paste(data, this.workspace); - chai.assert.deepEqual( + assert.deepEqual( newBlock.getRelativeToSurfaceXY(), new Blockly.utils.Coordinate(66, 69), ); @@ -105,7 +106,7 @@ suite('Clipboard', function () { const data = this.workspace.getBlockById('sourceBlockId').toCopyData(); const newBlock = Blockly.clipboard.paste(data, this.workspace); - chai.assert.deepEqual( + assert.deepEqual( newBlock.getRelativeToSurfaceXY(), new Blockly.utils.Coordinate(94, 125), ); @@ -126,7 +127,7 @@ suite('Clipboard', function () { const data = comment.toCopyData(); const newComment = Blockly.clipboard.paste(data, this.workspace); - chai.assert.deepEqual( + assert.deepEqual( newComment.getRelativeToSurfaceXY(), new Blockly.utils.Coordinate(60, 60), ); diff --git a/tests/mocha/comment_deserialization_test.js b/tests/mocha/comment_deserialization_test.js index 843453278..2517ed779 100644 --- a/tests/mocha/comment_deserialization_test.js +++ b/tests/mocha/comment_deserialization_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -60,23 +61,23 @@ suite('Comment Deserialization', function () { icon.setBubbleVisible(true); // Check comment bubble size. const bubbleSize = icon.getBubbleSize(); - chai.assert.isNotNaN(bubbleSize.width); - chai.assert.isNotNaN(bubbleSize.height); - chai.assert.equal(icon.getText(), text); + assert.isNotNaN(bubbleSize.width); + assert.isNotNaN(bubbleSize.height); + assert.equal(icon.getText(), text); } test('Trashcan', function () { // Create block. this.block = createBlock(this.workspace); // Delete block. this.block.checkAndDelete(); - chai.assert.equal(this.workspace.getAllBlocks().length, 0); + assert.equal(this.workspace.getAllBlocks().length, 0); // Open trashcan. simulateClick(this.workspace.trashcan.svgGroup); // Place from trashcan. simulateClick( this.workspace.trashcan.flyout.svgGroup_.querySelector('.blocklyPath'), ); - chai.assert.equal(this.workspace.getAllBlocks().length, 1); + assert.equal(this.workspace.getAllBlocks().length, 1); // Check comment. assertComment(this.workspace, 'test text'); }); @@ -85,10 +86,10 @@ suite('Comment Deserialization', function () { this.block = createBlock(this.workspace); // Delete block. this.block.checkAndDelete(); - chai.assert.equal(this.workspace.getAllBlocks().length, 0); + assert.equal(this.workspace.getAllBlocks().length, 0); // Undo. this.workspace.undo(false); - chai.assert.equal(this.workspace.getAllBlocks().length, 1); + assert.equal(this.workspace.getAllBlocks().length, 1); // Check comment. assertComment(this.workspace, 'test text'); }); @@ -98,11 +99,11 @@ suite('Comment Deserialization', function () { // Undo & undo. this.workspace.undo(false); this.workspace.undo(false); - chai.assert.equal(this.workspace.getAllBlocks().length, 0); + assert.equal(this.workspace.getAllBlocks().length, 0); // Redo & redo. this.workspace.undo(true); this.workspace.undo(true); - chai.assert.equal(this.workspace.getAllBlocks().length, 1); + assert.equal(this.workspace.getAllBlocks().length, 1); // Check comment. assertComment(this.workspace, 'test text'); }); @@ -113,7 +114,7 @@ suite('Comment Deserialization', function () { simulateClick( toolbox.getFlyout().svgGroup_.querySelector('.blocklyPath'), ); - chai.assert.equal(this.workspace.getAllBlocks().length, 1); + assert.equal(this.workspace.getAllBlocks().length, 1); // Check comment. assertComment(this.workspace, 'test toolbox text'); }); diff --git a/tests/mocha/comment_test.js b/tests/mocha/comment_test.js index 452f07493..d4091b9c2 100644 --- a/tests/mocha/comment_test.js +++ b/tests/mocha/comment_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import {assertEventFired} from './test_helpers/events.js'; import * as eventUtils from '../../build/src/core/events/utils.js'; import { @@ -40,16 +41,16 @@ suite('Comments', function () { }); function assertEditable(comment) { - chai.assert.isNotOk(comment.textBubble); - chai.assert.isOk(comment.textInputBubble); + assert.isNotOk(comment.textBubble); + assert.isOk(comment.textInputBubble); } function assertNotEditable(comment) { - chai.assert.isNotOk(comment.textInputBubble); - chai.assert.isOk(comment.textBubble); + assert.isNotOk(comment.textInputBubble); + assert.isOk(comment.textBubble); } test('Editable', async function () { await this.comment.setBubbleVisible(true); - chai.assert.isTrue(this.comment.bubbleIsVisible()); + assert.isTrue(this.comment.bubbleIsVisible()); assertEditable(this.comment); assertEventFired( this.eventsFireStub, @@ -64,7 +65,7 @@ suite('Comments', function () { await this.comment.setBubbleVisible(true); - chai.assert.isTrue(this.comment.bubbleIsVisible()); + assert.isTrue(this.comment.bubbleIsVisible()); assertNotEditable(this.comment); assertEventFired( this.eventsFireStub, @@ -80,7 +81,7 @@ suite('Comments', function () { await this.comment.updateEditable(); - chai.assert.isTrue(this.comment.bubbleIsVisible()); + assert.isTrue(this.comment.bubbleIsVisible()); assertNotEditable(this.comment); assertEventFired( this.eventsFireStub, @@ -98,7 +99,7 @@ suite('Comments', function () { editableStub.returns(true); await this.comment.updateEditable(); - chai.assert.isTrue(this.comment.bubbleIsVisible()); + assert.isTrue(this.comment.bubbleIsVisible()); assertEditable(this.comment); assertEventFired( this.eventsFireStub, @@ -115,8 +116,8 @@ suite('Comments', function () { }); function assertBubbleSize(comment, height, width) { const size = comment.getBubbleSize(); - chai.assert.equal(size.height, height); - chai.assert.equal(size.width, width); + assert.equal(size.height, height); + assert.equal(size.width, width); } function assertBubbleSizeDefault(comment) { assertBubbleSize(comment, 80, 160); diff --git a/tests/mocha/comment_view_test.js b/tests/mocha/comment_view_test.js index 6650848e5..57a247424 100644 --- a/tests/mocha/comment_view_test.js +++ b/tests/mocha/comment_view_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -28,11 +29,8 @@ suite('Workspace comment', function () { this.commentView.setText('test'); - chai.assert.isTrue( - spy.calledOnce, - 'Expected the spy to be called once', - ); - chai.assert.isTrue( + assert.isTrue(spy.calledOnce, 'Expected the spy to be called once'); + assert.isTrue( spy.calledWith('', 'test'), 'Expected the spy to be called with the given args', ); @@ -50,15 +48,15 @@ suite('Workspace comment', function () { this.commentView.setText('test'); - chai.assert.isTrue( + assert.isTrue( fake1.calledOnce, 'Expected the first listener to be called', ); - chai.assert.isTrue( + assert.isTrue( fake2.calledOnce, 'Expected the second listener to be called', ); - chai.assert.isTrue( + assert.isTrue( fake3.calledOnce, 'Expected the third listener to be called', ); @@ -74,11 +72,8 @@ suite('Workspace comment', function () { this.commentView.setSize(newSize); - chai.assert.isTrue( - spy.calledOnce, - 'Expected the spy to be called once', - ); - chai.assert.isTrue( + assert.isTrue(spy.calledOnce, 'Expected the spy to be called once'); + assert.isTrue( spy.calledWith(originalSize, newSize), 'Expected the spy to be called with the given args', ); @@ -97,15 +92,15 @@ suite('Workspace comment', function () { this.commentView.setSize(newSize); - chai.assert.isTrue( + assert.isTrue( fake1.calledOnce, 'Expected the first listener to be called', ); - chai.assert.isTrue( + assert.isTrue( fake2.calledOnce, 'Expected the second listener to be called', ); - chai.assert.isTrue( + assert.isTrue( fake3.calledOnce, 'Expected the third listener to be called', ); @@ -119,11 +114,8 @@ suite('Workspace comment', function () { this.commentView.setCollapsed(true); - chai.assert.isTrue( - spy.calledOnce, - 'Expected the spy to be called once', - ); - chai.assert.isTrue( + assert.isTrue(spy.calledOnce, 'Expected the spy to be called once'); + assert.isTrue( spy.calledWith(true), 'Expected the spy to be called with the given args', ); @@ -141,15 +133,15 @@ suite('Workspace comment', function () { this.commentView.setCollapsed(true); - chai.assert.isTrue( + assert.isTrue( fake1.calledOnce, 'Expected the first listener to be called', ); - chai.assert.isTrue( + assert.isTrue( fake2.calledOnce, 'Expected the second listener to be called', ); - chai.assert.isTrue( + assert.isTrue( fake3.calledOnce, 'Expected the third listener to be called', ); @@ -163,10 +155,7 @@ suite('Workspace comment', function () { this.commentView.dispose(); - chai.assert.isTrue( - spy.calledOnce, - 'Expected the spy to be called once', - ); + assert.isTrue(spy.calledOnce, 'Expected the spy to be called once'); }); test('dispose listeners can remove themselves without skipping others', function () { @@ -181,15 +170,15 @@ suite('Workspace comment', function () { this.commentView.dispose(); - chai.assert.isTrue( + assert.isTrue( fake1.calledOnce, 'Expected the first listener to be called', ); - chai.assert.isTrue( + assert.isTrue( fake2.calledOnce, 'Expected the second listener to be called', ); - chai.assert.isTrue( + assert.isTrue( fake3.calledOnce, 'Expected the third listener to be called', ); diff --git a/tests/mocha/connection_checker_test.js b/tests/mocha/connection_checker_test.js index 09797d6a7..20f85623a 100644 --- a/tests/mocha/connection_checker_test.js +++ b/tests/mocha/connection_checker_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import {ConnectionType} from '../../build/src/core/connection_type.js'; import { sharedTestSetup, @@ -22,9 +23,9 @@ suite('Connection checker', function () { }); suite('Safety checks', function () { function assertReasonHelper(checker, one, two, reason) { - chai.assert.equal(checker.canConnectWithReason(one, two), reason); + assert.equal(checker.canConnectWithReason(one, two), reason); // Order should not matter. - chai.assert.equal(checker.canConnectWithReason(two, one), reason); + assert.equal(checker.canConnectWithReason(two, one), reason); } test('Target Null', function () { @@ -452,9 +453,9 @@ suite('Connection checker', function () { this.con2 = new Blockly.Connection({}, ConnectionType.NEXT_STATEMENT); }); function assertCheckTypes(checker, one, two) { - chai.assert.isTrue(checker.doTypeChecks(one, two)); + assert.isTrue(checker.doTypeChecks(one, two)); // Order should not matter. - chai.assert.isTrue(checker.doTypeChecks(one, two)); + assert.isTrue(checker.doTypeChecks(one, two)); } test('No Types', function () { assertCheckTypes(this.checker, this.con1, this.con2); @@ -481,7 +482,7 @@ suite('Connection checker', function () { test('No Compatible Types', function () { this.con1.setCheck('type1'); this.con2.setCheck('type2'); - chai.assert.isFalse(this.checker.doTypeChecks(this.con1, this.con2)); + assert.isFalse(this.checker.doTypeChecks(this.con1, this.con2)); }); }); suite('Dragging Checks', function () { @@ -509,7 +510,7 @@ suite('Connection checker', function () { test('Connect a stack', function () { // block C is not connected to block A; both are movable. - chai.assert.isTrue( + assert.isTrue( this.checker.doDragChecks( this.blockC.nextConnection, this.blockA.previousConnection, @@ -543,7 +544,7 @@ suite('Connection checker', function () { // Try to connect blockC into the input connection of blockA, replacing blockB. // This is allowed because shadow blocks can always be replaced, even though // they are unmovable. - chai.assert.isTrue( + assert.isTrue( this.checker.doDragChecks( this.blockC.previousConnection, this.blockA.nextConnection, @@ -556,7 +557,7 @@ suite('Connection checker', function () { test('Do not splice into unmovable stack', function () { // Try to connect blockC above blockB. It shouldn't work because B is not movable // and is already connected to A's nextConnection. - chai.assert.isFalse( + assert.isFalse( this.checker.doDragChecks( this.blockC.previousConnection, this.blockA.nextConnection, @@ -569,7 +570,7 @@ suite('Connection checker', function () { test('Connect to bottom of unmovable stack', function () { // Try to connect blockC below blockB. // This is allowed even though B is not movable because it is on B's nextConnection. - chai.assert.isTrue( + assert.isTrue( this.checker.doDragChecks( this.blockC.previousConnection, this.blockB.nextConnection, @@ -585,7 +586,7 @@ suite('Connection checker', function () { // Try to connect blockC above blockB. // This is allowed because we're not splicing into a stack. - chai.assert.isTrue( + assert.isTrue( this.checker.doDragChecks( this.blockC.nextConnection, this.blockB.previousConnection, @@ -620,7 +621,7 @@ suite('Connection checker', function () { // Try to connect C's output to A's input. Should fail because // A is already connected to B, which is unmovable. const inputConnection = this.blockA.inputList[0].connection; - chai.assert.isFalse( + assert.isFalse( this.checker.doDragChecks( this.blockC.outputConnection, inputConnection, @@ -635,7 +636,7 @@ suite('Connection checker', function () { this.blockC.setMovable(false); // Try to connect A's output to C's input. This is allowed. const inputConnection = this.blockC.inputList[0].connection; - chai.assert.isTrue( + assert.isTrue( this.checker.doDragChecks( this.blockA.outputConnection, inputConnection, @@ -651,7 +652,7 @@ suite('Connection checker', function () { // Try to connect C's input to B's output. Allowed because B is now unconnected. const inputConnection = this.blockC.inputList[0].connection; - chai.assert.isTrue( + assert.isTrue( this.checker.doDragChecks( inputConnection, this.blockB.outputConnection, diff --git a/tests/mocha/connection_db_test.js b/tests/mocha/connection_db_test.js index 9cf579f1b..11eeecf31 100644 --- a/tests/mocha/connection_db_test.js +++ b/tests/mocha/connection_db_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import {ConnectionType} from '../../build/src/core/connection_type.js'; import { sharedTestSetup, @@ -18,7 +19,7 @@ suite('Connection Database', function () { this.assertOrder = function () { const length = this.database.connections.length; for (let i = 1; i < length; i++) { - chai.assert.isAtMost( + assert.isAtMost( this.database.connections[i - 1].y, this.database.connections[i].y, ); @@ -59,24 +60,19 @@ suite('Connection Database', function () { const y3b = {y: 3}; this.database.addConnection(y2, 2); - chai.assert.sameOrderedMembers(this.database.connections, [y2]); + assert.sameOrderedMembers(this.database.connections, [y2]); this.database.addConnection(y4, 4); - chai.assert.sameOrderedMembers(this.database.connections, [y2, y4]); + assert.sameOrderedMembers(this.database.connections, [y2, y4]); this.database.addConnection(y1, 1); - chai.assert.sameOrderedMembers(this.database.connections, [y1, y2, y4]); + assert.sameOrderedMembers(this.database.connections, [y1, y2, y4]); this.database.addConnection(y3a, 3); - chai.assert.sameOrderedMembers(this.database.connections, [ - y1, - y2, - y3a, - y4, - ]); + assert.sameOrderedMembers(this.database.connections, [y1, y2, y3a, y4]); this.database.addConnection(y3b, 3); - chai.assert.sameOrderedMembers(this.database.connections, [ + assert.sameOrderedMembers(this.database.connections, [ y1, y2, y3b, @@ -99,7 +95,7 @@ suite('Connection Database', function () { this.database.addConnection(y3b, 3); this.database.addConnection(y3a, 3); - chai.assert.sameOrderedMembers(this.database.connections, [ + assert.sameOrderedMembers(this.database.connections, [ y1, y2, y3a, @@ -109,7 +105,7 @@ suite('Connection Database', function () { ]); this.database.removeConnection(y2, 2); - chai.assert.sameOrderedMembers(this.database.connections, [ + assert.sameOrderedMembers(this.database.connections, [ y1, y3a, y3b, @@ -118,24 +114,19 @@ suite('Connection Database', function () { ]); this.database.removeConnection(y4, 4); - chai.assert.sameOrderedMembers(this.database.connections, [ - y1, - y3a, - y3b, - y3c, - ]); + assert.sameOrderedMembers(this.database.connections, [y1, y3a, y3b, y3c]); this.database.removeConnection(y1, 1); - chai.assert.sameOrderedMembers(this.database.connections, [y3a, y3b, y3c]); + assert.sameOrderedMembers(this.database.connections, [y3a, y3b, y3c]); this.database.removeConnection(y3a, 3); - chai.assert.sameOrderedMembers(this.database.connections, [y3b, y3c]); + assert.sameOrderedMembers(this.database.connections, [y3b, y3c]); this.database.removeConnection(y3c, 3); - chai.assert.sameOrderedMembers(this.database.connections, [y3b]); + assert.sameOrderedMembers(this.database.connections, [y3b]); this.database.removeConnection(y3b, 3); - chai.assert.isEmpty(this.database.connections); + assert.isEmpty(this.database.connections); }); suite('Get Neighbors', function () { test('Empty Database', function () { @@ -145,7 +136,7 @@ suite('Connection Database', function () { ConnectionType.NEXT_STATEMENT, new Blockly.ConnectionDB(), ); - chai.assert.isEmpty(this.database.getNeighbours(connection), 100); + assert.isEmpty(this.database.getNeighbours(connection), 100); }); test('Block At Top', function () { this.createSimpleTestConnections(); @@ -157,7 +148,7 @@ suite('Connection Database', function () { new Blockly.ConnectionDB(), ); const neighbors = this.database.getNeighbours(checkConnection, 4); - chai.assert.sameMembers(neighbors, this.database.connections.slice(0, 5)); + assert.sameMembers(neighbors, this.database.connections.slice(0, 5)); }); test('Block In Middle', function () { this.createSimpleTestConnections(); @@ -169,7 +160,7 @@ suite('Connection Database', function () { new Blockly.ConnectionDB(), ); const neighbors = this.database.getNeighbours(checkConnection, 2); - chai.assert.sameMembers(neighbors, this.database.connections.slice(2, 7)); + assert.sameMembers(neighbors, this.database.connections.slice(2, 7)); }); test('Block At End', function () { this.createSimpleTestConnections(); @@ -181,10 +172,7 @@ suite('Connection Database', function () { new Blockly.ConnectionDB(), ); const neighbors = this.database.getNeighbours(checkConnection, 4); - chai.assert.sameMembers( - neighbors, - this.database.connections.slice(5, 10), - ); + assert.sameMembers(neighbors, this.database.connections.slice(5, 10)); }); test('Out of Range X', function () { this.createSimpleTestConnections(); @@ -196,7 +184,7 @@ suite('Connection Database', function () { new Blockly.ConnectionDB(), ); const neighbors = this.database.getNeighbours(checkConnection, 4); - chai.assert.isEmpty(neighbors); + assert.isEmpty(neighbors); }); test('Out of Range Y', function () { this.createSimpleTestConnections(); @@ -208,7 +196,7 @@ suite('Connection Database', function () { new Blockly.ConnectionDB(), ); const neighbors = this.database.getNeighbours(checkConnection, 4); - chai.assert.isEmpty(neighbors); + assert.isEmpty(neighbors); }); test('Out of Range Diagonal', function () { this.createSimpleTestConnections(); @@ -220,7 +208,7 @@ suite('Connection Database', function () { new Blockly.ConnectionDB(), ); const neighbors = this.database.getNeighbours(checkConnection, 2); - chai.assert.isEmpty(neighbors); + assert.isEmpty(neighbors); }); }); suite('Ordering', function () { @@ -300,7 +288,7 @@ suite('Connection Database', function () { ConnectionType.NEXT_STATEMENT, new Blockly.ConnectionDB(), ); - chai.assert.isNull( + assert.isNull( this.database.searchForClosest(checkConnection, 100, {x: 0, y: 0}) .connection, ); @@ -319,7 +307,7 @@ suite('Connection Database', function () { ConnectionType.NEXT_STATEMENT, new Blockly.ConnectionDB(), ); - chai.assert.isNull( + assert.isNull( this.database.searchForClosest(checkConnection, 50, {x: 0, y: 0}) .connection, ); @@ -334,7 +322,7 @@ suite('Connection Database', function () { x: 0, y: 0, }).connection; - chai.assert.equal(last, closest); + assert.equal(last, closest); }); test('Many in Range', function () { this.createSimpleTestConnections(); @@ -346,7 +334,7 @@ suite('Connection Database', function () { x: 0, y: 0, }).connection; - chai.assert.equal(last, closest); + assert.equal(last, closest); }); test('No Y-Coord Priority', function () { const connection1 = this.createConnection( @@ -368,7 +356,7 @@ suite('Connection Database', function () { x: 0, y: 0, }).connection; - chai.assert.equal(connection2, closest); + assert.equal(connection2, closest); }); }); }); diff --git a/tests/mocha/connection_test.js b/tests/mocha/connection_test.js index afba4948c..040f59f40 100644 --- a/tests/mocha/connection_test.js +++ b/tests/mocha/connection_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { createGenUidStubWithReturns, sharedTestSetup, @@ -39,19 +40,19 @@ suite('Connection', function () { suite('Set Shadow', function () { function assertBlockMatches(block, isShadow, opt_id) { - chai.assert.equal( + assert.equal( block.isShadow(), isShadow, `expected block ${block.id} to ${isShadow ? '' : 'not'} be a shadow`, ); if (opt_id) { - chai.assert.equal(block.id, opt_id); + assert.equal(block.id, opt_id); } } function assertInputHasBlock(parent, inputName, isShadow, opt_name) { const block = parent.getInputTargetBlock(inputName); - chai.assert.exists( + assert.exists( block, `expected block ${opt_name || ''} to be attached to ${inputName}`, ); @@ -60,7 +61,7 @@ suite('Connection', function () { function assertNextHasBlock(parent, isShadow, opt_name) { const block = parent.getNextBlock(); - chai.assert.exists( + assert.exists( block, `expected block ${opt_name || ''} to be attached to next connection`, ); @@ -69,7 +70,7 @@ suite('Connection', function () { function assertInputNotHasBlock(parent, inputName) { const block = parent.getInputTargetBlock(inputName); - chai.assert.notExists( + assert.notExists( block, `expected block ${ block && block.id @@ -79,7 +80,7 @@ suite('Connection', function () { function assertNextNotHasBlock(parent) { const block = parent.getNextBlock(); - chai.assert.notExists( + assert.notExists( block, `expected block ${ block && block.id @@ -92,8 +93,8 @@ suite('Connection', function () { addNextBlocks: true, }); const actualXml = Blockly.Xml.domToText(Blockly.Xml.blockToDom(block)); - chai.assert.deepEqual(actualJso, jso); - chai.assert.equal(actualXml, xmlText); + assert.deepEqual(actualJso, jso); + assert.equal(actualXml, xmlText); } const testSuites = [ @@ -1382,7 +1383,7 @@ suite('Connection', function () { suite('Invalid', function () { test('Attach to output', function () { const block = this.workspace.newBlock('row_block'); - chai.assert.throws(() => + assert.throws(() => block.outputConnection.setShadowDom( Blockly.utils.xml.textToDom(''), ), @@ -1391,7 +1392,7 @@ suite('Connection', function () { test('Attach to previous', function () { const block = this.workspace.newBlock('stack_block'); - chai.assert.throws(() => + assert.throws(() => block.previousConnection.setShadowDom( Blockly.utils.xml.textToDom(''), ), @@ -1400,7 +1401,7 @@ suite('Connection', function () { test('Missing output', function () { const block = this.workspace.newBlock('row_block'); - chai.assert.throws(() => + assert.throws(() => block.outputConnection.setShadowDom( Blockly.utils.xml.textToDom(''), ), @@ -1409,7 +1410,7 @@ suite('Connection', function () { test('Missing previous', function () { const block = this.workspace.newBlock('stack_block'); - chai.assert.throws(() => + assert.throws(() => block.previousConnection.setShadowDom( Blockly.utils.xml.textToDom(''), ), @@ -1418,7 +1419,7 @@ suite('Connection', function () { test('Invalid connection checks, output', function () { const block = this.workspace.newBlock('logic_operation'); - chai.assert.throws(() => + assert.throws(() => block .getInput('A') .connection.setShadowDom( @@ -1437,7 +1438,7 @@ suite('Connection', function () { }, ]); const block = this.workspace.newBlock('stack_checks_block'); - chai.assert.throws(() => + assert.throws(() => block.nextConnection.setShadowDom( Blockly.utils.xml.textToDom( '', @@ -2751,14 +2752,14 @@ suite('Connection', function () { suite('Invalid', function () { test('Attach to output', function () { const block = this.workspace.newBlock('row_block'); - chai.assert.throws(() => + assert.throws(() => block.outputConnection.setShadowState({'type': 'row_block'}), ); }); test('Attach to previous', function () { const block = this.workspace.newBlock('stack_block'); - chai.assert.throws(() => + assert.throws(() => block.previousConnection.setShadowState({ 'type': 'stack_block', }), @@ -2767,21 +2768,21 @@ suite('Connection', function () { test('Missing output', function () { const block = this.workspace.newBlock('row_block'); - chai.assert.throws(() => + assert.throws(() => block.outputConnection.setShadowState({'type': 'stack_block'}), ); }); test('Missing previous', function () { const block = this.workspace.newBlock('stack_block'); - chai.assert.throws(() => + assert.throws(() => block.previousConnection.setShadowState({'type': 'row_block'}), ); }); test('Invalid connection checks, output', function () { const block = this.workspace.newBlock('logic_operation'); - chai.assert.throws(() => + assert.throws(() => block .getInput('A') .connection.setShadowState({'type': 'math_number'}), @@ -2798,7 +2799,7 @@ suite('Connection', function () { }, ]); const block = this.workspace.newBlock('stack_checks_block'); - chai.assert.throws(() => + assert.throws(() => block.nextConnection.setShadowState({ 'type': 'stack_checks_block', }), @@ -2984,7 +2985,7 @@ suite('Connection', function () { // Used to make sure we don't get stray shadow blocks or anything. this.assertBlockCount = function (count) { - chai.assert.equal(this.workspace.getAllBlocks().length, count); + assert.equal(this.workspace.getAllBlocks().length, count); }; }); @@ -2997,9 +2998,7 @@ suite('Connection', function () { oldParent.getInput('INPUT').connection.connect(child.outputConnection); newParent.getInput('INPUT').connection.connect(child.outputConnection); - chai.assert.isFalse( - oldParent.getInput('INPUT').connection.isConnected(), - ); + assert.isFalse(oldParent.getInput('INPUT').connection.isConnected()); this.assertBlockCount(3); }); @@ -3011,9 +3010,7 @@ suite('Connection', function () { oldParent.getInput('NAME').connection.connect(child.previousConnection); newParent.getInput('NAME').connection.connect(child.previousConnection); - chai.assert.isFalse( - oldParent.getInput('NAME').connection.isConnected(), - ); + assert.isFalse(oldParent.getInput('NAME').connection.isConnected()); this.assertBlockCount(3); }); @@ -3025,7 +3022,7 @@ suite('Connection', function () { oldParent.nextConnection.connect(child.previousConnection); newParent.nextConnection.connect(child.previousConnection); - chai.assert.isFalse(oldParent.nextConnection.isConnected()); + assert.isFalse(oldParent.nextConnection.isConnected()); this.assertBlockCount(3); }); }); @@ -3036,11 +3033,11 @@ suite('Connection', function () { const child = this.workspace.newBlock('row_block'); const xml = Blockly.utils.xml.textToDom(''); newParent.getInput('INPUT').connection.setShadowDom(xml); - chai.assert.isTrue(newParent.getInputTargetBlock('INPUT').isShadow()); + assert.isTrue(newParent.getInputTargetBlock('INPUT').isShadow()); newParent.getInput('INPUT').connection.connect(child.outputConnection); - chai.assert.isFalse(newParent.getInputTargetBlock('INPUT').isShadow()); + assert.isFalse(newParent.getInputTargetBlock('INPUT').isShadow()); this.assertBlockCount(2); }); @@ -3049,11 +3046,11 @@ suite('Connection', function () { const child = this.workspace.newBlock('stack_block'); const xml = Blockly.utils.xml.textToDom(''); newParent.getInput('NAME').connection.setShadowDom(xml); - chai.assert.isTrue(newParent.getInputTargetBlock('NAME').isShadow()); + assert.isTrue(newParent.getInputTargetBlock('NAME').isShadow()); newParent.getInput('NAME').connection.connect(child.previousConnection); - chai.assert.isFalse(newParent.getInputTargetBlock('NAME').isShadow()); + assert.isFalse(newParent.getInputTargetBlock('NAME').isShadow()); this.assertBlockCount(2); }); @@ -3062,11 +3059,11 @@ suite('Connection', function () { const child = this.workspace.newBlock('stack_block'); const xml = Blockly.utils.xml.textToDom(''); newParent.nextConnection.setShadowDom(xml); - chai.assert.isTrue(newParent.getNextBlock().isShadow()); + assert.isTrue(newParent.getNextBlock().isShadow()); newParent.nextConnection.connect(child.previousConnection); - chai.assert.isFalse(newParent.getNextBlock().isShadow()); + assert.isFalse(newParent.getNextBlock().isShadow()); this.assertBlockCount(2); }); }); @@ -3083,8 +3080,8 @@ suite('Connection', function () { newParent.getInput('INPUT').connection.disconnect(); const target = newParent.getInputTargetBlock('INPUT'); - chai.assert.isTrue(target.isShadow()); - chai.assert.equal(target.getFieldValue('FIELD'), 'new'); + assert.isTrue(target.isShadow()); + assert.equal(target.getFieldValue('FIELD'), 'new'); this.assertBlockCount(3); }); @@ -3099,8 +3096,8 @@ suite('Connection', function () { newParent.getInput('NAME').connection.disconnect(); const target = newParent.getInputTargetBlock('NAME'); - chai.assert.isTrue(target.isShadow()); - chai.assert.equal(target.getFieldValue('FIELD'), 'new'); + assert.isTrue(target.isShadow()); + assert.equal(target.getFieldValue('FIELD'), 'new'); this.assertBlockCount(3); }); @@ -3115,8 +3112,8 @@ suite('Connection', function () { newParent.nextConnection.disconnect(); const target = newParent.getNextBlock(); - chai.assert.isTrue(target.isShadow()); - chai.assert.equal(target.getFieldValue('FIELD'), 'new'); + assert.isTrue(target.isShadow()); + assert.equal(target.getFieldValue('FIELD'), 'new'); this.assertBlockCount(3); }); }); @@ -3136,11 +3133,9 @@ suite('Connection', function () { .getInput('INPUT') .connection.connect(newChild.outputConnection); - chai.assert.isTrue( - parent.getInput('INPUT').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('INPUT'), newChild); - chai.assert.isFalse(oldChild.outputConnection.isConnected()); + assert.isTrue(parent.getInput('INPUT').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('INPUT'), newChild); + assert.isFalse(oldChild.outputConnection.isConnected()); }); test('All statements', function () { @@ -3155,11 +3150,9 @@ suite('Connection', function () { .getInput('INPUT') .connection.connect(newChild.outputConnection); - chai.assert.isTrue( - parent.getInput('INPUT').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('INPUT'), newChild); - chai.assert.isFalse(oldChild.outputConnection.isConnected()); + assert.isTrue(parent.getInput('INPUT').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('INPUT'), newChild); + assert.isFalse(oldChild.outputConnection.isConnected()); }); test('Bad checks', function () { @@ -3174,11 +3167,9 @@ suite('Connection', function () { .getInput('INPUT') .connection.connect(newChild.outputConnection); - chai.assert.isTrue( - parent.getInput('INPUT').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('INPUT'), newChild); - chai.assert.isFalse(oldChild.outputConnection.isConnected()); + assert.isTrue(parent.getInput('INPUT').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('INPUT'), newChild); + assert.isFalse(oldChild.outputConnection.isConnected()); }); test('Through different types', function () { @@ -3198,11 +3189,9 @@ suite('Connection', function () { .getInput('INPUT') .connection.connect(newChild.outputConnection); - chai.assert.isTrue( - parent.getInput('INPUT').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('INPUT'), newChild); - chai.assert.isFalse(oldChild.outputConnection.isConnected()); + assert.isTrue(parent.getInput('INPUT').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('INPUT'), newChild); + assert.isFalse(oldChild.outputConnection.isConnected()); }); }); @@ -3223,11 +3212,9 @@ suite('Connection', function () { .getInput('INPUT') .connection.connect(newChild.outputConnection); - chai.assert.isTrue( - parent.getInput('INPUT').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('INPUT'), newChild); - chai.assert.isFalse(oldChild.outputConnection.isConnected()); + assert.isTrue(parent.getInput('INPUT').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('INPUT'), newChild); + assert.isFalse(oldChild.outputConnection.isConnected()); }); test('Child blocks', function () { @@ -3253,11 +3240,9 @@ suite('Connection', function () { .getInput('INPUT') .connection.connect(newChild.outputConnection); - chai.assert.isTrue( - parent.getInput('INPUT').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('INPUT'), newChild); - chai.assert.isFalse(oldChild.outputConnection.isConnected()); + assert.isTrue(parent.getInput('INPUT').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('INPUT'), newChild); + assert.isFalse(oldChild.outputConnection.isConnected()); }); test('Spots filled', function () { @@ -3279,11 +3264,9 @@ suite('Connection', function () { .getInput('INPUT') .connection.connect(newChild.outputConnection); - chai.assert.isTrue( - parent.getInput('INPUT').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('INPUT'), newChild); - chai.assert.isFalse(oldChild.outputConnection.isConnected()); + assert.isTrue(parent.getInput('INPUT').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('INPUT'), newChild); + assert.isFalse(oldChild.outputConnection.isConnected()); }); }); @@ -3317,11 +3300,9 @@ suite('Connection', function () { .getInput('INPUT') .connection.connect(newChild.outputConnection); - chai.assert.isTrue( - parent.getInput('INPUT').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('INPUT'), newChild); - chai.assert.isFalse(oldChild.outputConnection.isConnected()); + assert.isTrue(parent.getInput('INPUT').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('INPUT'), newChild); + assert.isFalse(oldChild.outputConnection.isConnected()); }); test('Child blocks', function () { @@ -3361,11 +3342,9 @@ suite('Connection', function () { .getInput('INPUT') .connection.connect(newChild.outputConnection); - chai.assert.isTrue( - parent.getInput('INPUT').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('INPUT'), newChild); - chai.assert.isFalse(oldChild.outputConnection.isConnected()); + assert.isTrue(parent.getInput('INPUT').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('INPUT'), newChild); + assert.isFalse(oldChild.outputConnection.isConnected()); }); test('Spots filled', function () { @@ -3394,11 +3373,9 @@ suite('Connection', function () { .getInput('INPUT') .connection.connect(newChild.outputConnection); - chai.assert.isTrue( - parent.getInput('INPUT').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('INPUT'), newChild); - chai.assert.isFalse(oldChild.outputConnection.isConnected()); + assert.isTrue(parent.getInput('INPUT').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('INPUT'), newChild); + assert.isFalse(oldChild.outputConnection.isConnected()); }); }); }); @@ -3417,14 +3394,10 @@ suite('Connection', function () { .getInput('INPUT') .connection.connect(newChild.outputConnection); - chai.assert.isTrue( - parent.getInput('INPUT').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('INPUT'), newChild); - chai.assert.isTrue( - newChild.getInput('INPUT').connection.isConnected(), - ); - chai.assert.equal(newChild.getInputTargetBlock('INPUT'), oldChild); + assert.isTrue(parent.getInput('INPUT').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('INPUT'), newChild); + assert.isTrue(newChild.getInput('INPUT').connection.isConnected()); + assert.equal(newChild.getInputTargetBlock('INPUT'), oldChild); }); test('Shadows', function () { @@ -3447,14 +3420,10 @@ suite('Connection', function () { .getInput('INPUT') .connection.connect(newChild.outputConnection); - chai.assert.isTrue( - parent.getInput('INPUT').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('INPUT'), newChild); - chai.assert.isTrue( - newChild.getInput('INPUT').connection.isConnected(), - ); - chai.assert.equal(newChild.getInputTargetBlock('INPUT'), oldChild); + assert.isTrue(parent.getInput('INPUT').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('INPUT'), newChild); + assert.isTrue(newChild.getInput('INPUT').connection.isConnected()); + assert.equal(newChild.getInputTargetBlock('INPUT'), oldChild); }); }); }); @@ -3473,12 +3442,10 @@ suite('Connection', function () { .getInput('NAME') .connection.connect(newChild.previousConnection); - chai.assert.isTrue( - parent.getInput('NAME').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('NAME'), newChild); - chai.assert.isTrue(newChild.nextConnection.isConnected()); - chai.assert.equal(newChild.getNextBlock(), oldChild); + assert.isTrue(parent.getInput('NAME').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('NAME'), newChild); + assert.isTrue(newChild.nextConnection.isConnected()); + assert.equal(newChild.getNextBlock(), oldChild); this.assertBlockCount(3); }); @@ -3496,12 +3463,10 @@ suite('Connection', function () { .getInput('NAME') .connection.connect(newChild1.previousConnection); - chai.assert.isTrue( - parent.getInput('NAME').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('NAME'), newChild1); - chai.assert.isTrue(newChild2.nextConnection.isConnected()); - chai.assert.equal(newChild2.getNextBlock(), oldChild); + assert.isTrue(parent.getInput('NAME').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('NAME'), newChild1); + assert.isTrue(newChild2.nextConnection.isConnected()); + assert.equal(newChild2.getNextBlock(), oldChild); this.assertBlockCount(4); }); @@ -3521,12 +3486,10 @@ suite('Connection', function () { .getInput('NAME') .connection.connect(newChild.previousConnection); - chai.assert.isTrue( - parent.getInput('NAME').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('NAME'), newChild); - chai.assert.isFalse(newChild.nextConnection.isConnected()); - chai.assert.isTrue(spy.calledOnce); + assert.isTrue(parent.getInput('NAME').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('NAME'), newChild); + assert.isFalse(newChild.nextConnection.isConnected()); + assert.isTrue(spy.calledOnce); this.assertBlockCount(3); }); @@ -3546,11 +3509,9 @@ suite('Connection', function () { .getInput('NAME') .connection.connect(newChild.previousConnection); - chai.assert.isTrue( - parent.getInput('NAME').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('NAME'), newChild); - chai.assert.isTrue(spy.calledOnce); + assert.isTrue(parent.getInput('NAME').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('NAME'), newChild); + assert.isTrue(spy.calledOnce); this.assertBlockCount(3); }); }); @@ -3572,12 +3533,10 @@ suite('Connection', function () { .getInput('NAME') .connection.connect(newChild.previousConnection); - chai.assert.isTrue( - parent.getInput('NAME').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('NAME'), newChild); - chai.assert.isTrue(newChild.nextConnection.isConnected()); - chai.assert.equal(newChild.getNextBlock(), oldChild); + assert.isTrue(parent.getInput('NAME').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('NAME'), newChild); + assert.isTrue(newChild.nextConnection.isConnected()); + assert.equal(newChild.getNextBlock(), oldChild); this.assertBlockCount(3); }); @@ -3599,12 +3558,10 @@ suite('Connection', function () { .getInput('NAME') .connection.connect(newChild1.previousConnection); - chai.assert.isTrue( - parent.getInput('NAME').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('NAME'), newChild1); - chai.assert.isTrue(newChild2.nextConnection.isConnected()); - chai.assert.equal(newChild2.getNextBlock(), oldChild); + assert.isTrue(parent.getInput('NAME').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('NAME'), newChild1); + assert.isTrue(newChild2.nextConnection.isConnected()); + assert.equal(newChild2.getNextBlock(), oldChild); this.assertBlockCount(4); }); @@ -3628,13 +3585,11 @@ suite('Connection', function () { .getInput('NAME') .connection.connect(newChild.previousConnection); - chai.assert.isTrue( - parent.getInput('NAME').connection.isConnected(), - ); - chai.assert.equal(parent.getInputTargetBlock('NAME'), newChild); - chai.assert.isTrue(newChild.nextConnection.isConnected()); - chai.assert.isTrue(newChild.getNextBlock().isShadow()); - chai.assert.isTrue(spy.calledOnce); + assert.isTrue(parent.getInput('NAME').connection.isConnected()); + assert.equal(parent.getInputTargetBlock('NAME'), newChild); + assert.isTrue(newChild.nextConnection.isConnected()); + assert.isTrue(newChild.getNextBlock().isShadow()); + assert.isTrue(spy.calledOnce); this.assertBlockCount(4); }); }); @@ -3650,10 +3605,10 @@ suite('Connection', function () { parent.nextConnection.connect(newChild.previousConnection); - chai.assert.isTrue(parent.nextConnection.isConnected()); - chai.assert.equal(parent.getNextBlock(), newChild); - chai.assert.isTrue(newChild.nextConnection.isConnected()); - chai.assert.equal(newChild.getNextBlock(), oldChild); + assert.isTrue(parent.nextConnection.isConnected()); + assert.equal(parent.getNextBlock(), newChild); + assert.isTrue(newChild.nextConnection.isConnected()); + assert.equal(newChild.getNextBlock(), oldChild); this.assertBlockCount(3); }); @@ -3667,10 +3622,10 @@ suite('Connection', function () { parent.nextConnection.connect(newChild1.previousConnection); - chai.assert.isTrue(parent.nextConnection.isConnected()); - chai.assert.equal(parent.getNextBlock(), newChild1); - chai.assert.isTrue(newChild2.nextConnection.isConnected()); - chai.assert.equal(newChild2.getNextBlock(), oldChild); + assert.isTrue(parent.nextConnection.isConnected()); + assert.equal(parent.getNextBlock(), newChild1); + assert.isTrue(newChild2.nextConnection.isConnected()); + assert.equal(newChild2.getNextBlock(), oldChild); this.assertBlockCount(4); }); @@ -3686,10 +3641,10 @@ suite('Connection', function () { parent.nextConnection.connect(newChild.previousConnection); - chai.assert.isTrue(parent.nextConnection.isConnected()); - chai.assert.equal(parent.getNextBlock(), newChild); - chai.assert.isFalse(newChild.nextConnection.isConnected()); - chai.assert.isTrue(spy.calledOnce); + assert.isTrue(parent.nextConnection.isConnected()); + assert.equal(parent.getNextBlock(), newChild); + assert.isFalse(newChild.nextConnection.isConnected()); + assert.isTrue(spy.calledOnce); this.assertBlockCount(3); }); @@ -3705,9 +3660,9 @@ suite('Connection', function () { parent.nextConnection.connect(newChild.previousConnection); - chai.assert.isTrue(parent.nextConnection.isConnected()); - chai.assert.equal(parent.getNextBlock(), newChild); - chai.assert.isTrue(spy.calledOnce); + assert.isTrue(parent.nextConnection.isConnected()); + assert.equal(parent.getNextBlock(), newChild); + assert.isTrue(spy.calledOnce); this.assertBlockCount(3); }); }); @@ -3725,10 +3680,10 @@ suite('Connection', function () { parent.nextConnection.connect(newChild.previousConnection); - chai.assert.isTrue(parent.nextConnection.isConnected()); - chai.assert.equal(parent.getNextBlock(), newChild); - chai.assert.isTrue(newChild.nextConnection.isConnected()); - chai.assert.equal(newChild.getNextBlock(), oldChild); + assert.isTrue(parent.nextConnection.isConnected()); + assert.equal(parent.getNextBlock(), newChild); + assert.isTrue(newChild.nextConnection.isConnected()); + assert.equal(newChild.getNextBlock(), oldChild); this.assertBlockCount(3); }); @@ -3746,10 +3701,10 @@ suite('Connection', function () { parent.nextConnection.connect(newChild1.previousConnection); - chai.assert.isTrue(parent.nextConnection.isConnected()); - chai.assert.equal(parent.getNextBlock(), newChild1); - chai.assert.isTrue(newChild2.nextConnection.isConnected()); - chai.assert.equal(newChild2.getNextBlock(), oldChild); + assert.isTrue(parent.nextConnection.isConnected()); + assert.equal(parent.getNextBlock(), newChild1); + assert.isTrue(newChild2.nextConnection.isConnected()); + assert.equal(newChild2.getNextBlock(), oldChild); this.assertBlockCount(4); }); @@ -3769,11 +3724,11 @@ suite('Connection', function () { parent.nextConnection.connect(newChild.previousConnection); - chai.assert.isTrue(parent.nextConnection.isConnected()); - chai.assert.equal(parent.getNextBlock(), newChild); - chai.assert.isTrue(newChild.nextConnection.isConnected()); - chai.assert.isTrue(newChild.getNextBlock().isShadow()); - chai.assert.isTrue(spy.calledOnce); + assert.isTrue(parent.nextConnection.isConnected()); + assert.equal(parent.getNextBlock(), newChild); + assert.isTrue(newChild.nextConnection.isConnected()); + assert.isTrue(newChild.getNextBlock().isShadow()); + assert.isTrue(spy.calledOnce); this.assertBlockCount(4); }); }); diff --git a/tests/mocha/contextmenu_items_test.js b/tests/mocha/contextmenu_items_test.js index 4596513c6..b5d480c37 100644 --- a/tests/mocha/contextmenu_items_test.js +++ b/tests/mocha/contextmenu_items_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -39,7 +40,7 @@ suite('Context Menu Items', function () { test('Disabled when nothing to undo', function () { const precondition = this.undoOption.preconditionFn(this.scope); - chai.assert.equal( + assert.equal( precondition, 'disabled', 'Should be disabled when there is nothing to undo', @@ -50,7 +51,7 @@ suite('Context Menu Items', function () { // Create a new block, which should be undoable. this.workspace.newBlock('text'); const precondition = this.undoOption.preconditionFn(this.scope); - chai.assert.equal( + assert.equal( precondition, 'enabled', 'Should be enabled when there are actions to undo', @@ -59,9 +60,9 @@ suite('Context Menu Items', function () { test('Undoes adding a new block', function () { this.workspace.newBlock('text'); - chai.assert.equal(this.workspace.getTopBlocks(false).length, 1); + assert.equal(this.workspace.getTopBlocks(false).length, 1); this.undoOption.callback(this.scope); - chai.assert.equal( + assert.equal( this.workspace.getTopBlocks(false).length, 0, 'Should be no blocks after undo', @@ -69,7 +70,7 @@ suite('Context Menu Items', function () { }); test('Has correct label', function () { - chai.assert.equal(this.undoOption.displayText(), 'Undo'); + assert.equal(this.undoOption.displayText(), 'Undo'); }); }); @@ -82,7 +83,7 @@ suite('Context Menu Items', function () { // Create a new block. There should be something to undo, but not redo. this.workspace.newBlock('text'); const precondition = this.redoOption.preconditionFn(this.scope); - chai.assert.equal( + assert.equal( precondition, 'disabled', 'Should be disabled when there is nothing to redo', @@ -94,7 +95,7 @@ suite('Context Menu Items', function () { this.workspace.newBlock('text'); this.workspace.undo(false); const precondition = this.redoOption.preconditionFn(this.scope); - chai.assert.equal( + assert.equal( precondition, 'enabled', 'Should be enabled when there are actions to redo', @@ -105,9 +106,9 @@ suite('Context Menu Items', function () { // Add a new block, then undo it, then redo it. this.workspace.newBlock('text'); this.workspace.undo(false); - chai.assert.equal(this.workspace.getTopBlocks(false).length, 0); + assert.equal(this.workspace.getTopBlocks(false).length, 0); this.redoOption.callback(this.scope); - chai.assert.equal( + assert.equal( this.workspace.getTopBlocks(false).length, 1, 'Should be 1 block after redo', @@ -115,7 +116,7 @@ suite('Context Menu Items', function () { }); test('Has correct label', function () { - chai.assert.equal(this.redoOption.displayText(), 'Redo'); + assert.equal(this.redoOption.displayText(), 'Redo'); }); }); @@ -128,7 +129,7 @@ suite('Context Menu Items', function () { test('Enabled when multiple blocks', function () { this.workspace.newBlock('text'); this.workspace.newBlock('text'); - chai.assert.equal( + assert.equal( this.cleanupOption.preconditionFn(this.scope), 'enabled', 'Should be enabled if there are multiple blocks', @@ -136,7 +137,7 @@ suite('Context Menu Items', function () { }); test('Disabled when no blocks', function () { - chai.assert.equal( + assert.equal( this.cleanupOption.preconditionFn(this.scope), 'disabled', 'Should be disabled if there are no blocks', @@ -145,7 +146,7 @@ suite('Context Menu Items', function () { test('Hidden when not movable', function () { sinon.stub(this.workspace, 'isMovable').returns(false); - chai.assert.equal( + assert.equal( this.cleanupOption.preconditionFn(this.scope), 'hidden', 'Should be hidden if the workspace is not movable', @@ -158,7 +159,7 @@ suite('Context Menu Items', function () { }); test('Has correct label', function () { - chai.assert.equal(this.cleanupOption.displayText(), 'Clean up Blocks'); + assert.equal(this.cleanupOption.displayText(), 'Clean up Blocks'); }); }); @@ -171,7 +172,7 @@ suite('Context Menu Items', function () { this.workspace.newBlock('text'); const block2 = this.workspace.newBlock('text'); block2.setCollapsed(true); - chai.assert.equal( + assert.equal( this.collapseOption.preconditionFn(this.scope), 'enabled', 'Should be enabled when any blocks are expanded', @@ -180,7 +181,7 @@ suite('Context Menu Items', function () { test('Disabled when all blocks collapsed', function () { this.workspace.newBlock('text').setCollapsed(true); - chai.assert.equal( + assert.equal( this.collapseOption.preconditionFn(this.scope), 'disabled', 'Should be disabled when no blocks are expanded', @@ -194,7 +195,7 @@ suite('Context Menu Items', function () { this.scope.workspace = workspaceWithOptions; try { - chai.assert.equal( + assert.equal( this.collapseOption.preconditionFn(this.scope), 'hidden', 'Should be hidden if collapse is disabled in options', @@ -216,18 +217,18 @@ suite('Context Menu Items', function () { this.collapseOption.callback(this.scope); this.clock.runAll(); - chai.assert.isTrue( + assert.isTrue( block1.isCollapsed(), 'Previously collapsed block should still be collapsed', ); - chai.assert.isTrue( + assert.isTrue( block2.isCollapsed(), 'Previously expanded block should now be collapsed', ); }); test('Has correct label', function () { - chai.assert.equal(this.collapseOption.displayText(), 'Collapse Blocks'); + assert.equal(this.collapseOption.displayText(), 'Collapse Blocks'); }); }); @@ -241,7 +242,7 @@ suite('Context Menu Items', function () { const block2 = this.workspace.newBlock('text'); block2.setCollapsed(true); - chai.assert.equal( + assert.equal( this.expandOption.preconditionFn(this.scope), 'enabled', 'Should be enabled when any blocks are collapsed', @@ -250,7 +251,7 @@ suite('Context Menu Items', function () { test('Disabled when no collapsed blocks', function () { this.workspace.newBlock('text'); - chai.assert.equal( + assert.equal( this.expandOption.preconditionFn(this.scope), 'disabled', 'Should be disabled when no blocks are collapsed', @@ -264,7 +265,7 @@ suite('Context Menu Items', function () { this.scope.workspace = workspaceWithOptions; try { - chai.assert.equal( + assert.equal( this.expandOption.preconditionFn(this.scope), 'hidden', 'Should be hidden if collapse is disabled in options', @@ -286,18 +287,18 @@ suite('Context Menu Items', function () { this.expandOption.callback(this.scope); this.clock.runAll(); - chai.assert.isFalse( + assert.isFalse( block1.isCollapsed(), 'Previously expanded block should still be expanded', ); - chai.assert.isFalse( + assert.isFalse( block2.isCollapsed(), 'Previously collapsed block should now be expanded', ); }); test('Has correct label', function () { - chai.assert.equal(this.expandOption.displayText(), 'Expand Blocks'); + assert.equal(this.expandOption.displayText(), 'Expand Blocks'); }); }); @@ -308,17 +309,11 @@ suite('Context Menu Items', function () { test('Enabled when blocks to delete', function () { this.workspace.newBlock('text'); - chai.assert.equal( - this.deleteOption.preconditionFn(this.scope), - 'enabled', - ); + assert.equal(this.deleteOption.preconditionFn(this.scope), 'enabled'); }); test('Disabled when no blocks to delete', function () { - chai.assert.equal( - this.deleteOption.preconditionFn(this.scope), - 'disabled', - ); + assert.equal(this.deleteOption.preconditionFn(this.scope), 'disabled'); }); test('Deletes all blocks after confirming', function () { @@ -332,7 +327,7 @@ suite('Context Menu Items', function () { this.deleteOption.callback(this.scope); this.clock.runAll(); sinon.assert.calledOnce(confirmStub); - chai.assert.equal(this.workspace.getTopBlocks(false).length, 0); + assert.equal(this.workspace.getTopBlocks(false).length, 0); }); test('Does not delete blocks if not confirmed', function () { @@ -346,7 +341,7 @@ suite('Context Menu Items', function () { this.deleteOption.callback(this.scope); this.clock.runAll(); sinon.assert.calledOnce(confirmStub); - chai.assert.equal(this.workspace.getTopBlocks(false).length, 2); + assert.equal(this.workspace.getTopBlocks(false).length, 2); }); test('No dialog for single block', function () { @@ -359,14 +354,14 @@ suite('Context Menu Items', function () { this.clock.runAll(); sinon.assert.notCalled(confirmStub); - chai.assert.equal(this.workspace.getTopBlocks(false).length, 0); + assert.equal(this.workspace.getTopBlocks(false).length, 0); }); test('Has correct label for multiple blocks', function () { this.workspace.newBlock('text'); this.workspace.newBlock('text'); - chai.assert.equal( + assert.equal( this.deleteOption.displayText(this.scope), 'Delete 2 Blocks', ); @@ -374,10 +369,7 @@ suite('Context Menu Items', function () { test('Has correct label for single block', function () { this.workspace.newBlock('text'); - chai.assert.equal( - this.deleteOption.displayText(this.scope), - 'Delete Block', - ); + assert.equal(this.deleteOption.displayText(this.scope), 'Delete Block'); }); }); }); @@ -395,7 +387,7 @@ suite('Context Menu Items', function () { test('Enabled when block is duplicatable', function () { // Block is duplicatable by default - chai.assert.equal( + assert.equal( this.duplicateOption.preconditionFn(this.scope), 'enabled', ); @@ -403,7 +395,7 @@ suite('Context Menu Items', function () { test('Disabled when block is not dupicatable', function () { sinon.stub(this.block, 'isDuplicatable').returns(false); - chai.assert.equal( + assert.equal( this.duplicateOption.preconditionFn(this.scope), 'disabled', ); @@ -411,15 +403,12 @@ suite('Context Menu Items', function () { test('Hidden when in flyout', function () { this.block.isInFlyout = true; - chai.assert.equal( - this.duplicateOption.preconditionFn(this.scope), - 'hidden', - ); + assert.equal(this.duplicateOption.preconditionFn(this.scope), 'hidden'); }); test('the block is duplicated', function () { this.duplicateOption.callback(this.scope); - chai.assert.equal( + assert.equal( this.workspace.getTopBlocks(false).length, 2, 'Expected a second block', @@ -427,7 +416,7 @@ suite('Context Menu Items', function () { }); test('Has correct label', function () { - chai.assert.equal(this.duplicateOption.displayText(), 'Duplicate'); + assert.equal(this.duplicateOption.displayText(), 'Duplicate'); }); }); @@ -437,10 +426,7 @@ suite('Context Menu Items', function () { }); test('Enabled for normal block', function () { - chai.assert.equal( - this.commentOption.preconditionFn(this.scope), - 'enabled', - ); + assert.equal(this.commentOption.preconditionFn(this.scope), 'enabled'); }); test('Hidden for collapsed block', function () { @@ -449,20 +435,17 @@ suite('Context Menu Items', function () { this.block.render(); this.block.setCollapsed(true); - chai.assert.equal( - this.commentOption.preconditionFn(this.scope), - 'hidden', - ); + assert.equal(this.commentOption.preconditionFn(this.scope), 'hidden'); }); test('Creates comment if one did not exist', function () { - chai.assert.isUndefined( + assert.isUndefined( this.block.getIcon(Blockly.icons.CommentIcon.TYPE), 'New block should not have a comment', ); this.commentOption.callback(this.scope); - chai.assert.exists(this.block.getIcon(Blockly.icons.CommentIcon.TYPE)); - chai.assert.isEmpty( + assert.exists(this.block.getIcon(Blockly.icons.CommentIcon.TYPE)); + assert.isEmpty( this.block.getCommentText(), 'Block should have empty comment text', ); @@ -471,22 +454,19 @@ suite('Context Menu Items', function () { test('Removes comment if block had one', function () { this.block.setCommentText('Test comment'); this.commentOption.callback(this.scope); - chai.assert.isNull( + assert.isNull( this.block.getCommentText(), 'Block should not have comment after removal', ); }); test('Has correct label for add comment', function () { - chai.assert.equal( - this.commentOption.displayText(this.scope), - 'Add Comment', - ); + assert.equal(this.commentOption.displayText(this.scope), 'Add Comment'); }); test('Has correct label for remove comment', function () { this.block.setCommentText('Test comment'); - chai.assert.equal( + assert.equal( this.commentOption.displayText(this.scope), 'Remove Comment', ); @@ -501,10 +481,7 @@ suite('Context Menu Items', function () { test('Enabled when inputs to inline', function () { this.block.appendValueInput('test1'); this.block.appendValueInput('test2'); - chai.assert.equal( - this.inlineOption.preconditionFn(this.scope), - 'enabled', - ); + assert.equal(this.inlineOption.preconditionFn(this.scope), 'enabled'); }); }); }); diff --git a/tests/mocha/contextmenu_test.js b/tests/mocha/contextmenu_test.js index 7af9c7918..b730b250d 100644 --- a/tests/mocha/contextmenu_test.js +++ b/tests/mocha/contextmenu_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -42,9 +43,9 @@ suite('Context Menu', function () { const callback = callbackFactory(this.forLoopBlock, xmlBlock); const getVarBlock = callback(); - chai.assert.equal(getVarBlock.type, 'variables_get'); - chai.assert.equal(getVarBlock.workspace, this.forLoopBlock.workspace); - chai.assert.equal( + assert.equal(getVarBlock.type, 'variables_get'); + assert.equal(getVarBlock.workspace, this.forLoopBlock.workspace); + assert.equal( getVarBlock.getField('VAR').getVariable().getId(), this.forLoopBlock.getField('VAR').getVariable().getId(), ); @@ -59,9 +60,9 @@ suite('Context Menu', function () { const callback = callbackFactory(this.forLoopBlock, jsonState); const getVarBlock = callback(); - chai.assert.equal(getVarBlock.type, 'variables_get'); - chai.assert.equal(getVarBlock.workspace, this.forLoopBlock.workspace); - chai.assert.equal( + assert.equal(getVarBlock.type, 'variables_get'); + assert.equal(getVarBlock.workspace, this.forLoopBlock.workspace); + assert.equal( getVarBlock.getField('VAR').getVariable().getId(), this.forLoopBlock.getField('VAR').getVariable().getId(), ); diff --git a/tests/mocha/cursor_test.js b/tests/mocha/cursor_test.js index c7b3a76af..fcb763304 100644 --- a/tests/mocha/cursor_test.js +++ b/tests/mocha/cursor_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -90,7 +91,7 @@ suite('Cursor', function () { this.cursor.setCurNode(prevNode); this.cursor.next(); const curNode = this.cursor.getCurNode(); - chai.assert.equal(curNode.getLocation(), this.blocks.B.previousConnection); + assert.equal(curNode.getLocation(), this.blocks.B.previousConnection); }); test('Next - From last block in a stack go to next connection', function () { const prevNode = ASTNode.createConnectionNode( @@ -99,7 +100,7 @@ suite('Cursor', function () { this.cursor.setCurNode(prevNode); this.cursor.next(); const curNode = this.cursor.getCurNode(); - chai.assert.equal(curNode.getLocation(), this.blocks.B.nextConnection); + assert.equal(curNode.getLocation(), this.blocks.B.nextConnection); }); test('In - From output connection', function () { @@ -110,10 +111,7 @@ suite('Cursor', function () { this.cursor.setCurNode(outputNode); this.cursor.in(); const curNode = this.cursor.getCurNode(); - chai.assert.equal( - curNode.getLocation(), - fieldBlock.inputList[0].fieldRow[0], - ); + assert.equal(curNode.getLocation(), fieldBlock.inputList[0].fieldRow[0]); }); test('Prev - From previous connection skip over next connection', function () { @@ -122,7 +120,7 @@ suite('Cursor', function () { this.cursor.setCurNode(prevConnectionNode); this.cursor.prev(); const curNode = this.cursor.getCurNode(); - chai.assert.equal(curNode.getLocation(), this.blocks.A.previousConnection); + assert.equal(curNode.getLocation(), this.blocks.A.previousConnection); }); test('Out - From field skip over block node', function () { @@ -131,6 +129,6 @@ suite('Cursor', function () { this.cursor.setCurNode(fieldNode); this.cursor.out(); const curNode = this.cursor.getCurNode(); - chai.assert.equal(curNode.getLocation(), this.blocks.E.outputConnection); + assert.equal(curNode.getLocation(), this.blocks.E.outputConnection); }); }); diff --git a/tests/mocha/dropdowndiv_test.js b/tests/mocha/dropdowndiv_test.js index 22066dda4..32109bfca 100644 --- a/tests/mocha/dropdowndiv_test.js +++ b/tests/mocha/dropdowndiv_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -51,10 +52,10 @@ suite('DropDownDiv', function () { -10, ); // "Above" in value actually means below in render. - chai.assert.isAtLeast(metrics.initialY, 0); - chai.assert.isAbove(metrics.finalY, 0); - chai.assert.isTrue(metrics.arrowVisible); - chai.assert.isTrue(metrics.arrowAtTop); + assert.isAtLeast(metrics.initialY, 0); + assert.isAbove(metrics.finalY, 0); + assert.isTrue(metrics.arrowVisible); + assert.isTrue(metrics.arrowAtTop); }); test('Above, in Bounds', function () { const metrics = Blockly.DropDownDiv.TEST_ONLY.getPositionMetrics( @@ -64,10 +65,10 @@ suite('DropDownDiv', function () { 90, ); // "Below" in value actually means above in render. - chai.assert.isAtMost(metrics.initialY, 100); - chai.assert.isBelow(metrics.finalY, 100); - chai.assert.isTrue(metrics.arrowVisible); - chai.assert.isFalse(metrics.arrowAtTop); + assert.isAtMost(metrics.initialY, 100); + assert.isBelow(metrics.finalY, 100); + assert.isTrue(metrics.arrowVisible); + assert.isFalse(metrics.arrowAtTop); }); test('Below, out of Bounds', function () { const metrics = Blockly.DropDownDiv.TEST_ONLY.getPositionMetrics( @@ -77,10 +78,10 @@ suite('DropDownDiv', function () { 50, ); // "Above" in value actually means below in render. - chai.assert.isAtLeast(metrics.initialY, 60); - chai.assert.isAbove(metrics.finalY, 60); - chai.assert.isTrue(metrics.arrowVisible); - chai.assert.isTrue(metrics.arrowAtTop); + assert.isAtLeast(metrics.initialY, 60); + assert.isAbove(metrics.finalY, 60); + assert.isTrue(metrics.arrowVisible); + assert.isTrue(metrics.arrowAtTop); }); test('Above, in Bounds', function () { const metrics = Blockly.DropDownDiv.TEST_ONLY.getPositionMetrics( @@ -90,10 +91,10 @@ suite('DropDownDiv', function () { 90, ); // "Below" in value actually means above in render. - chai.assert.isAtMost(metrics.initialY, 100); - chai.assert.isBelow(metrics.finalY, 100); - chai.assert.isTrue(metrics.arrowVisible); - chai.assert.isFalse(metrics.arrowAtTop); + assert.isAtMost(metrics.initialY, 100); + assert.isBelow(metrics.finalY, 100); + assert.isTrue(metrics.arrowVisible); + assert.isFalse(metrics.arrowAtTop); }); test('No Solution, Render At Top', function () { this.clientHeightStub.get(function () { @@ -106,10 +107,10 @@ suite('DropDownDiv', function () { 50, ); // "Above" in value actually means below in render. - chai.assert.equal(metrics.initialY, 0); - chai.assert.equal(metrics.finalY, 0); - chai.assert.isFalse(metrics.arrowVisible); - chai.assert.isNotOk(metrics.arrowAtTop); + assert.equal(metrics.initialY, 0); + assert.equal(metrics.finalY, 0); + assert.isFalse(metrics.arrowVisible); + assert.isNotOk(metrics.arrowAtTop); }); }); }); diff --git a/tests/mocha/event_block_change_test.js b/tests/mocha/event_block_change_test.js index 4f4728cc3..a4de1eddb 100644 --- a/tests/mocha/event_block_change_test.js +++ b/tests/mocha/event_block_change_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -45,7 +46,7 @@ suite('Block Change Event', function () { '', ); blockChange.run(false); - chai.assert.isFalse(block.hasInput); + assert.isFalse(block.hasInput); }); test('Redo', function () { @@ -58,7 +59,7 @@ suite('Block Change Event', function () { '', ); blockChange.run(true); - chai.assert.isTrue(block.hasInput); + assert.isTrue(block.hasInput); }); }); @@ -74,7 +75,7 @@ suite('Block Change Event', function () { '{"hasInput":true}', ); blockChange.run(false); - chai.assert.isFalse(block.hasInput); + assert.isFalse(block.hasInput); }); test('Redo', function () { @@ -87,7 +88,7 @@ suite('Block Change Event', function () { '{"hasInput":true}', ); blockChange.run(true); - chai.assert.isTrue(block.hasInput); + assert.isTrue(block.hasInput); }); }); }); @@ -119,7 +120,7 @@ suite('Block Change Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_block_create_test.js b/tests/mocha/event_block_create_test.js index f3aed672f..4ca6fb22a 100644 --- a/tests/mocha/event_block_create_test.js +++ b/tests/mocha/event_block_create_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import {assertEventFired} from './test_helpers/events.js'; import * as eventUtils from '../../build/src/core/events/utils.js'; import { @@ -53,7 +54,7 @@ suite('Block Create Event', function () { ); const calls = this.eventsFireStub.getCalls(); const event = calls[calls.length - 1].args[0]; - chai.assert.equal(event.xml.tagName, 'shadow'); + assert.equal(event.xml.tagName, 'shadow'); }); test('Does not create extra shadow blocks', function () { @@ -85,7 +86,7 @@ suite('Block Create Event', function () { event.run(true); const blocksAfter = this.workspace.getAllBlocks(); - chai.assert.deepEqual( + assert.deepEqual( blocksAfter, blocksBefore, 'No new blocks should be created from an event that only creates shadow blocks', @@ -102,7 +103,7 @@ suite('Block Create Event', function () { delete origEvent.xml; // xml fails deep equals for some reason. delete newEvent.xml; // xml fails deep equals for some reason. - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_block_delete_test.js b/tests/mocha/event_block_delete_test.js index 1aa70c4d1..d74b6aa06 100644 --- a/tests/mocha/event_block_delete_test.js +++ b/tests/mocha/event_block_delete_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import {defineRowBlock} from './test_helpers/block_definitions.js'; import { sharedTestSetup, @@ -34,7 +35,7 @@ suite('Block Delete Event', function () { testBlock.dispose(); this.clock.runAll(); - chai.assert.isFalse(spy.called); + assert.isFalse(spy.called); }); }); @@ -48,7 +49,7 @@ suite('Block Delete Event', function () { delete origEvent.oldXml; // xml fails deep equals for some reason. delete newEvent.oldXml; // xml fails deep equals for some reason. - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_block_drag_test.js b/tests/mocha/event_block_drag_test.js index 8a5399c8b..9b0f2031a 100644 --- a/tests/mocha/event_block_drag_test.js +++ b/tests/mocha/event_block_drag_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import {defineRowBlock} from './test_helpers/block_definitions.js'; import { sharedTestSetup, @@ -29,7 +30,7 @@ suite('Block Drag Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_block_field_intermediate_change_test.js b/tests/mocha/event_block_field_intermediate_change_test.js index 4d441e5d6..0ff4e1bbf 100644 --- a/tests/mocha/event_block_field_intermediate_change_test.js +++ b/tests/mocha/event_block_field_intermediate_change_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -32,7 +33,7 @@ suite('Field Intermediate Change Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); @@ -47,10 +48,7 @@ suite('Field Intermediate Change Event', function () { ); origEvent.run(true); - chai.assert.deepEqual( - block.getField(origEvent.name).getValue(), - 'new value', - ); + assert.deepEqual(block.getField(origEvent.name).getValue(), 'new value'); }); test("running backward changes the block's value to old value", function () { @@ -63,10 +61,7 @@ suite('Field Intermediate Change Event', function () { ); origEvent.run(false); - chai.assert.deepEqual( - block.getField(origEvent.name).getValue(), - 'old value', - ); + assert.deepEqual(block.getField(origEvent.name).getValue(), 'old value'); }); }); }); diff --git a/tests/mocha/event_block_move_test.js b/tests/mocha/event_block_move_test.js index 2b4102de6..b93457e14 100644 --- a/tests/mocha/event_block_move_test.js +++ b/tests/mocha/event_block_move_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import {defineRowBlock} from './test_helpers/block_definitions.js'; import { sharedTestSetup, @@ -32,7 +33,7 @@ suite('Block Move Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_bubble_open_test.js b/tests/mocha/event_bubble_open_test.js index 54e48aa9c..099a625f6 100644 --- a/tests/mocha/event_bubble_open_test.js +++ b/tests/mocha/event_bubble_open_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import {defineMutatorBlocks} from './test_helpers/block_definitions.js'; import { sharedTestSetup, @@ -35,7 +36,7 @@ suite('Bubble Open Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_click_test.js b/tests/mocha/event_click_test.js index ec998b62d..6e1876948 100644 --- a/tests/mocha/event_click_test.js +++ b/tests/mocha/event_click_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import {defineRowBlock} from './test_helpers/block_definitions.js'; import { sharedTestSetup, @@ -33,7 +34,7 @@ suite('Click Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_comment_change_test.js b/tests/mocha/event_comment_change_test.js index c2355f874..ed5f4d9f6 100644 --- a/tests/mocha/event_comment_change_test.js +++ b/tests/mocha/event_comment_change_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -32,7 +33,7 @@ suite('Comment Change Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_comment_collapse_test.js b/tests/mocha/event_comment_collapse_test.js index 86b36b075..e2d275307 100644 --- a/tests/mocha/event_comment_collapse_test.js +++ b/tests/mocha/event_comment_collapse_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -27,7 +28,7 @@ suite('Comment Collapse Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_comment_create_test.js b/tests/mocha/event_comment_create_test.js index 57c246f1f..df919541d 100644 --- a/tests/mocha/event_comment_create_test.js +++ b/tests/mocha/event_comment_create_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -31,7 +32,7 @@ suite('Comment Create Event', function () { delete origEvent.xml; // xml fails deep equals for some reason. delete newEvent.xml; // xml fails deep equals for some reason. - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_comment_delete_test.js b/tests/mocha/event_comment_delete_test.js index e0a8a98db..2e2bb45c4 100644 --- a/tests/mocha/event_comment_delete_test.js +++ b/tests/mocha/event_comment_delete_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -31,7 +32,7 @@ suite('Comment Delete Event', function () { delete origEvent.xml; // xml fails deep equals for some reason. delete newEvent.xml; // xml fails deep equals for some reason. - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_comment_move_test.js b/tests/mocha/event_comment_move_test.js index 420bdbb52..aae3fdfe6 100644 --- a/tests/mocha/event_comment_move_test.js +++ b/tests/mocha/event_comment_move_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -33,7 +34,7 @@ suite('Comment Move Event', function () { delete origEvent.comment_; // Ignore private properties. delete newEvent.comment_; // Ignore private properties. - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_marker_move_test.js b/tests/mocha/event_marker_move_test.js index 26238dc43..cd5609c33 100644 --- a/tests/mocha/event_marker_move_test.js +++ b/tests/mocha/event_marker_move_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import {defineRowBlock} from './test_helpers/block_definitions.js'; import { sharedTestSetup, @@ -37,7 +38,7 @@ suite('Marker Move Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_selected_test.js b/tests/mocha/event_selected_test.js index 3c69889f2..1ce8306db 100644 --- a/tests/mocha/event_selected_test.js +++ b/tests/mocha/event_selected_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import {defineRowBlock} from './test_helpers/block_definitions.js'; import { sharedTestSetup, @@ -34,7 +35,7 @@ suite('Selected Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_test.js b/tests/mocha/event_test.js index 75688c654..4709297d8 100644 --- a/tests/mocha/event_test.js +++ b/tests/mocha/event_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import * as Blockly from '../../build/src/core/blockly.js'; import {ASTNode} from '../../build/src/core/keyboard_nav/ast_node.js'; import { @@ -916,10 +917,7 @@ suite('Events', function () { const json = event.toJson(); const event2 = Blockly.Events.fromJson(json, this.workspace); - chai.assert.equal( - safeStringify(event2.toJson()), - safeStringify(json), - ); + assert.equal(safeStringify(event2.toJson()), safeStringify(json)); }); }); }); @@ -931,10 +929,7 @@ suite('Events', function () { const json = event.toJson(); const expectedJson = testCase.getExpectedJson(this); - chai.assert.equal( - safeStringify(json), - safeStringify(expectedJson), - ); + assert.equal(safeStringify(json), safeStringify(expectedJson)); }); } }); @@ -958,10 +953,10 @@ suite('Events', function () { */ function checkVariableValues(container, name, type, id) { const variable = container.getVariableById(id); - chai.assert.isDefined(variable); - chai.assert.equal(name, variable.name); - chai.assert.equal(type, variable.type); - chai.assert.equal(id, variable.getId()); + assert.isDefined(variable); + assert.equal(name, variable.name); + assert.equal(type, variable.type); + assert.equal(id, variable.getId()); } suite('Constructors', function () { @@ -1036,29 +1031,29 @@ suite('Events', function () { }; const event = eventUtils.fromJson(json, this.workspace); const x = this.workspace.getVariableById('id2'); - chai.assert.isNull(x); + assert.isNull(x); event.run(true); assertVariableValues(this.workspace, 'name2', 'type2', 'id2'); }); test('Var delete', function () { const event = new Blockly.Events.VarDelete(this.variable); - chai.assert.isNotNull(this.workspace.getVariableById('id1')); + assert.isNotNull(this.workspace.getVariableById('id1')); event.run(true); - chai.assert.isNull(this.workspace.getVariableById('id1')); + assert.isNull(this.workspace.getVariableById('id1')); }); test('Var rename', function () { const event = new Blockly.Events.VarRename(this.variable, 'name2'); event.run(true); - chai.assert.isNull(this.workspace.getVariable('name1')); + assert.isNull(this.workspace.getVariable('name1')); checkVariableValues(this.workspace, 'name2', 'type1', 'id1'); }); }); suite('Run Backward', function () { test('Var create', function () { const event = new Blockly.Events.VarCreate(this.variable); - chai.assert.isNotNull(this.workspace.getVariableById('id1')); + assert.isNotNull(this.workspace.getVariableById('id1')); event.run(false); }); @@ -1070,7 +1065,7 @@ suite('Events', function () { varName: 'name2', }; const event = eventUtils.fromJson(json, this.workspace); - chai.assert.isNull(this.workspace.getVariableById('id2')); + assert.isNull(this.workspace.getVariableById('id2')); event.run(false); assertVariableValues(this.workspace, 'name2', 'type2', 'id2'); }); @@ -1078,7 +1073,7 @@ suite('Events', function () { test('Var rename', function () { const event = new Blockly.Events.VarRename(this.variable, 'name2'); event.run(false); - chai.assert.isNull(this.workspace.getVariable('name2')); + assert.isNull(this.workspace.getVariable('name2')); checkVariableValues(this.workspace, 'name1', 'type1', 'id1'); }); }); @@ -1106,16 +1101,12 @@ suite('Events', function () { new Blockly.Events.Click(block), ]; const filteredEvents = eventUtils.filter(events, true); - chai.assert.equal(filteredEvents.length, 4); // no event should have been removed. + assert.equal(filteredEvents.length, 4); // no event should have been removed. // test that the order hasn't changed - chai.assert.isTrue( - filteredEvents[0] instanceof Blockly.Events.BlockCreate, - ); - chai.assert.isTrue(filteredEvents[1] instanceof Blockly.Events.BlockMove); - chai.assert.isTrue( - filteredEvents[2] instanceof Blockly.Events.BlockChange, - ); - chai.assert.isTrue(filteredEvents[3] instanceof Blockly.Events.Click); + assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BlockCreate); + assert.isTrue(filteredEvents[1] instanceof Blockly.Events.BlockMove); + assert.isTrue(filteredEvents[2] instanceof Blockly.Events.BlockChange); + assert.isTrue(filteredEvents[3] instanceof Blockly.Events.Click); }); test('Different blocks no removed', function () { @@ -1128,7 +1119,7 @@ suite('Events', function () { new Blockly.Events.BlockMove(block2), ]; const filteredEvents = eventUtils.filter(events, true); - chai.assert.equal(filteredEvents.length, 4); // no event should have been removed. + assert.equal(filteredEvents.length, 4); // no event should have been removed. }); test('Forward', function () { @@ -1138,14 +1129,12 @@ suite('Events', function () { addMoveEvent(events, block, 2, 2); addMoveEvent(events, block, 3, 3); const filteredEvents = eventUtils.filter(events, true); - chai.assert.equal(filteredEvents.length, 2); // duplicate moves should have been removed. + assert.equal(filteredEvents.length, 2); // duplicate moves should have been removed. // test that the order hasn't changed - chai.assert.isTrue( - filteredEvents[0] instanceof Blockly.Events.BlockCreate, - ); - chai.assert.isTrue(filteredEvents[1] instanceof Blockly.Events.BlockMove); - chai.assert.equal(filteredEvents[1].newCoordinate.x, 3); - chai.assert.equal(filteredEvents[1].newCoordinate.y, 3); + assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BlockCreate); + assert.isTrue(filteredEvents[1] instanceof Blockly.Events.BlockMove); + assert.equal(filteredEvents[1].newCoordinate.x, 3); + assert.equal(filteredEvents[1].newCoordinate.y, 3); }); test('Backward', function () { @@ -1155,14 +1144,12 @@ suite('Events', function () { addMoveEvent(events, block, 2, 2); addMoveEvent(events, block, 3, 3); const filteredEvents = eventUtils.filter(events, false); - chai.assert.equal(filteredEvents.length, 2); // duplicate event should have been removed. + assert.equal(filteredEvents.length, 2); // duplicate event should have been removed. // test that the order hasn't changed - chai.assert.isTrue( - filteredEvents[0] instanceof Blockly.Events.BlockCreate, - ); - chai.assert.isTrue(filteredEvents[1] instanceof Blockly.Events.BlockMove); - chai.assert.equal(filteredEvents[1].newCoordinate.x, 1); - chai.assert.equal(filteredEvents[1].newCoordinate.y, 1); + assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BlockCreate); + assert.isTrue(filteredEvents[1] instanceof Blockly.Events.BlockMove); + assert.equal(filteredEvents[1].newCoordinate.x, 1); + assert.equal(filteredEvents[1].newCoordinate.y, 1); }); test('Merge block move events', function () { @@ -1171,9 +1158,9 @@ suite('Events', function () { addMoveEvent(events, block, 0, 0); addMoveEvent(events, block, 1, 1); const filteredEvents = eventUtils.filter(events, true); - chai.assert.equal(filteredEvents.length, 1); // second move event merged into first - chai.assert.equal(filteredEvents[0].newCoordinate.x, 1); - chai.assert.equal(filteredEvents[0].newCoordinate.y, 1); + assert.equal(filteredEvents.length, 1); // second move event merged into first + assert.equal(filteredEvents[0].newCoordinate.x, 1); + assert.equal(filteredEvents[0].newCoordinate.y, 1); }); test('Merge block change events', function () { @@ -1189,9 +1176,9 @@ suite('Events', function () { ), ]; const filteredEvents = eventUtils.filter(events, true); - chai.assert.equal(filteredEvents.length, 1); // second change event merged into first - chai.assert.equal(filteredEvents[0].oldValue, 'item'); - chai.assert.equal(filteredEvents[0].newValue, 'item2'); + assert.equal(filteredEvents.length, 1); // second change event merged into first + assert.equal(filteredEvents[0].oldValue, 'item'); + assert.equal(filteredEvents[0].newValue, 'item2'); }); test('Merge viewport change events', function () { @@ -1200,11 +1187,11 @@ suite('Events', function () { new Blockly.Events.ViewportChange(5, 6, 7, this.workspace, 8), ]; const filteredEvents = eventUtils.filter(events, true); - chai.assert.equal(filteredEvents.length, 1); // second change event merged into first - chai.assert.equal(filteredEvents[0].viewTop, 5); - chai.assert.equal(filteredEvents[0].viewLeft, 6); - chai.assert.equal(filteredEvents[0].scale, 7); - chai.assert.equal(filteredEvents[0].oldScale, 8); + assert.equal(filteredEvents.length, 1); // second change event merged into first + assert.equal(filteredEvents[0].viewTop, 5); + assert.equal(filteredEvents[0].viewLeft, 6); + assert.equal(filteredEvents[0].scale, 7); + assert.equal(filteredEvents[0].oldScale, 8); }); test('Merge ui events', function () { @@ -1221,19 +1208,13 @@ suite('Events', function () { ]; const filteredEvents = eventUtils.filter(events, true); // click event merged into corresponding *Open event - chai.assert.equal(filteredEvents.length, 3); - chai.assert.isTrue( - filteredEvents[0] instanceof Blockly.Events.BubbleOpen, - ); - chai.assert.isTrue( - filteredEvents[1] instanceof Blockly.Events.BubbleOpen, - ); - chai.assert.isTrue( - filteredEvents[2] instanceof Blockly.Events.BubbleOpen, - ); - chai.assert.equal(filteredEvents[0].bubbleType, 'comment'); - chai.assert.equal(filteredEvents[1].bubbleType, 'mutator'); - chai.assert.equal(filteredEvents[2].bubbleType, 'warning'); + assert.equal(filteredEvents.length, 3); + assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BubbleOpen); + assert.isTrue(filteredEvents[1] instanceof Blockly.Events.BubbleOpen); + assert.isTrue(filteredEvents[2] instanceof Blockly.Events.BubbleOpen); + assert.equal(filteredEvents[0].bubbleType, 'comment'); + assert.equal(filteredEvents[1].bubbleType, 'mutator'); + assert.equal(filteredEvents[2].bubbleType, 'warning'); }); test('Colliding events not dropped', function () { @@ -1246,9 +1227,9 @@ suite('Events', function () { ]; const filteredEvents = eventUtils.filter(events, true); // click and stackclick should both exist - chai.assert.equal(filteredEvents.length, 2); - chai.assert.isTrue(filteredEvents[0] instanceof Blockly.Events.Click); - chai.assert.equal(filteredEvents[1].isStart, true); + assert.equal(filteredEvents.length, 2); + assert.isTrue(filteredEvents[0] instanceof Blockly.Events.Click); + assert.equal(filteredEvents[1].isStart, true); }); test('Merging null operations dropped', function () { @@ -1267,7 +1248,7 @@ suite('Events', function () { const filteredEvents = eventUtils.filter(events, true); // The two events should be merged, but because nothing has changed // they will be filtered out. - chai.assert.equal(filteredEvents.length, 0); + assert.equal(filteredEvents.length, 0); }); test('Move events different blocks not merged', function () { @@ -1287,14 +1268,12 @@ suite('Events', function () { const filteredEvents = eventUtils.filter(events, true); // Nothing should have merged. - chai.assert.equal(filteredEvents.length, 4); + assert.equal(filteredEvents.length, 4); // test that the order hasn't changed - chai.assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BlockMove); - chai.assert.isTrue(filteredEvents[1] instanceof Blockly.Events.BlockMove); - chai.assert.isTrue( - filteredEvents[2] instanceof Blockly.Events.BlockDelete, - ); - chai.assert.isTrue(filteredEvents[3] instanceof Blockly.Events.BlockMove); + assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BlockMove); + assert.isTrue(filteredEvents[1] instanceof Blockly.Events.BlockMove); + assert.isTrue(filteredEvents[2] instanceof Blockly.Events.BlockDelete); + assert.isTrue(filteredEvents[3] instanceof Blockly.Events.BlockMove); }); }); @@ -1344,7 +1323,7 @@ suite('Events', function () { ); // Expect the workspace to not have a variable with ID 'test_block_id'. - chai.assert.isNull(this.workspace.getVariableById(TEST_BLOCK_ID)); + assert.isNull(this.workspace.getVariableById(TEST_BLOCK_ID)); } finally { workspaceTeardown.call(this, workspaceSvg); } @@ -1374,11 +1353,7 @@ suite('Events', function () { // Expect both events to trigger change listener. sinon.assert.calledTwice(this.changeListenerSpy); // Both events should be on undo stack - chai.assert.equal( - this.workspace.undoStack_.length, - 2, - 'Undo stack length', - ); + assert.equal(this.workspace.undoStack_.length, 2, 'Undo stack length'); assertNthCallEventArgEquals( this.changeListenerSpy, @@ -1398,7 +1373,7 @@ suite('Events', function () { ); // Expect the workspace to have a variable with ID 'test_var_id'. - chai.assert.isNotNull(this.workspace.getVariableById(TEST_VAR_ID)); + assert.isNotNull(this.workspace.getVariableById(TEST_VAR_ID)); }); test('New block new var xml', function () { @@ -1432,11 +1407,7 @@ suite('Events', function () { // The first varCreate and move event should have been ignored. sinon.assert.callCount(this.changeListenerSpy, 3); // Expect two events on undo stack: varCreate and block create. - chai.assert.equal( - this.workspace.undoStack_.length, - 2, - 'Undo stack length', - ); + assert.equal(this.workspace.undoStack_.length, 2, 'Undo stack length'); assertNthCallEventArgEquals( this.changeListenerSpy, @@ -1466,7 +1437,7 @@ suite('Events', function () { ); // Expect the workspace to have a variable with ID 'test_var_id'. - chai.assert.isNotNull(this.workspace.getVariableById(TEST_VAR_ID)); + assert.isNotNull(this.workspace.getVariableById(TEST_VAR_ID)); }); }); suite('Disable orphans', function () { @@ -1487,7 +1458,7 @@ suite('Events', function () { // Fire all events this.clock.runAll(); - chai.assert.isFalse( + assert.isFalse( block.isEnabled(), 'Expected orphan block to be disabled after creation', ); @@ -1503,7 +1474,7 @@ suite('Events', function () { // Fire all events this.clock.runAll(); - chai.assert.isTrue( + assert.isTrue( functionBlock.isEnabled(), 'Expected top-level procedure block to be enabled', ); @@ -1527,7 +1498,7 @@ suite('Events', function () { // Fire all events this.clock.runAll(); - chai.assert.isFalse( + assert.isFalse( block.isEnabled(), 'Expected disconnected block to be disabled', ); @@ -1548,7 +1519,7 @@ suite('Events', function () { // Fire all events this.clock.runAll(); - chai.assert.isTrue( + assert.isTrue( block.isEnabled(), 'Expected block to be enabled after connecting to parent', ); @@ -1575,7 +1546,7 @@ suite('Events', function () { const disabledEvents = this.workspace.getUndoStack().filter(function (e) { return e.element === 'disabled'; }); - chai.assert.isEmpty( + assert.isEmpty( disabledEvents, 'Undo stack should not contain any disabled events', ); diff --git a/tests/mocha/event_theme_change_test.js b/tests/mocha/event_theme_change_test.js index 155e373a3..f20f745b6 100644 --- a/tests/mocha/event_theme_change_test.js +++ b/tests/mocha/event_theme_change_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -29,7 +30,7 @@ suite('Theme Change Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_toolbox_item_select_test.js b/tests/mocha/event_toolbox_item_select_test.js index 82f8e4863..bf6a9a462 100644 --- a/tests/mocha/event_toolbox_item_select_test.js +++ b/tests/mocha/event_toolbox_item_select_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -57,7 +58,7 @@ suite('Toolbox Item Select Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_trashcan_open_test.js b/tests/mocha/event_trashcan_open_test.js index 84c2abd9c..2c809f2df 100644 --- a/tests/mocha/event_trashcan_open_test.js +++ b/tests/mocha/event_trashcan_open_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -29,7 +30,7 @@ suite('Trashcan Open Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_var_create_test.js b/tests/mocha/event_var_create_test.js index 003cd11b5..e374c4965 100644 --- a/tests/mocha/event_var_create_test.js +++ b/tests/mocha/event_var_create_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -32,7 +33,7 @@ suite('Var Create Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); test('typed variable events round-trip through JSON', function () { @@ -47,7 +48,7 @@ suite('Var Create Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_var_delete_test.js b/tests/mocha/event_var_delete_test.js index 7bad8eb7b..b06943d9a 100644 --- a/tests/mocha/event_var_delete_test.js +++ b/tests/mocha/event_var_delete_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -32,7 +33,7 @@ suite('Var Delete Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); test('typed variable events round-trip through JSON', function () { @@ -47,7 +48,7 @@ suite('Var Delete Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_var_rename_test.js b/tests/mocha/event_var_rename_test.js index 0c8fb80cd..7fbd185ab 100644 --- a/tests/mocha/event_var_rename_test.js +++ b/tests/mocha/event_var_rename_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -32,7 +33,7 @@ suite('Var Rename Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/event_viewport_test.js b/tests/mocha/event_viewport_test.js index 7913e7bf5..edacc0da6 100644 --- a/tests/mocha/event_viewport_test.js +++ b/tests/mocha/event_viewport_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -32,7 +33,7 @@ suite('Viewport Change Event', function () { const json = origEvent.toJson(); const newEvent = new Blockly.Events.fromJson(json, this.workspace); - chai.assert.deepEqual(newEvent, origEvent); + assert.deepEqual(newEvent, origEvent); }); }); }); diff --git a/tests/mocha/extensions_test.js b/tests/mocha/extensions_test.js index 8eb37e75d..66772cbea 100644 --- a/tests/mocha/extensions_test.js +++ b/tests/mocha/extensions_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -27,7 +28,7 @@ suite('Extensions', function () { this.extensionsCleanup_.push('extensions_test_before'); this.extensionsCleanup_.push('extensions_test_after'); - chai.assert.isUndefined( + assert.isUndefined( Blockly.Extensions.TEST_ONLY.allExtensions['extensions_test_before'], ); const beforeCallback = sinon.spy(); @@ -42,18 +43,18 @@ suite('Extensions', function () { }, ]); - chai.assert.isUndefined( + assert.isUndefined( Blockly.Extensions.TEST_ONLY.allExtensions['extensions_test_after'], ); const afterCallback = sinon.spy(); // Extension defined after the block type (but before instantiation). Blockly.Extensions.register('extensions_test_after', afterCallback); - chai.assert.typeOf( + assert.typeOf( Blockly.Extensions.TEST_ONLY.allExtensions['extensions_test_before'], 'function', ); - chai.assert.typeOf( + assert.typeOf( Blockly.Extensions.TEST_ONLY.allExtensions['extensions_test_after'], 'function', ); @@ -98,27 +99,27 @@ suite('Extensions', function () { ); // Tooltip is dynamic after extension initialization. - chai.assert.typeOf(block.tooltip, 'function'); - chai.assert.equal(block.tooltip(), defaultTooltip); + assert.typeOf(block.tooltip, 'function'); + assert.equal(block.tooltip(), defaultTooltip); // Tooltip is normal before connected to parent. const parent = new Blockly.Block(this.workspace, 'test_parent'); - chai.assert.equal(parent.tooltip, parentTooltip); - chai.assert.notExists(parent.inputsInline); + assert.equal(parent.tooltip, parentTooltip); + assert.notExists(parent.inputsInline); // Tooltip is normal when parent is not inline. parent.getInput('INPUT').connection.connect(block.outputConnection); - chai.assert.equal(block.getParent(), parent); - chai.assert.equal(block.tooltip(), defaultTooltip); + assert.equal(block.getParent(), parent); + assert.equal(block.tooltip(), defaultTooltip); // Tooltip is parent's when parent is inline. parent.setInputsInline(true); - chai.assert.equal(block.tooltip(), parentTooltip); + assert.equal(block.tooltip(), parentTooltip); // Tooltip revert when disconnected. parent.getInput('INPUT').connection.disconnect(); - chai.assert.notExists(block.getParent()); - chai.assert.equal(block.tooltip(), defaultTooltip); + assert.notExists(block.getParent()); + assert.equal(block.tooltip(), defaultTooltip); }); suite('Mixin', function () { @@ -132,13 +133,13 @@ suite('Extensions', function () { }, }; - chai.assert.isUndefined( + assert.isUndefined( Blockly.Extensions.TEST_ONLY.allExtensions['mixin_test'], ); // Extension defined before the block type is defined. Blockly.Extensions.registerMixin('mixin_test', testMixin); - chai.assert.typeOf( + assert.typeOf( Blockly.Extensions.TEST_ONLY.allExtensions['mixin_test'], 'function', ); @@ -153,8 +154,8 @@ suite('Extensions', function () { const block = new Blockly.Block(this.workspace, 'test_block_mixin'); - chai.assert.equal(testMixin.field, block.field); - chai.assert.equal(testMixin.method, block.method); + assert.equal(testMixin.field, block.field); + assert.equal(testMixin.method, block.method); }); suite('Mutator', function () { @@ -190,10 +191,10 @@ suite('Extensions', function () { const block = new Blockly.Block(this.workspace, 'mutator_test_block'); // Make sure all of the functions were installed correctly. - chai.assert.equal(block.domToMutation(), 'domToMutationFn'); - chai.assert.equal(block.mutationToDom(), 'mutationToDomFn'); - chai.assert.equal(block.compose(), 'composeFn'); - chai.assert.equal(block.decompose(), 'decomposeFn'); + assert.equal(block.domToMutation(), 'domToMutationFn'); + assert.equal(block.mutationToDom(), 'mutationToDomFn'); + assert.equal(block.compose(), 'composeFn'); + assert.equal(block.decompose(), 'decomposeFn'); }); test('With helper function', function () { @@ -210,7 +211,7 @@ suite('Extensions', function () { // Events code calls mutationToDom and expects it to give back a // meaningful value. Blockly.Events.disable(); - chai.assert.isUndefined( + assert.isUndefined( Blockly.Extensions.TEST_ONLY.allExtensions['extensions_test'], ); const helperFunctionSpy = sinon.spy(); @@ -246,7 +247,7 @@ suite('Extensions', function () { // Events code calls mutationToDom and expects it to give back a // meaningful value. Blockly.Events.disable(); - chai.assert.isUndefined( + assert.isUndefined( Blockly.Extensions.TEST_ONLY.allExtensions['mutator_test'], ); Blockly.Extensions.registerMutator('mutator_test', { @@ -261,10 +262,10 @@ suite('Extensions', function () { const block = new Blockly.Block(this.workspace, 'mutator_test_block'); // Make sure all of the functions were installed correctly. - chai.assert.equal(block.domToMutation(), 'domToMutationFn'); - chai.assert.equal(block.mutationToDom(), 'mutationToDomFn'); - chai.assert.isUndefined(block['compose']); - chai.assert.isUndefined(block['decompose']); + assert.equal(block.domToMutation(), 'domToMutationFn'); + assert.equal(block.mutationToDom(), 'mutationToDomFn'); + assert.isUndefined(block['compose']); + assert.isUndefined(block['decompose']); }); }); }); @@ -279,11 +280,11 @@ suite('Extensions', function () { }, ]); - chai.assert.isUndefined( + assert.isUndefined( Blockly.Extensions.TEST_ONLY.allExtensions['missing_extension'], ); const workspace = this.workspace; - chai.assert.throws(function () { + assert.throws(function () { const _ = new Blockly.Block(workspace, 'missing_extension_block'); }); }); @@ -295,7 +296,7 @@ suite('Extensions', function () { inputList: 'bad inputList', // Defined in constructor }; - chai.assert.isUndefined( + assert.isUndefined( Blockly.Extensions.TEST_ONLY.allExtensions['mixin_bad_inputList'], ); // Extension defined before the block type is defined. @@ -303,7 +304,7 @@ suite('Extensions', function () { 'mixin_bad_inputList', TEST_MIXIN_BAD_INPUTLIST, ); - chai.assert.typeOf( + assert.typeOf( Blockly.Extensions.TEST_ONLY.allExtensions['mixin_bad_inputList'], 'function', ); @@ -317,7 +318,7 @@ suite('Extensions', function () { ]); const workspace = this.workspace; - chai.assert.throws(function () { + assert.throws(function () { const _ = new Blockly.Block(workspace, 'test_block_bad_inputList'); }, /inputList/); }); @@ -329,7 +330,7 @@ suite('Extensions', function () { colour_: 'bad colour_', // Defined on prototype }; - chai.assert.isUndefined( + assert.isUndefined( Blockly.Extensions.TEST_ONLY.allExtensions['mixin_bad_colour_'], ); // Extension defined before the block type is defined. @@ -337,7 +338,7 @@ suite('Extensions', function () { 'mixin_bad_colour_', TEST_MIXIN_BAD_COLOUR, ); - chai.assert.typeOf( + assert.typeOf( Blockly.Extensions.TEST_ONLY.allExtensions['mixin_bad_colour_'], 'function', ); @@ -351,7 +352,7 @@ suite('Extensions', function () { ]); const workspace = this.workspace; - chai.assert.throws(function () { + assert.throws(function () { const _ = new Blockly.Block(workspace, 'test_block_bad_colour'); }, /colour_/); }); @@ -370,7 +371,7 @@ suite('Extensions', function () { // Events code calls mutationToDom and expects it to give back a // meaningful value. Blockly.Events.disable(); - chai.assert.isUndefined( + assert.isUndefined( Blockly.Extensions.TEST_ONLY.allExtensions['mutator_test'], ); Blockly.Extensions.registerMutator('mutator_test', { @@ -383,11 +384,11 @@ suite('Extensions', function () { }); const workspace = this.workspace; - chai.assert.throws(function () { + assert.throws(function () { const _ = new Blockly.Block(workspace, 'mutator_test_block'); }); // Should have failed on apply, not on register. - chai.assert.isNotNull( + assert.isNotNull( Blockly.Extensions.TEST_ONLY.allExtensions['mutator_test'], ); }); @@ -406,7 +407,7 @@ suite('Extensions', function () { // Events code calls mutationToDom and expects it to give back a // meaningful value. Blockly.Events.disable(); - chai.assert.isUndefined( + assert.isUndefined( Blockly.Extensions.TEST_ONLY.allExtensions['mutator_test'], ); Blockly.Extensions.registerMixin('mutator_test', { @@ -419,11 +420,11 @@ suite('Extensions', function () { }); const workspace = this.workspace; - chai.assert.throws(function () { + assert.throws(function () { const _ = new Blockly.Block(workspace, 'mutator_test_block'); }); // Should have failed on apply, not on register. - chai.assert.isNotNull( + assert.isNotNull( Blockly.Extensions.TEST_ONLY.allExtensions['mutator_test'], ); }); @@ -442,7 +443,7 @@ suite('Extensions', function () { // Events code calls mutationToDom and expects it to give back a // meaningful value. Blockly.Events.disable(); - chai.assert.isUndefined( + assert.isUndefined( Blockly.Extensions.TEST_ONLY.allExtensions['extensions_test'], ); Blockly.Extensions.register('extensions_test', function () { @@ -450,11 +451,11 @@ suite('Extensions', function () { }); const workspace = this.workspace; - chai.assert.throws(function () { + assert.throws(function () { const _ = new Blockly.Block(workspace, 'mutator_test_block'); }); // Should have failed on apply, not on register. - chai.assert.isNotNull( + assert.isNotNull( Blockly.Extensions.TEST_ONLY.allExtensions['extensions_test'], ); }); @@ -462,30 +463,30 @@ suite('Extensions', function () { suite('register', function () { test('Just a string', function () { this.extensionsCleanup_.push('extension_just_a_string'); - chai.assert.isUndefined( + assert.isUndefined( Blockly.Extensions.TEST_ONLY.allExtensions['extension_just_a_string'], ); - chai.assert.throws(function () { + assert.throws(function () { Blockly.Extensions.register('extension_just_a_string', null); }); }); test('Null', function () { this.extensionsCleanup_.push('extension_is_null'); - chai.assert.isUndefined( + assert.isUndefined( Blockly.Extensions.TEST_ONLY.allExtensions['extension_is_null'], ); - chai.assert.throws(function () { + assert.throws(function () { Blockly.Extensions.register('extension_is_null', null); }); }); test('Undefined', function () { this.extensionsCleanup_.push('extension_is_undefined'); - chai.assert.isUndefined( + assert.isUndefined( Blockly.Extensions.TEST_ONLY.allExtensions['extension_is_undefined'], ); - chai.assert.throws(function () { + assert.throws(function () { Blockly.Extensions.register('extension_is_undefined', null); }); }); @@ -494,7 +495,7 @@ suite('Extensions', function () { suite('registerMutator', function () { test('No domToMutation', function () { this.extensionsCleanup_.push('mutator_test'); - chai.assert.throws(function () { + assert.throws(function () { Blockly.Extensions.registerMutator('mutator_test', { mutationToDom: function () { return 'mutationToDomFn'; @@ -511,7 +512,7 @@ suite('Extensions', function () { test('No mutationToDom', function () { this.extensionsCleanup_.push('mutator_test'); - chai.assert.throws(function () { + assert.throws(function () { Blockly.Extensions.registerMutator('mutator_test', { domToMutation: function () { return 'domToMutationFn'; @@ -528,7 +529,7 @@ suite('Extensions', function () { test('No saveExtraState', function () { this.extensionsCleanup_.push('mutator_test'); - chai.assert.throws(function () { + assert.throws(function () { Blockly.Extensions.registerMutator('mutator_test', { loadExtraState: function () { return 'loadExtraState'; @@ -545,7 +546,7 @@ suite('Extensions', function () { test('No loadExtraState', function () { this.extensionsCleanup_.push('mutator_test'); - chai.assert.throws(function () { + assert.throws(function () { Blockly.Extensions.registerMutator('mutator_test', { saveExtraState: function () { return 'saveExtraState'; @@ -562,7 +563,7 @@ suite('Extensions', function () { test('No serialization hooks', function () { this.extensionsCleanup_.push('mutator_test'); - chai.assert.throws(function () { + assert.throws(function () { Blockly.Extensions.registerMutator('mutator_test', { compose: function () { return 'composeFn'; @@ -576,7 +577,7 @@ suite('Extensions', function () { test('Has decompose but no compose', function () { this.extensionsCleanup_.push('mutator_test'); - chai.assert.throws(function () { + assert.throws(function () { Blockly.Extensions.registerMutator('mutator_test', { domToMutation: function () { return 'domToMutationFn'; @@ -593,7 +594,7 @@ suite('Extensions', function () { test('Has compose but no decompose', function () { this.extensionsCleanup_.push('mutator_test'); - chai.assert.throws(function () { + assert.throws(function () { Blockly.Extensions.registerMutator('mutator_test', { domToMutation: function () { return 'domToMutationFn'; diff --git a/tests/mocha/field_checkbox_test.js b/tests/mocha/field_checkbox_test.js index 4f9503d9c..1db3c9a4b 100644 --- a/tests/mocha/field_checkbox_test.js +++ b/tests/mocha/field_checkbox_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import * as Blockly from '../../build/src/core/blockly.js'; import { assertFieldValue, @@ -223,7 +224,7 @@ suite('Checkbox Fields', function () { }; field.initView(); field.render_(); - chai.assert(field.textContent_.nodeValue, char); + assert(field.textContent_.nodeValue, char); } test('Constant', function () { const checkChar = Blockly.FieldCheckbox.CHECK_CHAR; @@ -251,7 +252,7 @@ suite('Checkbox Fields', function () { assertCharacter(field, Blockly.FieldCheckbox.CHECK_CHAR); field.setCheckCharacter('\u2661'); // Don't call assertCharacter b/c we don't want to re-initialize. - chai.assert.equal(field.textContent_.nodeValue, '\u2661'); + assert.equal(field.textContent_.nodeValue, '\u2661'); }); test('setCheckCharacter Before Init', function () { const field = new Blockly.FieldCheckbox(); @@ -264,10 +265,7 @@ suite('Checkbox Fields', function () { }); assertCharacter(field, '\u2661'); field.setCheckCharacter(null); - chai.assert( - field.textContent_.nodeValue, - Blockly.FieldCheckbox.CHECK_CHAR, - ); + assert(field.textContent_.nodeValue, Blockly.FieldCheckbox.CHECK_CHAR); }); }); }); @@ -282,7 +280,7 @@ suite('Checkbox Fields', function () { const field = new Blockly.FieldCheckbox(value); block.getInput('INPUT').appendField(field, 'CHECK'); const jso = Blockly.serialization.blocks.save(block); - chai.assert.deepEqual(jso['fields'], {'CHECK': value}); + assert.deepEqual(jso['fields'], {'CHECK': value}); }; }); diff --git a/tests/mocha/field_colour_test.js b/tests/mocha/field_colour_test.js index fcc5041bd..ed30be552 100644 --- a/tests/mocha/field_colour_test.js +++ b/tests/mocha/field_colour_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import * as Blockly from '../../build/src/core/blockly.js'; import { assertFieldValue, @@ -253,8 +254,8 @@ suite('Colour Fields', function () { let index = 0; let node = field.picker.firstChild.firstChild; while (node) { - chai.assert.equal(node.getAttribute('title'), titles[index]); - chai.assert.equal( + assert.equal(node.getAttribute('title'), titles[index]); + assert.equal( Blockly.utils.colour.parse(node.style.backgroundColor), colours[index], ); @@ -331,7 +332,7 @@ suite('Colour Fields', function () { suite('Columns', function () { function assertColumns(field, columns) { field.dropdownCreate(); - chai.assert.equal(field.picker.firstChild.children.length, columns); + assert.equal(field.picker.firstChild.children.length, columns); } test('Constants', function () { const columns = Blockly.FieldColour.COLUMNS; @@ -375,7 +376,7 @@ suite('Colour Fields', function () { const field = new Blockly.FieldColour(value); block.getInput('INPUT').appendField(field, 'COLOUR'); const jso = Blockly.serialization.blocks.save(block); - chai.assert.deepEqual(jso['fields'], {'COLOUR': value}); + assert.deepEqual(jso['fields'], {'COLOUR': value}); }; }); diff --git a/tests/mocha/field_dropdown_test.js b/tests/mocha/field_dropdown_test.js index 616211287..c0261bc65 100644 --- a/tests/mocha/field_dropdown_test.js +++ b/tests/mocha/field_dropdown_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import * as Blockly from '../../build/src/core/blockly.js'; import { assertFieldValue, @@ -252,7 +253,7 @@ suite('Dropdown Fields', function () { field.setValue(value); block.getInput('INPUT').appendField(field, 'DROPDOWN'); const jso = Blockly.serialization.blocks.save(block); - chai.assert.deepEqual(jso['fields'], {'DROPDOWN': value}); + assert.deepEqual(jso['fields'], {'DROPDOWN': value}); }; }); diff --git a/tests/mocha/field_image_test.js b/tests/mocha/field_image_test.js index ec8ad2227..ed1ec5596 100644 --- a/tests/mocha/field_image_test.js +++ b/tests/mocha/field_image_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import * as Blockly from '../../build/src/core/blockly.js'; import { assertFieldValue, @@ -134,23 +135,23 @@ suite('Image Fields', function () { }); test('JS Constructor', function () { const field = new Blockly.FieldImage('src', 10, 10, null, this.onClick); - chai.assert.equal(field.clickHandler, this.onClick); + assert.equal(field.clickHandler, this.onClick); }); test('setOnClickHandler', function () { const field = new Blockly.FieldImage('src', 10, 10); field.setOnClickHandler(this.onClick); - chai.assert.equal(field.clickHandler, this.onClick); + assert.equal(field.clickHandler, this.onClick); }); test('Remove Click Handler', function () { const field = new Blockly.FieldImage('src', 10, 10, null, this.onClick); field.setOnClickHandler(null); - chai.assert.isNull(field.clickHandler); + assert.isNull(field.clickHandler); }); }); suite('Alt', function () { test('JS Constructor', function () { const field = new Blockly.FieldImage('src', 10, 10, 'alt'); - chai.assert.equal(field.getText(), 'alt'); + assert.equal(field.getText(), 'alt'); }); test('JSON Definition', function () { const field = Blockly.FieldImage.fromJson({ @@ -159,7 +160,7 @@ suite('Image Fields', function () { height: 10, alt: 'alt', }); - chai.assert.equal(field.getText(), 'alt'); + assert.equal(field.getText(), 'alt'); }); suite('SetAlt', function () { setup(function () { @@ -182,31 +183,31 @@ suite('Image Fields', function () { const field = new Blockly.FieldImage('src', 10, 10, null, null, null, { alt: 'alt', }); - chai.assert.equal(field.getText(), 'alt'); + assert.equal(field.getText(), 'alt'); }); test('JS Configuration - Ignore', function () { const field = new Blockly.FieldImage('src', 10, 10, 'alt', null, null, { alt: 'configAlt', }); - chai.assert.equal(field.getText(), 'configAlt'); + assert.equal(field.getText(), 'configAlt'); }); test("JS Configuration - Ignore - ''", function () { const field = new Blockly.FieldImage('src', 10, 10, '', null, null, { alt: 'configAlt', }); - chai.assert.equal(field.getText(), 'configAlt'); + assert.equal(field.getText(), 'configAlt'); }); test("JS Configuration - Ignore - Config ''", function () { const field = new Blockly.FieldImage('src', 10, 10, 'alt', null, null, { alt: '', }); - chai.assert.equal(field.getText(), ''); + assert.equal(field.getText(), ''); }); }); suite('Flip RTL', function () { test('JS Constructor', function () { const field = new Blockly.FieldImage('src', 10, 10, null, null, true); - chai.assert.isTrue(field.getFlipRtl()); + assert.isTrue(field.getFlipRtl()); }); test('JSON Definition', function () { const field = Blockly.FieldImage.fromJson({ @@ -215,25 +216,25 @@ suite('Image Fields', function () { height: 10, flipRtl: true, }); - chai.assert.isTrue(field.getFlipRtl()); + assert.isTrue(field.getFlipRtl()); }); test('JS Configuration - Simple', function () { const field = new Blockly.FieldImage('src', 10, 10, null, null, null, { flipRtl: true, }); - chai.assert.isTrue(field.getFlipRtl()); + assert.isTrue(field.getFlipRtl()); }); test('JS Configuration - Ignore - True', function () { const field = new Blockly.FieldImage('src', 10, 10, null, null, true, { flipRtl: false, }); - chai.assert.isFalse(field.getFlipRtl()); + assert.isFalse(field.getFlipRtl()); }); test('JS Configuration - Ignore - False', function () { const field = new Blockly.FieldImage('src', 10, 10, null, null, false, { flipRtl: true, }); - chai.assert.isTrue(field.getFlipRtl()); + assert.isTrue(field.getFlipRtl()); }); }); }); diff --git a/tests/mocha/field_label_serializable_test.js b/tests/mocha/field_label_serializable_test.js index 37052f046..f6502db08 100644 --- a/tests/mocha/field_label_serializable_test.js +++ b/tests/mocha/field_label_serializable_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import * as Blockly from '../../build/src/core/blockly.js'; import { assertFieldValue, @@ -137,7 +138,7 @@ suite('Label Serializable Fields', function () { FIELD_TEXT_BASELINE_Y: 13, }; labelField.initView(); - chai.assert.isTrue( + assert.isTrue( Blockly.utils.dom.hasClass(labelField.textElement_, cssClass), ); } @@ -151,7 +152,7 @@ suite('Label Serializable Fields', function () { FIELD_TEXT_BASELINE_Y: 13, }; labelField.initView(); - chai.assert.isFalse( + assert.isFalse( Blockly.utils.dom.hasClass(labelField.textElement_, cssClass), ); } @@ -204,7 +205,7 @@ suite('Label Serializable Fields', function () { field.initView(); field.setClass('testClass'); // Don't call assertHasClass b/c we don't want to re-initialize. - chai.assert.isTrue( + assert.isTrue( Blockly.utils.dom.hasClass(field.textElement_, 'testClass'), ); }); @@ -219,7 +220,7 @@ suite('Label Serializable Fields', function () { }); assertHasClass(field, 'testClass'); field.setClass(null); - chai.assert.isFalse( + assert.isFalse( Blockly.utils.dom.hasClass(field.textElement_, 'testClass'), ); }); @@ -236,7 +237,7 @@ suite('Label Serializable Fields', function () { const field = new Blockly.FieldLabelSerializable(value); block.getInput('INPUT').appendField(field, 'LABEL'); const jso = Blockly.serialization.blocks.save(block); - chai.assert.deepEqual(jso['fields'], {'LABEL': value}); + assert.deepEqual(jso['fields'], {'LABEL': value}); }; }); diff --git a/tests/mocha/field_label_test.js b/tests/mocha/field_label_test.js index 368e7fd3c..43883ebf8 100644 --- a/tests/mocha/field_label_test.js +++ b/tests/mocha/field_label_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import * as Blockly from '../../build/src/core/blockly.js'; import { assertFieldValue, @@ -133,7 +134,7 @@ suite('Label Fields', function () { FIELD_TEXT_BASELINE_Y: 13, }; labelField.initView(); - chai.assert.isTrue( + assert.isTrue( Blockly.utils.dom.hasClass(labelField.textElement_, cssClass), ); } @@ -147,7 +148,7 @@ suite('Label Fields', function () { FIELD_TEXT_BASELINE_Y: 13, }; labelField.initView(); - chai.assert.isFalse( + assert.isFalse( Blockly.utils.dom.hasClass(labelField.textElement_, cssClass), ); } @@ -201,7 +202,7 @@ suite('Label Fields', function () { field.initView(); field.setClass('testClass'); // Don't call assertHasClass b/c we don't want to re-initialize. - chai.assert.isTrue( + assert.isTrue( Blockly.utils.dom.hasClass(field.textElement_, 'testClass'), ); }); @@ -216,7 +217,7 @@ suite('Label Fields', function () { }); assertHasClass(field, 'testClass'); field.setClass(null); - chai.assert.isFalse( + assert.isFalse( Blockly.utils.dom.hasClass(field.textElement_, 'testClass'), ); }); diff --git a/tests/mocha/field_number_test.js b/tests/mocha/field_number_test.js index c6737668d..fb6712046 100644 --- a/tests/mocha/field_number_test.js +++ b/tests/mocha/field_number_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import * as Blockly from '../../build/src/core/blockly.js'; import { assertFieldValue, @@ -87,9 +88,9 @@ suite('Number Fields', function () { expectedValue, ) { assertFieldValue(field, expectedValue); - chai.assert.equal(field.getMin(), expectedMin, 'Min'); - chai.assert.equal(field.getMax(), expectedMax, 'Max'); - chai.assert.equal(field.getPrecision(), expectedPrecision, 'Precision'); + assert.equal(field.getMin(), expectedMin, 'Min'); + assert.equal(field.getMax(), expectedMax, 'Max'); + assert.equal(field.getPrecision(), expectedPrecision, 'Precision'); } /** * Asserts that the field property values are set to default. @@ -190,7 +191,7 @@ suite('Number Fields', function () { }); test('Null', function () { const field = Blockly.FieldNumber.fromJson({precision: null}); - chai.assert.equal(field.getPrecision(), 0); + assert.equal(field.getPrecision(), 0); }); }); const setValueBoundsTestFn = function (testCase) { @@ -226,7 +227,7 @@ suite('Number Fields', function () { runTestCases(testCases, setValueBoundsTestFn); test('Null', function () { const field = Blockly.FieldNumber.fromJson({min: null}); - chai.assert.equal(field.getMin(), -Infinity); + assert.equal(field.getMin(), -Infinity); }); }); suite('Max', function () { @@ -253,7 +254,7 @@ suite('Number Fields', function () { runTestCases(testCases, setValueBoundsTestFn); test('Null', function () { const field = Blockly.FieldNumber.fromJson({max: null}); - chai.assert.equal(field.getMax(), Infinity); + assert.equal(field.getMax(), Infinity); }); }); }); @@ -473,7 +474,7 @@ suite('Number Fields', function () { const field = new Blockly.FieldNumber(value); block.getInput('INPUT').appendField(field, 'NUMBER'); const jso = Blockly.serialization.blocks.save(block); - chai.assert.deepEqual(jso['fields'], {'NUMBER': value}); + assert.deepEqual(jso['fields'], {'NUMBER': value}); }; }); diff --git a/tests/mocha/field_registry_test.js b/tests/mocha/field_registry_test.js index aca548746..c6ec26967 100644 --- a/tests/mocha/field_registry_test.js +++ b/tests/mocha/field_registry_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import * as Blockly from '../../build/src/core/blockly.js'; import {createDeprecationWarningStub} from './test_helpers/warnings.js'; import { @@ -37,20 +38,20 @@ suite('Field Registry', function () { Blockly.fieldRegistry.register('field_custom_test', CustomFieldType); }); test('fromJson as Key', function () { - chai.assert.throws(function () { + assert.throws(function () { Blockly.fieldRegistry.register(CustomFieldType.fromJson, ''); }, 'Invalid name'); }); test('No fromJson', function () { class IncorrectField {} - chai.assert.throws(function () { + assert.throws(function () { Blockly.fieldRegistry.register('field_custom_test', IncorrectField); }, 'must have a fromJson function'); }); test('fromJson not a function', function () { const fromJson = CustomFieldType.fromJson; CustomFieldType.fromJson = true; - chai.assert.throws(function () { + assert.throws(function () { Blockly.fieldRegistry.register('field_custom_test', CustomFieldType); }, 'must have a fromJson function'); CustomFieldType.fromJson = fromJson; @@ -67,8 +68,8 @@ suite('Field Registry', function () { const field = Blockly.fieldRegistry.fromJson(json); - chai.assert.isNotNull(field); - chai.assert.equal(field.getValue(), 'ok'); + assert.isNotNull(field); + assert.equal(field.getValue(), 'ok'); }); test('Not Registered', function () { const json = { @@ -78,8 +79,8 @@ suite('Field Registry', function () { const spy = sinon.stub(console, 'warn'); const field = Blockly.fieldRegistry.fromJson(json); - chai.assert.isNull(field); - chai.assert.isTrue(spy.called); + assert.isNull(field); + assert.isTrue(spy.called); spy.restore(); }); test('Case Different', function () { @@ -92,8 +93,8 @@ suite('Field Registry', function () { const field = Blockly.fieldRegistry.fromJson(json); - chai.assert.isNotNull(field); - chai.assert.equal(field.getValue(), 'ok'); + assert.isNotNull(field); + assert.equal(field.getValue(), 'ok'); }); test('Did not override fromJson', function () { // This class will have a fromJson method, so it can be registered @@ -107,7 +108,7 @@ suite('Field Registry', function () { value: 'ok', }; - chai.assert.throws(function () { + assert.throws(function () { Blockly.fieldRegistry.fromJson(json); }, 'Attempted to instantiate a field from the registry'); }); diff --git a/tests/mocha/field_test.js b/tests/mocha/field_test.js index 7265a1bb4..dfc798033 100644 --- a/tests/mocha/field_test.js +++ b/tests/mocha/field_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import * as Blockly from '../../build/src/core/blockly.js'; import { addBlockTypeToCleanup, @@ -65,26 +66,26 @@ suite('Abstract Fields', function () { // An old default field should be serialized. const field = new FieldDefault(); const stub = sinon.stub(console, 'warn'); - chai.assert.isTrue(field.isSerializable()); + assert.isTrue(field.isSerializable()); sinon.assert.calledOnce(stub); stub.restore(); }); test('Editable False, Serializable Default(false)', function () { // An old non-editable field should not be serialized. const field = new FieldFalseDefault(); - chai.assert.isFalse(field.isSerializable()); + assert.isFalse(field.isSerializable()); }); /* Test Other Cases */ test('Editable Default(true), Serializable True', function () { // A field that is both editable and serializable should be serialized. const field = new FieldDefaultTrue(); - chai.assert.isTrue(field.isSerializable()); + assert.isTrue(field.isSerializable()); }); test('Editable False, Serializable True', function () { // A field that is not editable, but overrides serializable to true // should be serialized (e.g. field_label_serializable) const field = new FieldFalseTrue(); - chai.assert.isTrue(field.isSerializable()); + assert.isTrue(field.isSerializable()); }); }); @@ -193,19 +194,19 @@ suite('Abstract Fields', function () { test('No implementations', function () { const field = new DefaultSerializationField('test value'); const value = field.saveState(); - chai.assert.equal(value, 'test value'); + assert.equal(value, 'test value'); }); test('Xml implementations', function () { const field = new CustomXmlField('test value'); const value = field.saveState(); - chai.assert.equal(value, 'custom value'); + assert.equal(value, 'custom value'); }); test('Xml super implementation', function () { const field = new CustomXmlCallSuperField('test value'); const value = field.saveState(); - chai.assert.equal( + assert.equal( value, 'test value', ); @@ -214,13 +215,13 @@ suite('Abstract Fields', function () { test('JSO implementations', function () { const field = new CustomJsoField('test value'); const value = field.saveState(); - chai.assert.equal(value, 'custom value'); + assert.equal(value, 'custom value'); }); test('JSO super implementations', function () { const field = new CustomJsoCallSuperField('test value'); const value = field.saveState(); - chai.assert.deepEqual(value, { + assert.deepEqual(value, { default: 'test value', val: 'custom value', }); @@ -229,7 +230,7 @@ suite('Abstract Fields', function () { test('Xml and JSO implementations', function () { const field = new CustomXmlAndJsoField('test value'); const value = field.saveState(); - chai.assert.equal(value, 'custom value'); + assert.equal(value, 'custom value'); }); }); @@ -238,7 +239,7 @@ suite('Abstract Fields', function () { const field = new DefaultSerializationField('test value'); const element = document.createElement('field'); const value = Blockly.Xml.domToText(field.toXml(element)); - chai.assert.equal( + assert.equal( value, 'test value', ); @@ -248,7 +249,7 @@ suite('Abstract Fields', function () { const field = new CustomXmlField('test value'); const element = document.createElement('field'); const value = Blockly.Xml.domToText(field.toXml(element)); - chai.assert.equal( + assert.equal( value, 'custom value', ); @@ -258,7 +259,7 @@ suite('Abstract Fields', function () { const field = new CustomXmlCallSuperField('test value'); const element = document.createElement('field'); const value = Blockly.Xml.domToText(field.toXml(element)); - chai.assert.equal( + assert.equal( value, 'test value', @@ -269,7 +270,7 @@ suite('Abstract Fields', function () { const field = new CustomXmlAndJsoField('test value'); const element = document.createElement('field'); const value = Blockly.Xml.domToText(field.toXml(element)); - chai.assert.equal( + assert.equal( value, 'custom value', ); @@ -282,13 +283,13 @@ suite('Abstract Fields', function () { test('No implementations', function () { const field = new DefaultSerializationField(''); field.loadState('test value'); - chai.assert.equal(field.getValue(), 'test value'); + assert.equal(field.getValue(), 'test value'); }); test('Xml implementations', function () { const field = new CustomXmlField(''); field.loadState('custom value'); - chai.assert.equal(field.someProperty, 'custom value'); + assert.equal(field.someProperty, 'custom value'); }); test('Xml super implementation', function () { @@ -296,27 +297,27 @@ suite('Abstract Fields', function () { field.loadState( 'test value', ); - chai.assert.equal(field.getValue(), 'test value'); - chai.assert.equal(field.someProperty, 'custom value'); + assert.equal(field.getValue(), 'test value'); + assert.equal(field.someProperty, 'custom value'); }); test('JSO implementations', function () { const field = new CustomJsoField(''); field.loadState('custom value'); - chai.assert.equal(field.someProperty, 'custom value'); + assert.equal(field.someProperty, 'custom value'); }); test('JSO super implementations', function () { const field = new CustomJsoCallSuperField(''); field.loadState({default: 'test value', val: 'custom value'}); - chai.assert.equal(field.getValue(), 'test value'); - chai.assert.equal(field.someProperty, 'custom value'); + assert.equal(field.getValue(), 'test value'); + assert.equal(field.someProperty, 'custom value'); }); test('Xml and JSO implementations', function () { const field = new CustomXmlAndJsoField(''); field.loadState('custom value'); - chai.assert.equal(field.someProperty, 'custom value'); + assert.equal(field.someProperty, 'custom value'); }); }); @@ -326,7 +327,7 @@ suite('Abstract Fields', function () { field.fromXml( Blockly.utils.xml.textToDom('test value'), ); - chai.assert.equal(field.getValue(), 'test value'); + assert.equal(field.getValue(), 'test value'); }); test('Xml implementations', function () { @@ -334,7 +335,7 @@ suite('Abstract Fields', function () { field.fromXml( Blockly.utils.xml.textToDom('custom value'), ); - chai.assert.equal(field.someProperty, 'custom value'); + assert.equal(field.someProperty, 'custom value'); }); test('Xml super implementation', function () { @@ -344,8 +345,8 @@ suite('Abstract Fields', function () { 'test value', ), ); - chai.assert.equal(field.getValue(), 'test value'); - chai.assert.equal(field.someProperty, 'custom value'); + assert.equal(field.getValue(), 'test value'); + assert.equal(field.someProperty, 'custom value'); }); test('XML andd JSO implementations', function () { @@ -353,7 +354,7 @@ suite('Abstract Fields', function () { field.fromXml( Blockly.utils.xml.textToDom('custom value'), ); - chai.assert.equal(field.someProperty, 'custom value'); + assert.equal(field.someProperty, 'custom value'); }); }); }); @@ -572,7 +573,7 @@ suite('Abstract Fields', function () { stubClassValidatorWithReturn(this.field, undefined); addSpies(this.field); this.field.setValue('value'); - chai.assert.equal(this.field.getValue(), 'value'); + assert.equal(this.field.getValue(), 'value'); sinon.assert.notCalled(this.field.doValueInvalid_); sinon.assert.calledOnce(this.field.doValueUpdate_); }); @@ -603,7 +604,7 @@ suite('Abstract Fields', function () { setLocalValidatorWithReturn(this.field, undefined); addSpies(this.field); this.field.setValue('value'); - chai.assert.equal(this.field.getValue(), 'value'); + assert.equal(this.field.getValue(), 'value'); sinon.assert.notCalled(this.field.doValueInvalid_); sinon.assert.calledOnce(this.field.doValueUpdate_); }); @@ -626,7 +627,7 @@ suite('Abstract Fields', function () { const field = new Blockly.Field('value', null, { tooltip: 'test tooltip', }); - chai.assert.equal(field.tooltip_, 'test tooltip'); + assert.equal(field.tooltip_, 'test tooltip'); }); test('JS Constructor - Dynamic', function () { const returnTooltip = function () { @@ -635,13 +636,13 @@ suite('Abstract Fields', function () { const field = new Blockly.Field('value', null, { tooltip: returnTooltip, }); - chai.assert.equal(field.tooltip_, returnTooltip); + assert.equal(field.tooltip_, returnTooltip); }); test('JSON Definition', function () { const field = CustomField.fromJson({ tooltip: 'test tooltip', }); - chai.assert.equal(field.tooltip_, 'test tooltip'); + assert.equal(field.tooltip_, 'test tooltip'); }); suite('W/ Msg References', function () { setup(function () { @@ -652,13 +653,13 @@ suite('Abstract Fields', function () { const field = new Blockly.Field('value', null, { tooltip: '%{BKY_TOOLTIP}', }); - chai.assert.equal(field.tooltip_, 'test tooltip'); + assert.equal(field.tooltip_, 'test tooltip'); }); test('JSON Definition', function () { const field = CustomField.fromJson({ tooltip: '%{BKY_TOOLTIP}', }); - chai.assert.equal(field.tooltip_, 'test tooltip'); + assert.equal(field.tooltip_, 'test tooltip'); }); }); suite('setTooltip', function () { @@ -687,7 +688,7 @@ suite('Abstract Fields', function () { this.workspace, ); const field = block.getField('TOOLTIP'); - chai.assert.equal(field.getClickTarget_().tooltip, 'tooltip'); + assert.equal(field.getClickTarget_().tooltip, 'tooltip'); }); test('After Append', function () { addBlockTypeToCleanup(this.sharedCleanup, 'tooltip'); @@ -707,7 +708,7 @@ suite('Abstract Fields', function () { this.workspace, ); const field = block.getField('TOOLTIP'); - chai.assert.equal(field.getClickTarget_().tooltip, 'tooltip'); + assert.equal(field.getClickTarget_().tooltip, 'tooltip'); }); test('After Block Creation', function () { addBlockTypeToCleanup(this.sharedCleanup, 'tooltip'); @@ -727,7 +728,7 @@ suite('Abstract Fields', function () { ); const field = block.getField('TOOLTIP'); field.setTooltip('tooltip'); - chai.assert.equal(field.getClickTarget_().tooltip, 'tooltip'); + assert.equal(field.getClickTarget_().tooltip, 'tooltip'); }); test('Dynamic Function', function () { addBlockTypeToCleanup(this.sharedCleanup, 'tooltip'); @@ -751,7 +752,7 @@ suite('Abstract Fields', function () { this.workspace, ); const field = block.getField('TOOLTIP'); - chai.assert.equal(field.getClickTarget_().tooltip, block.tooltipFunc); + assert.equal(field.getClickTarget_().tooltip, block.tooltipFunc); }); test('Element', function () { addBlockTypeToCleanup(this.sharedCleanup, 'tooltip'); @@ -774,7 +775,7 @@ suite('Abstract Fields', function () { this.workspace, ); const field = block.getField('TOOLTIP'); - chai.assert.equal(field.getClickTarget_().tooltip, block.element); + assert.equal(field.getClickTarget_().tooltip, block.element); }); test('Null', function () { addBlockTypeToCleanup(this.sharedCleanup, 'tooltip'); @@ -794,7 +795,7 @@ suite('Abstract Fields', function () { this.workspace, ); const field = block.getField('TOOLTIP'); - chai.assert.equal(field.getClickTarget_().tooltip, block); + assert.equal(field.getClickTarget_().tooltip, block); }); test('Undefined', function () { addBlockTypeToCleanup(this.sharedCleanup, 'tooltip'); @@ -813,7 +814,7 @@ suite('Abstract Fields', function () { this.workspace, ); const field = block.getField('TOOLTIP'); - chai.assert.equal(field.getClickTarget_().tooltip, block); + assert.equal(field.getClickTarget_().tooltip, block); }); }); }); diff --git a/tests/mocha/field_textinput_test.js b/tests/mocha/field_textinput_test.js index f68006e87..7b0da1b4c 100644 --- a/tests/mocha/field_textinput_test.js +++ b/tests/mocha/field_textinput_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import * as Blockly from '../../build/src/core/blockly.js'; import { assertFieldValue, @@ -228,7 +229,7 @@ suite('Text Input Fields', function () { this.assertSpellcheck = function (field, value) { this.prepField(field); field.showEditor_(); - chai.assert.equal( + assert.equal( field.htmlInput_.getAttribute('spellcheck'), value.toString(), ); @@ -266,7 +267,7 @@ suite('Text Input Fields', function () { this.prepField(field); field.showEditor_(); field.setSpellcheck(false); - chai.assert.equal(field.htmlInput_.getAttribute('spellcheck'), 'false'); + assert.equal(field.htmlInput_.getAttribute('spellcheck'), 'false'); }); }); }); @@ -281,7 +282,7 @@ suite('Text Input Fields', function () { const field = new Blockly.FieldTextInput(value); block.getInput('INPUT').appendField(field, 'TEXT'); const jso = Blockly.serialization.blocks.save(block); - chai.assert.deepEqual(jso['fields'], {'TEXT': value}); + assert.deepEqual(jso['fields'], {'TEXT': value}); }; }); diff --git a/tests/mocha/field_variable_test.js b/tests/mocha/field_variable_test.js index 0815303c6..63dd644c3 100644 --- a/tests/mocha/field_variable_test.js +++ b/tests/mocha/field_variable_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import * as Blockly from '../../build/src/core/blockly.js'; import { assertFieldValue, @@ -135,8 +136,8 @@ suite('Variable Fields', function () { suite('initModel', function () { test('No Value Before InitModel', function () { const fieldVariable = new Blockly.FieldVariable('name1'); - chai.assert.equal(fieldVariable.getText(), ''); - chai.assert.isNull(fieldVariable.getValue()); + assert.equal(fieldVariable.getText(), ''); + assert.isNull(fieldVariable.getValue()); }); }); @@ -199,19 +200,13 @@ suite('Variable Fields', function () { const dropdownOptions = Blockly.FieldVariable.dropdownCreate.call(fieldVariable); // Expect variable options, a rename option, and a delete option. - chai.assert.lengthOf(dropdownOptions, expectedVarOptions.length + 2); + assert.lengthOf(dropdownOptions, expectedVarOptions.length + 2); for (let i = 0, option; (option = expectedVarOptions[i]); i++) { - chai.assert.deepEqual(dropdownOptions[i], option); + assert.deepEqual(dropdownOptions[i], option); } - chai.assert.include( - dropdownOptions[dropdownOptions.length - 2][0], - 'Rename', - ); + assert.include(dropdownOptions[dropdownOptions.length - 2][0], 'Rename'); - chai.assert.include( - dropdownOptions[dropdownOptions.length - 1][0], - 'Delete', - ); + assert.include(dropdownOptions[dropdownOptions.length - 1][0], 'Delete'); }; test('Contains variables created before field', function () { this.workspace.createVariable('name1', '', 'id1'); @@ -311,8 +306,8 @@ suite('Variable Fields', function () { ['Type1'], 'Type1', ); - chai.assert.deepEqual(field.variableTypes, ['Type1']); - chai.assert.equal(field.defaultType, 'Type1'); + assert.deepEqual(field.variableTypes, ['Type1']); + assert.equal(field.defaultType, 'Type1'); }); test('JSON Definition', function () { const field = Blockly.FieldVariable.fromJson({ @@ -320,8 +315,8 @@ suite('Variable Fields', function () { variableTypes: ['Type1'], defaultType: 'Type1', }); - chai.assert.deepEqual(field.variableTypes, ['Type1']); - chai.assert.equal(field.defaultType, 'Type1'); + assert.deepEqual(field.variableTypes, ['Type1']); + assert.equal(field.defaultType, 'Type1'); }); test('JS Configuration - Simple', function () { const field = new Blockly.FieldVariable( @@ -334,8 +329,8 @@ suite('Variable Fields', function () { defaultType: 'Type1', }, ); - chai.assert.deepEqual(field.variableTypes, ['Type1']); - chai.assert.equal(field.defaultType, 'Type1'); + assert.deepEqual(field.variableTypes, ['Type1']); + assert.equal(field.defaultType, 'Type1'); }); test('JS Configuration - Ignore', function () { const field = new Blockly.FieldVariable( @@ -348,8 +343,8 @@ suite('Variable Fields', function () { defaultType: 'Type1', }, ); - chai.assert.deepEqual(field.variableTypes, ['Type1']); - chai.assert.equal(field.defaultType, 'Type1'); + assert.deepEqual(field.variableTypes, ['Type1']); + assert.equal(field.defaultType, 'Type1'); }); }); }); @@ -363,7 +358,7 @@ suite('Variable Fields', function () { // will be returned (regardless of what types are available on the workspace). const fieldVariable = new Blockly.FieldVariable('name1'); const resultTypes = fieldVariable.getVariableTypes(); - chai.assert.deepEqual(resultTypes, ['']); + assert.deepEqual(resultTypes, ['']); }); test('variableTypes is explicit', function () { // Expect that since variableTypes is defined, it will be the return @@ -375,8 +370,8 @@ suite('Variable Fields', function () { 'type1', ); const resultTypes = fieldVariable.getVariableTypes(); - chai.assert.deepEqual(resultTypes, ['type1', 'type2']); - chai.assert.equal( + assert.deepEqual(resultTypes, ['type1', 'type2']); + assert.equal( fieldVariable.defaultType, 'type1', 'Default type was wrong', @@ -394,7 +389,7 @@ suite('Variable Fields', function () { const resultTypes = fieldVariable.getVariableTypes(); // The empty string is always one of the options. - chai.assert.deepEqual(resultTypes, ['type1', 'type2', '']); + assert.deepEqual(resultTypes, ['type1', 'type2', '']); }); test('variableTypes is the empty list', function () { const fieldVariable = new Blockly.FieldVariable('name1'); @@ -403,7 +398,7 @@ suite('Variable Fields', function () { fieldVariable.setSourceBlock(mockBlock); fieldVariable.variableTypes = []; - chai.assert.throws(function () { + assert.throws(function () { fieldVariable.getVariableTypes(); }); }); @@ -411,7 +406,7 @@ suite('Variable Fields', function () { suite('Default types', function () { test('Default type exists', function () { const fieldVariable = new Blockly.FieldVariable(null, null, ['b'], 'b'); - chai.assert.equal( + assert.equal( fieldVariable.defaultType, 'b', 'The variable field\'s default type should be "b"', @@ -419,25 +414,25 @@ suite('Variable Fields', function () { }); test('No default type', function () { const fieldVariable = new Blockly.FieldVariable(null); - chai.assert.equal( + assert.equal( fieldVariable.defaultType, '', "The variable field's default type should be the empty string", ); - chai.assert.isNull( + assert.isNull( fieldVariable.variableTypes, "The variable field's allowed types should be null", ); }); test('Default type mismatch', function () { // Invalid default type when creating a variable field. - chai.assert.throws(function () { + assert.throws(function () { new Blockly.FieldVariable(null, null, ['a'], 'b'); }); }); test('Default type mismatch with empty array', function () { // Invalid default type when creating a variable field. - chai.assert.throws(function () { + assert.throws(function () { new Blockly.FieldVariable(null, null, ['a']); }); }); @@ -466,14 +461,14 @@ suite('Variable Fields', function () { }); test('Rename & Keep Old ID', function () { this.workspace.renameVariableById('id1', 'name2'); - chai.assert.equal(this.variableField.getText(), 'name2'); - chai.assert.equal(this.variableField.getValue(), 'id1'); + assert.equal(this.variableField.getText(), 'name2'); + assert.equal(this.variableField.getValue(), 'id1'); }); test('Rename & Get New ID', function () { this.workspace.createVariable('name2', null, 'id2'); this.workspace.renameVariableById('id1', 'name2'); - chai.assert.equal(this.variableField.getText(), 'name2'); - chai.assert.equal(this.variableField.getValue(), 'id2'); + assert.equal(this.variableField.getText(), 'name2'); + assert.equal(this.variableField.getValue(), 'id2'); }); }); @@ -494,7 +489,7 @@ suite('Variable Fields', function () { const field = new Blockly.FieldVariable('x'); block.getInput('INPUT').appendField(field, 'VAR'); const jso = Blockly.serialization.blocks.save(block); - chai.assert.deepEqual(jso['fields'], { + assert.deepEqual(jso['fields'], { 'VAR': {'id': 'id2', 'name': 'x', 'type': ''}, }); }); @@ -509,7 +504,7 @@ suite('Variable Fields', function () { ); block.getInput('INPUT').appendField(field, 'VAR'); const jso = Blockly.serialization.blocks.save(block); - chai.assert.deepEqual(jso['fields'], { + assert.deepEqual(jso['fields'], { 'VAR': {'id': 'id2', 'name': 'x', 'type': 'String'}, }); }); @@ -523,9 +518,9 @@ suite('Variable Fields', function () { const jso = Blockly.serialization.blocks.save(block, { doFullSerialization: false, }); - chai.assert.deepEqual(jso['fields'], {'VAR': {'id': 'id2'}}); - chai.assert.isUndefined(jso['fields']['VAR']['name']); - chai.assert.isUndefined(jso['fields']['VAR']['type']); + assert.deepEqual(jso['fields'], {'VAR': {'id': 'id2'}}); + assert.isUndefined(jso['fields']['VAR']['name']); + assert.isUndefined(jso['fields']['VAR']['type']); }); test('Typed', function () { @@ -540,9 +535,9 @@ suite('Variable Fields', function () { const jso = Blockly.serialization.blocks.save(block, { doFullSerialization: false, }); - chai.assert.deepEqual(jso['fields'], {'VAR': {'id': 'id2'}}); - chai.assert.isUndefined(jso['fields']['VAR']['name']); - chai.assert.isUndefined(jso['fields']['VAR']['type']); + assert.deepEqual(jso['fields'], {'VAR': {'id': 'id2'}}); + assert.isUndefined(jso['fields']['VAR']['name']); + assert.isUndefined(jso['fields']['VAR']['type']); }); }); }); @@ -572,9 +567,9 @@ suite('Variable Fields', function () { this.workspace, ); const variable = block.getField('VAR').getVariable(); - chai.assert.equal(variable.name, 'test'); - chai.assert.equal(variable.type, ''); - chai.assert.equal(variable.getId(), 'id1'); + assert.equal(variable.name, 'test'); + assert.equal(variable.type, ''); + assert.equal(variable.getId(), 'id1'); }); test('Name, untyped', function () { @@ -590,9 +585,9 @@ suite('Variable Fields', function () { this.workspace, ); const variable = block.getField('VAR').getVariable(); - chai.assert.equal(variable.name, 'test'); - chai.assert.equal(variable.type, ''); - chai.assert.equal(variable.getId(), 'id2'); + assert.equal(variable.name, 'test'); + assert.equal(variable.type, ''); + assert.equal(variable.getId(), 'id2'); }); test('Name, typed', function () { @@ -609,9 +604,9 @@ suite('Variable Fields', function () { this.workspace, ); const variable = block.getField('VAR').getVariable(); - chai.assert.equal(variable.name, 'test'); - chai.assert.equal(variable.type, 'string'); - chai.assert.equal(variable.getId(), 'id2'); + assert.equal(variable.name, 'test'); + assert.equal(variable.type, 'string'); + assert.equal(variable.getId(), 'id2'); }); }); }); diff --git a/tests/mocha/flyout_test.js b/tests/mocha/flyout_test.js index f2fe79e38..522efbdc6 100644 --- a/tests/mocha/flyout_test.js +++ b/tests/mocha/flyout_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -59,7 +60,7 @@ suite('Flyout', function () { this.flyout.targetWorkspace.getMetricsManager(); }); test('y is always 0', function () { - chai.assert.equal( + assert.equal( this.flyout.getY(), 0, 'y coordinate in vertical flyout should be 0', @@ -72,7 +73,7 @@ suite('Flyout', function () { this.flyout.targetWorkspace.toolboxPosition = Blockly.utils.toolbox.Position.RIGHT; this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.RIGHT; - chai.assert.equal( + assert.equal( this.flyout.getX(), 100, 'x should be right of workspace', @@ -82,7 +83,7 @@ suite('Flyout', function () { this.flyout.targetWorkspace.toolboxPosition = Blockly.utils.toolbox.Position.LEFT; this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.LEFT; - chai.assert.equal( + assert.equal( this.flyout.getX(), 0, 'x should be 0 if the flyout is on the left', @@ -110,7 +111,7 @@ suite('Flyout', function () { this.flyout.targetWorkspace.toolboxPosition = Blockly.utils.toolbox.Position.LEFT; this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.LEFT; - chai.assert.equal( + assert.equal( this.flyout.getX(), 20, 'x should be aligned with toolbox', @@ -128,7 +129,7 @@ suite('Flyout', function () { this.flyout.targetWorkspace.toolboxPosition = Blockly.utils.toolbox.Position.RIGHT; this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.RIGHT; - chai.assert.equal( + assert.equal( this.flyout.getX(), 90, 'x + width should be aligned with toolbox', @@ -150,7 +151,7 @@ suite('Flyout', function () { this.flyout.targetWorkspace.toolboxPosition = Blockly.utils.toolbox.Position.RIGHT; this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.LEFT; - chai.assert.equal( + assert.equal( this.flyout.getX(), 0, 'x should be aligned with left edge', @@ -169,7 +170,7 @@ suite('Flyout', function () { this.flyout.targetWorkspace.toolboxPosition = Blockly.utils.toolbox.Position.LEFT; this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.RIGHT; - chai.assert.equal( + assert.equal( this.flyout.getX(), 90, 'x + width should be aligned with right edge', @@ -195,7 +196,7 @@ suite('Flyout', function () { this.flyout.targetWorkspace.getMetricsManager(); }); test('x is always 0', function () { - chai.assert.equal( + assert.equal( this.flyout.getX(), 0, 'x coordinate in horizontal flyout should be 0', @@ -205,7 +206,7 @@ suite('Flyout', function () { this.flyout.targetWorkspace.toolboxPosition = Blockly.utils.toolbox.Position.TOP; this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.TOP; - chai.assert.equal( + assert.equal( this.flyout.getY(), 0, 'y should be 0 if flyout is at the top', @@ -218,7 +219,7 @@ suite('Flyout', function () { sinon.stub(this.targetMetricsManager, 'getViewMetrics').returns({ height: 50, }); - chai.assert.equal( + assert.equal( this.flyout.getY(), 50, 'y should be below the workspace', @@ -247,7 +248,7 @@ suite('Flyout', function () { this.flyout.targetWorkspace.toolboxPosition = Blockly.utils.toolbox.Position.TOP; this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.TOP; - chai.assert.equal( + assert.equal( this.flyout.getY(), 20, 'y should be aligned with toolbox', @@ -265,7 +266,7 @@ suite('Flyout', function () { this.flyout.targetWorkspace.toolboxPosition = Blockly.utils.toolbox.Position.BOTTOM; this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.BOTTOM; - chai.assert.equal( + assert.equal( this.flyout.getY(), 70, 'y + height should be aligned with toolbox', @@ -284,11 +285,7 @@ suite('Flyout', function () { this.flyout.targetWorkspace.toolboxPosition = Blockly.utils.toolbox.Position.BOTTOM; this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.TOP; - chai.assert.equal( - this.flyout.getY(), - 0, - 'y should be aligned with top', - ); + assert.equal(this.flyout.getY(), 0, 'y should be aligned with top'); }); test('trashcan on bottom covers bottom of workspace', function () { this.flyout.targetWorkspace.toolboxPosition = @@ -302,7 +299,7 @@ suite('Flyout', function () { }); this.flyout.setVisible(true); this.flyout.height_ = 20; - chai.assert.equal( + assert.equal( this.flyout.getY(), 40, 'y + height should be aligned with bottom', @@ -324,26 +321,26 @@ suite('Flyout', function () { const gaps = flyoutInfo.gaps; const expectedGaps = [20, 24, 24]; - chai.assert.deepEqual(gaps, expectedGaps); + assert.deepEqual(gaps, expectedGaps); - chai.assert.equal(contents.length, 3, 'Contents'); + assert.equal(contents.length, 3, 'Contents'); - chai.assert.equal(contents[0].type, 'block', 'Contents'); + assert.equal(contents[0].type, 'block', 'Contents'); const block = contents[0]['block']; - chai.assert.instanceOf(block, Blockly.BlockSvg); - chai.assert.equal(block.getFieldValue('OP'), 'NEQ'); + assert.instanceOf(block, Blockly.BlockSvg); + assert.equal(block.getFieldValue('OP'), 'NEQ'); const childA = block.getInputTargetBlock('A'); const childB = block.getInputTargetBlock('B'); - chai.assert.isTrue(childA.isShadow()); - chai.assert.isFalse(childB.isShadow()); - chai.assert.equal(childA.getFieldValue('NUM'), 1); - chai.assert.equal(childB.getFieldValue('NUM'), 2); + assert.isTrue(childA.isShadow()); + assert.isFalse(childB.isShadow()); + assert.equal(childA.getFieldValue('NUM'), 1); + assert.equal(childB.getFieldValue('NUM'), 2); - chai.assert.equal(contents[1].type, 'button', 'Contents'); - chai.assert.instanceOf(contents[1]['button'], Blockly.FlyoutButton); + assert.equal(contents[1].type, 'button', 'Contents'); + assert.instanceOf(contents[1]['button'], Blockly.FlyoutButton); - chai.assert.equal(contents[2].type, 'button', 'Contents'); - chai.assert.instanceOf(contents[2]['button'], Blockly.FlyoutButton); + assert.equal(contents[2].type, 'button', 'Contents'); + assert.instanceOf(contents[2]['button'], Blockly.FlyoutButton); } suite('Direct show', function () { @@ -391,7 +388,7 @@ suite('Flyout', function () { }); test('No category available', function () { - chai.assert.throws( + assert.throws( function () { this.flyout.show('someString'); }.bind(this), @@ -431,7 +428,7 @@ suite('Flyout', function () { this.assertDisabled = function (disabled) { const block = this.flyout.getWorkspace().getTopBlocks(false)[0]; - chai.assert.equal(!block.isEnabled(), disabled); + assert.equal(!block.isEnabled(), disabled); }; }); @@ -630,7 +627,7 @@ suite('Flyout', function () { ], }); const block = this.flyout.workspace_.getAllBlocks()[0]; - chai.assert.equal(block.getFieldValue('NUM'), 321); + assert.equal(block.getFieldValue('NUM'), 321); }); test('Recycling enabled', function () { @@ -660,7 +657,7 @@ suite('Flyout', function () { ], }); const block = this.flyout.workspace_.getAllBlocks()[0]; - chai.assert.equal(block.getFieldValue('NUM'), 123); + assert.equal(block.getFieldValue('NUM'), 123); }); }); }); diff --git a/tests/mocha/generator_test.js b/tests/mocha/generator_test.js index 3a2679dca..efaa924de 100644 --- a/tests/mocha/generator_test.js +++ b/tests/mocha/generator_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import * as Blockly from '../../build/src/core/blockly.js'; import {DartGenerator} from '../../build/src/generators/dart/dart_generator.js'; import {JavascriptGenerator} from '../../build/src/generators/javascript/javascript_generator.js'; @@ -31,22 +32,19 @@ suite('Generator', function () { }); test('Nothing', function () { - chai.assert.equal(this.generator.prefixLines('', ''), ''); + assert.equal(this.generator.prefixLines('', ''), ''); }); test('One word', function () { - chai.assert.equal(this.generator.prefixLines('Hello', '@'), '@Hello'); + assert.equal(this.generator.prefixLines('Hello', '@'), '@Hello'); }); test('One line', function () { - chai.assert.equal( - this.generator.prefixLines('Hello\n', '12'), - '12Hello\n', - ); + assert.equal(this.generator.prefixLines('Hello\n', '12'), '12Hello\n'); }); test('Two lines', function () { - chai.assert.equal( + assert.equal( this.generator.prefixLines('Hello\nWorld\n', '***'), '***Hello\n***World\n', ); @@ -97,7 +95,7 @@ suite('Generator', function () { const code = generator.blockToCode(rowBlock, opt_thisOnly); delete generator.forBlock['stack_block']; delete generator.forBlock['row_block']; - chai.assert.equal(code, expectedCode, opt_message); + assert.equal(code, expectedCode, opt_message); }; }); @@ -187,7 +185,7 @@ suite('Generator', function () { blockA.nextConnection.connect(blockC.previousConnection); const code = generator.blockToCode(blockA, opt_thisOnly); - chai.assert.equal(code, expectedCode, opt_message); + assert.equal(code, expectedCode, opt_message); }; }); @@ -214,7 +212,7 @@ suite('Generator', function () { this.generator = new TestGenerator(); }); test('No nameDB_ initialized', function () { - chai.assert.throws(() => { + assert.throws(() => { this.generator.getVariableName('foo'); }); }); @@ -222,13 +220,13 @@ suite('Generator', function () { test('Get variable name', function () { this.generator.init(); - chai.assert.equal(this.generator.getVariableName('foo'), 'foo'); + assert.equal(this.generator.getVariableName('foo'), 'foo'); }); test('Get procedure name', function () { this.generator.init(); - chai.assert.equal(this.generator.getProcedureName('foo'), 'foo'); + assert.equal(this.generator.getProcedureName('foo'), 'foo'); }); }); }); diff --git a/tests/mocha/gesture_test.js b/tests/mocha/gesture_test.js index 0572fed5b..122e96b8b 100644 --- a/tests/mocha/gesture_test.js +++ b/tests/mocha/gesture_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import {assertEventFired, assertEventNotFired} from './test_helpers/events.js'; import {defineBasicBlockWithField} from './test_helpers/block_definitions.js'; import {dispatchPointerEvent} from './test_helpers/user_input.js'; @@ -17,10 +18,7 @@ suite('Gesture', function () { function testGestureIsFieldClick(block, isFieldClick, eventsFireStub) { const field = block.getField('NAME'); const eventTarget = field.getClickTarget_(); - chai.assert.exists( - eventTarget, - 'Precondition: missing click target for field', - ); + assert.exists(eventTarget, 'Precondition: missing click target for field'); eventsFireStub.resetHistory(); dispatchPointerEvent(eventTarget, 'pointerdown'); @@ -29,14 +27,14 @@ suite('Gesture', function () { // Gestures triggered on flyouts are stored on targetWorkspace. const gestureWorkspace = fieldWorkspace.targetWorkspace || fieldWorkspace; const gesture = gestureWorkspace.currentGesture_; - chai.assert.exists(gesture, 'Gesture exists after pointerdown.'); + assert.exists(gesture, 'Gesture exists after pointerdown.'); const isFieldClickSpy = sinon.spy(gesture, 'isFieldClick'); dispatchPointerEvent(eventTarget, 'pointerup'); dispatchPointerEvent(eventTarget, 'click'); sinon.assert.called(isFieldClickSpy); - chai.assert.isTrue(isFieldClickSpy.alwaysReturned(isFieldClick)); + assert.isTrue(isFieldClickSpy.alwaysReturned(isFieldClick)); assertEventFired( eventsFireStub, @@ -67,8 +65,8 @@ suite('Gesture', function () { test('Constructor', function () { const e = {id: 'dummy_test_event'}; const gesture = new Blockly.Gesture(e, this.workspace); - chai.assert.equal(gesture.mostRecentEvent, e); - chai.assert.equal(gesture.creatorWorkspace, this.workspace); + assert.equal(gesture.mostRecentEvent, e); + assert.equal(gesture.creatorWorkspace, this.workspace); }); test('Field click - Click in workspace', function () { @@ -81,7 +79,7 @@ suite('Gesture', function () { test('Field click - Auto close flyout', function () { const flyout = this.workspace.getFlyout(true); - chai.assert.exists(flyout, 'Precondition: missing flyout'); + assert.exists(flyout, 'Precondition: missing flyout'); flyout.autoClose = true; const block = getTopFlyoutBlock(flyout); @@ -90,7 +88,7 @@ suite('Gesture', function () { test('Field click - Always open flyout', function () { const flyout = this.workspace.getFlyout(true); - chai.assert.exists(flyout, 'Precondition: missing flyout'); + assert.exists(flyout, 'Precondition: missing flyout'); flyout.autoClose = false; const block = getTopFlyoutBlock(flyout); diff --git a/tests/mocha/icon_test.js b/tests/mocha/icon_test.js index 3463d8ad8..dd5668b24 100644 --- a/tests/mocha/icon_test.js +++ b/tests/mocha/icon_test.js @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {assert} from '../../node_modules/chai/chai.js'; import { sharedTestSetup, sharedTestTeardown, @@ -62,7 +63,7 @@ suite('Icon', function () { block.addIcon(icon); - chai.assert.isFalse( + assert.isFalse( initViewSpy.called, 'Expected initView to not be called', ); @@ -79,7 +80,7 @@ suite('Icon', function () { const initViewSpy = sinon.spy(icon, 'initView'); block.addIcon(icon); - chai.assert.isTrue( + assert.isTrue( initViewSpy.calledOnce, 'Expected initView to be called', ); @@ -96,7 +97,7 @@ suite('Icon', function () { block.addIcon(icon); - chai.assert.isFalse( + assert.isFalse( applyColourSpy.called, 'Expected applyColour to not be called', ); @@ -112,7 +113,7 @@ suite('Icon', function () { const applyColourSpy = sinon.spy(icon, 'applyColour'); block.addIcon(icon); - chai.assert.isTrue( + assert.isTrue( applyColourSpy.calledOnce, 'Expected applyColour to be called', ); @@ -128,7 +129,7 @@ suite('Icon', function () { block.addIcon(icon); applyColourSpy.resetHistory(); block.setColour('#cccccc'); - chai.assert.isTrue( + assert.isTrue( applyColourSpy.calledOnce, 'Expected applyColour to be called', ); @@ -143,7 +144,7 @@ suite('Icon', function () { block.addIcon(icon); applyColourSpy.resetHistory(); block.setStyle('logic_block'); - chai.assert.isTrue( + assert.isTrue( applyColourSpy.calledOnce, 'Expected applyColour to be called', ); @@ -158,7 +159,7 @@ suite('Icon', function () { block.addIcon(icon); applyColourSpy.resetHistory(); block.setDisabledReason(true, 'test reason'); - chai.assert.isTrue( + assert.isTrue( applyColourSpy.calledOnce, 'Expected applyColour to be called', ); @@ -173,7 +174,7 @@ suite('Icon', function () { block.addIcon(icon); applyColourSpy.resetHistory(); block.setShadow(true); - chai.assert.isTrue( + assert.isTrue( applyColourSpy.calledOnce, 'Expected applyColour to be called', ); @@ -189,7 +190,7 @@ suite('Icon', function () { block.addIcon(icon); - chai.assert.isFalse( + assert.isFalse( updateEditableSpy.called, 'Expected updateEditable to not be called', ); @@ -205,7 +206,7 @@ suite('Icon', function () { const updateEditableSpy = sinon.spy(icon, 'updateEditable'); block.addIcon(icon); - chai.assert.isTrue( + assert.isTrue( updateEditableSpy.calledOnce, 'Expected updateEditable to be called', ); @@ -221,7 +222,7 @@ suite('Icon', function () { block.addIcon(icon); updateEditableSpy.resetHistory(); block.setEditable(false); - chai.assert.isTrue( + assert.isTrue( updateEditableSpy.calledOnce, 'Expected updateEditable to be called', ); @@ -237,7 +238,7 @@ suite('Icon', function () { block.setEditable(false); updateEditableSpy.resetHistory(); block.setEditable(true); - chai.assert.isTrue( + assert.isTrue( updateEditableSpy.calledOnce, 'Expected updateEditable to be called', ); @@ -255,7 +256,7 @@ suite('Icon', function () { block.setCollapsed(true); block.setCollapsed(false); - chai.assert.isFalse( + assert.isFalse( updateCollapsedSpy.called, 'Expected updateCollapsed to not be called', ); @@ -272,7 +273,7 @@ suite('Icon', function () { block.setCollapsed(true); this.clock.runAll(); - chai.assert.isTrue( + assert.isTrue( updateCollapsedSpy.called, 'Expected updateCollapsed to be called', ); @@ -289,7 +290,7 @@ suite('Icon', function () { block.setCollapsed(false); this.clock.runAll(); - chai.assert.isTrue( + assert.isTrue( updateCollapsedSpy.called, 'Expected updateCollapsed to be called', ); @@ -302,7 +303,7 @@ suite('Icon', function () { const block = createHeadlessBlock(createHeadlessWorkspace()); block.addIcon(new MockSerializableIcon()); const json = Blockly.serialization.blocks.save(block); - chai.assert.deepNestedInclude( + assert.deepNestedInclude( json, {'icons': {'serializable icon': 'some state'}}, 'Expected the JSON to include the saved state of the ' + @@ -314,7 +315,7 @@ suite('Icon', function () { const block = createHeadlessBlock(createHeadlessWorkspace()); block.addIcon(new MockNonSerializableIcon()); const json = Blockly.serialization.blocks.save(block); - chai.assert.notProperty( + assert.notProperty( json, 'icons', 'Expected the JSON to not include any saved state for icons', @@ -337,7 +338,7 @@ suite('Icon', function () { }, }; const block = Blockly.serialization.blocks.append(json, workspace); - chai.assert.equal( + assert.equal( block.getIcon('serializable icon').state, 'some state', 'Expected the icon to have been properly instantiated and ' + @@ -355,7 +356,7 @@ suite('Icon', function () { 'serializable icon': 'some state', }, }; - chai.assert.throws( + assert.throws( () => { Blockly.serialization.blocks.append(json, workspace); }, diff --git a/tests/mocha/index.html b/tests/mocha/index.html index 9c7b10cab..e095f402a 100644 --- a/tests/mocha/index.html +++ b/tests/mocha/index.html @@ -21,7 +21,6 @@ -