Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support changing null to false in update-bcd #1473

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading