Skip to content

Commit d0f48c5

Browse files
committed
test(skills): split the add-media example check into small helpers
Clears the Fallow complexity finding on the test callback.
1 parent 210a34d commit d0f48c5

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

‎scripts/creator-editing-recipes.test.mjs‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,25 @@ test("the add-media example carries every attribute Studio's drop writes", async
126126
}
127127
});
128128

129+
const CLIP_ATTRS = ["id=", 'class="clip"', "data-start", "data-track-index"];
130+
131+
const mediaExample = (section, tag) =>
132+
section.match(new RegExp(`<${tag}[\\s\\S]*?</${tag}>`))?.[0] ?? "";
133+
134+
const assertNoAuthoredDuration = (example, tag) => {
135+
assert.ok(example, `no <${tag}> example`);
136+
assert.doesNotMatch(example, /data-duration/, `${tag} example must not author a duration`);
137+
};
138+
139+
const assertHasAttrs = (example, tag, attrs) => {
140+
for (const attr of attrs) assert.ok(example.includes(attr), `${tag} example lacks ${attr}`);
141+
};
142+
129143
test("the video and audio add-media examples carry no data-duration and keep the clip attributes", async () => {
130144
const { section } = await addMediaSection();
131145
for (const tag of ["video", "audio"]) {
132-
const example = section.match(new RegExp(`<${tag}[\\s\\S]*?</${tag}>`))?.[0] ?? "";
133-
assert.ok(example, `no <${tag}> example`);
134-
assert.doesNotMatch(example, /data-duration/, `${tag} example must not author a duration`);
135-
for (const attr of ["id=", 'class="clip"', "data-start", "data-track-index"]) {
136-
assert.ok(example.includes(attr), `${tag} example lacks ${attr}`);
137-
}
146+
const example = mediaExample(section, tag);
147+
assertNoAuthoredDuration(example, tag);
148+
assertHasAttrs(example, tag, CLIP_ATTRS);
138149
}
139150
});

0 commit comments

Comments
 (0)