Skip to content

Commit

Permalink
updates tests
Browse files Browse the repository at this point in the history
adds additional boolean & string test cases
  • Loading branch information
ChrisC committed Dec 20, 2023
1 parent 2d1a41c commit 38d014e
Showing 1 changed file with 23 additions and 55 deletions.
78 changes: 23 additions & 55 deletions scripts/update-bcd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,61 +854,6 @@ describe("BCD updater", () => {
});
});

describe("getSupportStatementRanges", () => {
it("returns indefinite unsupported range for empty statements", () => {
assert.deepEqual(getStatementSupportRanges([]), {
supportedRanges: new Map(),
unsupportedRanges: new Map([[0, undefined]]),
});
});

it("returns ranges for version_added and version_removed strings", () => {
assert.deepEqual(getStatementSupportRanges([{version_added: "30"}]), {
supportedRanges: new Map([[30, undefined]]),
unsupportedRanges: new Map([[0, 29]]),
});

assert.deepEqual(
getStatementSupportRanges([
{version_added: "30"},
{version_added: "10", version_removed: "20"},
]),
{
supportedRanges: new Map([
[10, 19],
[30, undefined],
]),
unsupportedRanges: new Map([
[0, 9],
[20, 29],
]),
},
);
});

it("handles booleans", () => {
assert.deepEqual(getStatementSupportRanges([{version_added: true}]), {
supportedRanges: new Map([[0, undefined]]),
unsupportedRanges: new Map([[0, -1]]),
});

assert.deepEqual(getStatementSupportRanges([{version_added: false}]), {
supportedRanges: new Map(),
unsupportedRanges: new Map([[0, undefined]]),
});
});

it("handles preview statements", () => {
assert.deepEqual(
getStatementSupportRanges([{version_added: "preview"}]),
{
supportedRanges: new Map(),
unsupportedRanges: new Map([[0, undefined]]),
},
);
});
});

describe("hasSupportUpdates", () => {
it("detects updates with nonexistent support statements", () => {
assert.isTrue(
Expand Down Expand Up @@ -959,6 +904,14 @@ describe("BCD updater", () => {
"skips generic false statements",
);

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

assert.isTrue(
hasSupportUpdates(new Map([["80", true]]), [
{
Expand Down Expand Up @@ -1010,6 +963,21 @@ describe("BCD updater", () => {
),
);

assert.isFalse(
hasSupportUpdates(
new Map([
["v79.0.0", false],
["v80.0.1", false],
["v81.1.0", true],
]),
[
{
version_added: "81",
},
],
),
);

assert.isFalse(
hasSupportUpdates(
new Map([
Expand Down

0 comments on commit 38d014e

Please sign in to comment.