Bug 1675848 - Post: In tests, camelCase for mutable variables and reasons for assertions. r=kmag

Differential Revision: https://phabricator.services.mozilla.com/D100821
This commit is contained in:
Nick Alexander 2021-01-25 23:48:17 +00:00
parent 3d0d39d82c
commit 4803fb7c62

View File

@ -172,20 +172,22 @@ add_test(function test_categoryRegistration()
// Load test components.
do_load_manifest("CatRegistrationComponents.manifest");
const EXPECTED_ENTRIES = new Map([
const expectedEntries = new Map([
["CatRegisteredComponent", "@unit.test.com/cat-registered-component;1"],
["CatAppRegisteredComponent", "@unit.test.com/cat-app-registered-component;1"],
]);
// Verify the correct entries are registered in the "test-cat" category.
for (let {entry, value} of Services.catMan.enumerateCategory(CATEGORY_NAME)) {
print("Verify that the name/value pair exists in the expected entries.");
ok(EXPECTED_ENTRIES.has(entry));
Assert.equal(EXPECTED_ENTRIES.get(entry), value);
EXPECTED_ENTRIES.delete(entry);
ok(expectedEntries.has(entry), `${entry} is expected`);
Assert.equal(value, expectedEntries.get(entry), "${entry} has correct value.");
expectedEntries.delete(entry);
}
print("Check that all of the expected entries have been deleted.");
Assert.equal(EXPECTED_ENTRIES.size, 0);
Assert.deepEqual(
Array.from(expectedEntries.keys()),
[],
"All expected entries have been deleted."
);
run_next_test();
});
@ -201,20 +203,19 @@ add_test(function test_categoryBackgroundTaskRegistration()
// Load test components.
do_load_manifest("CatBackgroundTaskRegistrationComponents.manifest");
const EXPECTED_ENTRIES = new Map([
const expectedEntries = new Map([
["Cat1RegisteredComponent", "@unit.test.com/cat1-registered-component;1"],
["Cat1BackgroundTaskNotRegisteredComponent", "@unit.test.com/cat1-backgroundtask-notregistered-component;1"],
]);
// Verify the correct entries are registered in the "test-cat" category.
for (let {entry, value} of Services.catMan.enumerateCategory(CATEGORY_NAME)) {
ok(EXPECTED_ENTRIES.has(entry), `${entry} is expected`);
Assert.equal(EXPECTED_ENTRIES.get(entry), value);
EXPECTED_ENTRIES.delete(entry);
ok(expectedEntries.has(entry), `${entry} is expected`);
Assert.equal(value, expectedEntries.get(entry), "Verify that the value is correct in the expected entries.");
expectedEntries.delete(entry);
}
print("Check that all of the expected entries have been deleted.");
Assert.deepEqual(
Array.from(EXPECTED_ENTRIES.keys()),
Array.from(expectedEntries.keys()),
[],
"All expected entries have been deleted."
);