Skip to content

Commit

Permalink
Support changing null to false in update-bcd
Browse files Browse the repository at this point in the history
Fixes #1042.
  • Loading branch information
foolip committed May 19, 2024
1 parent 4269572 commit 80a6ad1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
27 changes: 27 additions & 0 deletions scripts/update-bcd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,33 @@ describe("BCD updater", () => {
);
});

it("detects updates in statements with null values", () => {
// Both a true and false test result is new information, but null is not.
assert.isTrue(
hasSupportUpdates(new Map([["80", true]]), [
{
version_added: null,
},
]),
);

assert.isTrue(
hasSupportUpdates(new Map([["80", false]]), [
{
version_added: null,
},
]),
);

assert.isFalse(
hasSupportUpdates(new Map([["80", null]]), [
{
version_added: null,
},
]),
);
});

it("detects updates in statements with boolean values", () => {
assert.isFalse(
hasSupportUpdates(new Map([["80", false]]), [
Expand Down
8 changes: 6 additions & 2 deletions scripts/update-bcd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -819,14 +819,18 @@ const skipCurrentBeforeSupport = skip("currentBeforeSupport", ({
* @param version - A version string.
* @param hasSupport - An boolean indicating if a test result for the version shows support.
* @param statements - An array of default statements.
* @returns A boolean indicating whether default statements indicate support for the version.
* @returns A boolean or null indicating whether default statements indicate support for the version.
*/
const isSupported = (
version: string,
hasSupport: boolean,
statements: SimpleSupportStatement[],
) => {
for (const {version_added, version_removed} of statements) {
if (version_added === null) {
return null;
}

if (version_added === "preview") {
return false;
}
Expand Down Expand Up @@ -858,7 +862,7 @@ const isSupported = (
* Iterates through a BrowserSupportMap and checks each version for possible updates against a set of default statements.
* @param versionMap - A map of versions and support assertions.
* @param defaultStatements - An array of default statements.
* @returns A boolean indicating whether possible updates to the default statments have been detected.
* @returns A boolean indicating whether possible updates to the default statements have been detected.
*/
export const hasSupportUpdates = (
versionMap: BrowserSupportMap,
Expand Down

0 comments on commit 80a6ad1

Please sign in to comment.