Skip to content

Commit 694478e

Browse files
Brian M Huntclaude
authored andcommitted
Restore setTimeout fallback, clean up test helpers
- Restore setTimeout fallback in tasks.ts for environments without queueMicrotask or MutationObserver - Remove unused Assertion import in knockout test helper - Remove redundant assert.isNotNull before null throw guard Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9978f86 commit 694478e

3 files changed

Lines changed: 3 additions & 4 deletions

File tree

builds/knockout/helpers/mocha-test-helpers.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
;(function (global) {
2-
const Assertion = chai.Assertion
3-
42
function restoreAfter(cleanups, object, propertyName) {
53
const originalValue = object[propertyName]
64
cleanups.push(function () {
@@ -53,7 +51,7 @@
5351

5452
function expectEqualOneOf(actual, expectedPossibilities) {
5553
const matches = expectedPossibilities.some(function (expected) { return chai.util.eql(actual, expected) })
56-
new Assertion(matches, 'expected value to deeply equal one of the provided possibilities').to.equal(true)
54+
expect(matches, 'expected value to deeply equal one of the provided possibilities').to.equal(true)
5755
}
5856

5957
function expectContainHtml(actual, expectedHtml, postProcessCleanedHtml) {

packages/utils/helpers/mocha-test-helpers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export function nodeText(node: Node) {
3939
type HtmlNode = Node & { innerHTML: string }
4040

4141
function assertHtmlNode(node: Node | null): asserts node is HtmlNode {
42-
assert.isNotNull(node, 'expected node to exist')
4342
if (node === null) {
4443
throw new Error('expected node to exist')
4544
}

packages/utils/src/tasks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ if (schedulerGlobal && typeof schedulerGlobal.queueMicrotask === 'function') {
3838
div.setAttribute('data-task-scheduler', toggle ? '1' : '0')
3939
}
4040
})()
41+
} else {
42+
options.taskScheduler = callback => setTimeout(callback, 0)
4143
}
4244

4345
function processTasks() {

0 commit comments

Comments
 (0)