qunitx 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/shims/shared/assert.js +24 -16
package/package.json
CHANGED
package/shims/shared/assert.js
CHANGED
|
@@ -574,7 +574,7 @@ export default class Assert {
|
|
|
574
574
|
*/
|
|
575
575
|
throws(blockFn, expectedInput, assertionMessage) {
|
|
576
576
|
this?._incrementAssertionCount();
|
|
577
|
-
const [expected, message] = validateExpectedExceptionArgs(expectedInput, assertionMessage, '
|
|
577
|
+
const [expected, message] = validateExpectedExceptionArgs(expectedInput, assertionMessage, 'throws');
|
|
578
578
|
if (typeof blockFn !== 'function') {
|
|
579
579
|
throw new Assert.AssertionError({
|
|
580
580
|
actual: blockFn,
|
|
@@ -587,12 +587,12 @@ export default class Assert {
|
|
|
587
587
|
try {
|
|
588
588
|
blockFn();
|
|
589
589
|
} catch (error) {
|
|
590
|
-
const
|
|
591
|
-
if (
|
|
590
|
+
const [result, validatedExpected, validatedMessage] = validateException(error, expected, message);
|
|
591
|
+
if (result === false) {
|
|
592
592
|
throw new Assert.AssertionError({
|
|
593
|
-
actual:
|
|
594
|
-
expected:
|
|
595
|
-
message:
|
|
593
|
+
actual: result,
|
|
594
|
+
expected: validatedExpected,
|
|
595
|
+
message: validatedMessage,
|
|
596
596
|
stackStartFn: this.throws,
|
|
597
597
|
});
|
|
598
598
|
}
|
|
@@ -636,24 +636,32 @@ export default class Assert {
|
|
|
636
636
|
});
|
|
637
637
|
}
|
|
638
638
|
|
|
639
|
+
let didReject = false;
|
|
640
|
+
let rejectionError;
|
|
639
641
|
try {
|
|
640
642
|
await promise;
|
|
643
|
+
} catch (error) {
|
|
644
|
+
didReject = true;
|
|
645
|
+
rejectionError = error;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
if (!didReject) {
|
|
641
649
|
throw new Assert.AssertionError({
|
|
642
650
|
actual: promise,
|
|
643
651
|
expected: expected,
|
|
644
652
|
message: 'The promise returned by the `assert.rejects` callback did not reject!',
|
|
645
653
|
stackStartFn: this.rejects,
|
|
646
654
|
});
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
}
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
const [result, validatedExpected, validatedMessage] = validateException(rejectionError, expected, message);
|
|
658
|
+
if (result === false) {
|
|
659
|
+
throw new Assert.AssertionError({
|
|
660
|
+
actual: result,
|
|
661
|
+
expected: validatedExpected,
|
|
662
|
+
message: validatedMessage,
|
|
663
|
+
stackStartFn: this.rejects,
|
|
664
|
+
});
|
|
657
665
|
}
|
|
658
666
|
}
|
|
659
667
|
};
|