Skip to content

Commit 0ed5f0d

Browse files
fix(curriculum): improve lightbox display tests and allow vw/vh units (freeCodeCamp#65739)
1 parent 9b5a7f0 commit 0ed5f0d

1 file changed

Lines changed: 25 additions & 7 deletions

File tree

curriculum/challenges/english/blocks/lab-lightbox-viewer/66db57ad34c7089b9b41bfd6.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,20 @@ assert.equal(new __helpers.CSSHelp(document).getStyle(".lightbox")?.position, "f
131131
Your `.lightbox` element should cover the entire viewport.
132132

133133
```js
134-
assert.equal(new __helpers.CSSHelp(document).getStyle(".lightbox")?.width, "100%");
135-
assert.equal(new __helpers.CSSHelp(document).getStyle(".lightbox")?.height, "100%");
134+
const style = new __helpers.CSSHelp(document).getStyle(".lightbox");
135+
136+
const width = style?.width;
137+
const height = style?.height;
138+
139+
assert.oneOf(
140+
width,
141+
["100%", "100vw"]
142+
);
143+
144+
assert.oneOf(
145+
height,
146+
["100%", "100vh"]
147+
);
136148
```
137149

138150
Your `.lightbox` element should be aligned with top left corner of the container.
@@ -197,15 +209,18 @@ When your `.lightbox` element is visible and you click the `#close-btn` button,
197209

198210
```js
199211
const lightbox = document.querySelector(".lightbox");
200-
const background = document.getElementById("close-btn");
212+
const closeBtn = document.getElementById("close-btn");
213+
const galleryItem = document.querySelector(".gallery-item");
201214
202215
function getComputedDisplay(element) {
203216
return window.getComputedStyle(element).display;
204217
}
205218
206-
lightbox.style.display = "flex";
219+
galleryItem.dispatchEvent(new Event("click", { bubbles: true }));
207220
208-
background.dispatchEvent(new Event("click"));
221+
assert.strictEqual(getComputedDisplay(lightbox), "flex");
222+
223+
closeBtn.dispatchEvent(new Event("click", { bubbles: true }));
209224
210225
assert.strictEqual(getComputedDisplay(lightbox), "none");
211226
```
@@ -219,9 +234,12 @@ function getComputedDisplay(element) {
219234
return window.getComputedStyle(element).display;
220235
}
221236
222-
lightbox.style.display = "flex";
237+
const galleryItem = document.querySelector(".gallery-item");
238+
galleryItem.dispatchEvent(new Event("click", { bubbles: true }));
239+
240+
assert.strictEqual(getComputedDisplay(lightbox), "flex");
223241
224-
lightbox.dispatchEvent(new Event("click"));
242+
lightbox.dispatchEvent(new Event("click", { bubbles: true }));
225243
226244
assert.strictEqual(getComputedDisplay(lightbox), "none");
227245
```

0 commit comments

Comments
 (0)