From 9866d2f2414db4932b79cc28ae5c3ae388b630fc Mon Sep 17 00:00:00 2001 From: Tom <20648924+moT01@users.noreply.github.com> Date: Sat, 30 Nov 2019 22:32:24 -0600 Subject: [PATCH] fix: grid column and grid row tests (#37736) * fix: grid column and grid row tests * fix: test text verbiage * fix: add solution to pass build error * fix: make test more readable --- ...-grid-column-to-control-spacing.english.md | 28 ++++------- ...use-grid-row-to-control-spacing.english.md | 48 +++++++++++++++++-- 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/curriculum/challenges/english/01-responsive-web-design/css-grid/use-grid-column-to-control-spacing.english.md b/curriculum/challenges/english/01-responsive-web-design/css-grid/use-grid-column-to-control-spacing.english.md index 5703708a1a..219084e31a 100644 --- a/curriculum/challenges/english/01-responsive-web-design/css-grid/use-grid-column-to-control-spacing.english.md +++ b/curriculum/challenges/english/01-responsive-web-design/css-grid/use-grid-column-to-control-spacing.english.md @@ -34,8 +34,14 @@ Make the item with the class item5 consume the last two columns of tests: - text: item5 class should have a grid-column property. testString: assert($('style').text().replace(/\s/g, '').match(/\.item5{.*grid-column:.*}/g)); - - text: item5 class should have a grid-column property which results in the div with the item5 consuming the last two columns of the grid. - testString: assert(hasCorrectSpacing()); + - text: item5 class should have a grid-column property which results in it consuming the last two columns of the grid. + testString: " + const colStart = getComputedStyle($('.item5')[0]).gridColumnStart; + const colEnd = getComputedStyle($('.item5')[0]).gridColumnEnd; + const result = colStart.toString() + colEnd.toString(); + const correctResults = ['24', '2-1', '2span 2', '2span2', 'span 2-1', '-12', 'span 2span 2', 'span 2auto', 'autospan 2']; + assert(correctResults.includes(result)); + " ``` @@ -83,24 +89,6 @@ tests: ``` - -### Before Test -
- -```html - -``` - -
- ## Solution diff --git a/curriculum/challenges/english/01-responsive-web-design/css-grid/use-grid-row-to-control-spacing.english.md b/curriculum/challenges/english/01-responsive-web-design/css-grid/use-grid-row-to-control-spacing.english.md index 593e610c9e..3804d98f5b 100644 --- a/curriculum/challenges/english/01-responsive-web-design/css-grid/use-grid-row-to-control-spacing.english.md +++ b/curriculum/challenges/english/01-responsive-web-design/css-grid/use-grid-row-to-control-spacing.english.md @@ -21,8 +21,16 @@ Make the element with the item5 class consume the last two rows. ```yml tests: - - text: item5 class should have a grid-row property that has the value of 2 / 4. - testString: assert(code.match(/.item5\s*?{[\s\S]*grid-row\s*?:\s*?2\s*?\/\s*?4\s*?;[\s\S]*}/gi)); + - text: item5 class should have a grid-row property. + testString: assert($('style').text().replace(/\s/g, '').match(/\.item5{.*grid-row:.*}/g)); + - text: item5 class should have a grid-row property which results in it consuming the last two rows of the grid. + testString: " + const rowStart = getComputedStyle($('.item5')[0]).gridRowStart; + const rowEnd = getComputedStyle($('.item5')[0]).gridRowEnd; + const result = rowStart.toString() + rowEnd.toString(); + const correctResults = ['24', '2-1', '2span 2', '2span2', 'span 2-1', '-12', 'span 2span 2', 'span 2auto', 'autospan 2']; + assert(correctResults.includes(result)); + " ``` @@ -80,8 +88,40 @@ tests:
-```js -var code = ".item5 {grid-row: 2 / 4;}" +```html + + +
+
1
+
2
+
3
+
4
+
5
+
```