summaryrefslogtreecommitdiffstats
path: root/toolkit/components/messaging-system/schemas/SpecialMessageActionSchemas/test/browser/browser_sma_docs.js
blob: cf2ec2c30562a515ba48f3e24e5a26c424b2f502 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const TEST_URL =
  "https://example.com/browser/toolkit/components/messaging-system/schemas/SpecialMessageActionSchemas/test/browser/index.md";

function getHeadingsFromDocs(docs) {
  const re = /### `(\w+)`/g;
  const found = [];
  let match = 1;
  while (match) {
    match = re.exec(docs);
    if (match) {
      found.push(match[1]);
    }
  }
  return found;
}

add_task(async function test_sma_docs() {
  let request = await fetch(TEST_URL);
  let docs = await request.text();
  let headings = getHeadingsFromDocs(docs);
  const schemaTypes = (
    await fetchSMASchema
  ).definitions.SpecialMessageActionSchemas.anyOf.map(
    s => s.properties.type.enum[0]
  );
  for (let schemaType of schemaTypes) {
    Assert.ok(
      headings.includes(schemaType),
      `${schemaType} not found in SpecialMessageActionSchemas/index.md`
    );
  }
});