mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 18:08:58 +00:00
Bug 1463673 - Add the expected argument to Assert.throws/rejects for various tests in toolkit/. r=mossop
MozReview-Commit-ID: LsWlHC16145 --HG-- extra : rebase_source : d786176c8a1777e2dfb2ca71476cddf6403f2ec3
This commit is contained in:
parent
102246d437
commit
5d838d18c1
@ -37,7 +37,7 @@ add_task(async function test_constructor_ok() {
|
||||
add_task(async function test_constructor_invalid() {
|
||||
Assert.throws(() => {
|
||||
new CrashManager({foo: true});
|
||||
});
|
||||
}, /Required key not present in options/);
|
||||
});
|
||||
|
||||
add_task(async function test_get_manager() {
|
||||
@ -653,4 +653,3 @@ add_task(async function test_telemetryHistogram() {
|
||||
Assert.deepEqual(Object.keys(snap).sort(), keys.sort(),
|
||||
"Some crash types do not match");
|
||||
});
|
||||
|
||||
|
@ -44,9 +44,9 @@ add_test(function test_other_subtags_ignored() {
|
||||
add_test(function test_invalid_locales() {
|
||||
deepEqual(gLocDN(["2"]), ["2"]);
|
||||
deepEqual(gLocDN([""]), [""]);
|
||||
Assert.throws(() => gLocDN([2]));
|
||||
Assert.throws(() => gLocDN([{}]));
|
||||
Assert.throws(() => gLocDN([true]));
|
||||
Assert.throws(() => gLocDN([2]), /All locale codes must be strings/);
|
||||
Assert.throws(() => gLocDN([{}]), /All locale codes must be strings/);
|
||||
Assert.throws(() => gLocDN([true]), /All locale codes must be strings/);
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
@ -60,9 +60,9 @@ add_test(function test_language_only() {
|
||||
add_test(function test_invalid_languages() {
|
||||
deepEqual(gLangDN(["2"]), ["2"]);
|
||||
deepEqual(gLangDN([""]), [""]);
|
||||
Assert.throws(() => gLangDN([2]));
|
||||
Assert.throws(() => gLangDN([{}]));
|
||||
Assert.throws(() => gLangDN([true]));
|
||||
Assert.throws(() => gLangDN([2]), /All language codes must be strings/);
|
||||
Assert.throws(() => gLangDN([{}]), /All language codes must be strings/);
|
||||
Assert.throws(() => gLangDN([true]), /All language codes must be strings/);
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
@ -76,8 +76,8 @@ add_test(function test_region_only() {
|
||||
add_test(function test_invalid_regions() {
|
||||
deepEqual(gRegDN(["2"]), ["2"]);
|
||||
deepEqual(gRegDN([""]), [""]);
|
||||
Assert.throws(() => gRegDN([2]));
|
||||
Assert.throws(() => gRegDN([{}]));
|
||||
Assert.throws(() => gRegDN([true]));
|
||||
Assert.throws(() => gRegDN([2]), /All region codes must be strings/);
|
||||
Assert.throws(() => gRegDN([{}]), /All region codes must be strings/);
|
||||
Assert.throws(() => gRegDN([true]), /All region codes must be strings/);
|
||||
run_next_test();
|
||||
});
|
||||
|
@ -21,6 +21,7 @@ add_task(async function test_ignoreAbsent() {
|
||||
|
||||
// Removing absent files should throw if "ignoreAbsent" is true.
|
||||
await Assert.rejects(OS.File.remove(absent_file_name, {ignoreAbsent: false}),
|
||||
err => err.operation == "remove",
|
||||
"OS.File.remove throws if there is no such file.");
|
||||
|
||||
// Removing absent files should not throw if "ignoreAbsent" is true or not
|
||||
@ -40,6 +41,7 @@ add_task(async function test_ignoreAbsent_directory_missing() {
|
||||
|
||||
// Removing absent files should throw if "ignoreAbsent" is true.
|
||||
await Assert.rejects(OS.File.remove(absent_file_name, {ignoreAbsent: false}),
|
||||
err => err.operation == "remove",
|
||||
"OS.File.remove throws if there is no such file.");
|
||||
|
||||
// Removing files from absent directories should not throw if "ignoreAbsent"
|
||||
|
@ -298,7 +298,7 @@ add_task(function test_modifyLogin_nsIProperyBag()
|
||||
// Specifying a null property for a required value should throw.
|
||||
Assert.throws(() => Services.logins.modifyLogin(loginInfo, newPropertyBag({
|
||||
usernameField: null,
|
||||
})));
|
||||
})), /No matching logins/);
|
||||
|
||||
// The login can be changed to have a different type and hostname.
|
||||
Services.logins.modifyLogin(updatedLoginInfo, differentLoginProperties);
|
||||
|
@ -25,7 +25,8 @@ add_task(async function testBucketSample() {
|
||||
|
||||
add_task(async function testRatioSample() {
|
||||
// Invalid input
|
||||
Assert.rejects(Sampling.ratioSample("test", []), "ratioSample rejects for a list with no ratios");
|
||||
await Assert.rejects(Sampling.ratioSample("test", []), /ratios must be at least 1 element long/,
|
||||
"ratioSample rejects for a list with no ratios");
|
||||
|
||||
// Absolute samples
|
||||
equal(await Sampling.ratioSample("test", [1]), 0, "ratioSample returns 0 for a list with only 1 ratio");
|
||||
|
@ -206,7 +206,7 @@ add_task(async function test_xpcom_throws() {
|
||||
|
||||
// This calls QueryInterface because it looks for nsISupportsWeakReference.
|
||||
Assert.throws(() => Services.obs.addObserver(combined, "test-topic", true),
|
||||
"NS_NOINTERFACE");
|
||||
/NS_NOINTERFACE/);
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -102,20 +102,20 @@ add_task(async function test_setIntervalWithTarget() {
|
||||
|
||||
add_task(async function test_setTimeoutNonFunction() {
|
||||
Assert.throws(() => { imported.setTimeout({}, 0); },
|
||||
"callback is not a function in setTimeout");
|
||||
/callback is not a function in setTimeout/);
|
||||
});
|
||||
|
||||
add_task(async function test_setIntervalNonFunction() {
|
||||
Assert.throws(() => { imported.setInterval({}, 0); },
|
||||
"callback is not a function in setInterval");
|
||||
/callback is not a function in setInterval/);
|
||||
});
|
||||
|
||||
add_task(async function test_setTimeoutWithTargetNonFunction() {
|
||||
Assert.throws(() => { imported.setTimeoutWithTarget({}, 0); },
|
||||
"callback is not a function in setTimeout");
|
||||
/callback is not a function in setTimeout/);
|
||||
});
|
||||
|
||||
add_task(async function test_setIntervalWithTargetNonFunction() {
|
||||
Assert.throws(() => { imported.setIntervalWithTarget({}, 0); },
|
||||
"callback is not a function in setInterval");
|
||||
/callback is not a function in setInterval/);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user