-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
662 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/unpublished-test-infra/addon-test-support/qunit-asserts/assert-better.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import QUnit from 'qunit'; | ||
|
||
let HAS_REGISTERED = false; | ||
|
||
function refFromIndex(index: number, suffix: string): string { | ||
return `<ref:@${index}${suffix}>`; | ||
} | ||
function getRefForItem<T>(map: Map<T, string>, item: T, index: number): string { | ||
let ref = map.get(item); | ||
if (ref === undefined) { | ||
ref = refFromIndex(index, 'b'); | ||
} | ||
return ref; | ||
} | ||
|
||
export function configureBetterAsserts() { | ||
if (HAS_REGISTERED === true) { | ||
throw new Error(`Attempting to re-register better assertion tools`); | ||
} | ||
HAS_REGISTERED = true; | ||
|
||
QUnit.assert.arrayStrictEquals = function <T>(actual: T[], expected: T[], message: string): void { | ||
let passed = actual.length === expected.length; | ||
|
||
let actualRefs = new Map<T, string>(); | ||
let actualSerialized: string[] = actual.map((item, index) => { | ||
let ref = refFromIndex(index, ''); | ||
actualRefs.set(item, ref); | ||
return ref; | ||
}); | ||
let expectedSerialized: string[] = expected.map((item, index) => { | ||
return getRefForItem(actualRefs, item, index); | ||
}); | ||
|
||
if (passed) { | ||
for (let i = 0; i < actual.length; i++) { | ||
if (actual[i] !== expected[i]) { | ||
passed = false; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
this.pushResult({ | ||
result: passed, | ||
actual: actualSerialized, | ||
expected: expectedSerialized, | ||
message, | ||
}); | ||
}; | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/unpublished-test-infra/addon-test-support/qunit-asserts/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { configureAssertionHandler } from './assert-assertion'; | ||
import { configureBetterAsserts } from './assert-better'; | ||
import { configureDeprecationHandler } from './assert-deprecation'; | ||
import { configureWarningHandler } from './assert-warning'; | ||
|
||
export default function configureAsserts() { | ||
configureAssertionHandler(); | ||
configureDeprecationHandler(); | ||
configureWarningHandler(); | ||
configureBetterAsserts(); | ||
} |
Oops, something went wrong.