Skip to content

Commit

Permalink
Add regression tests for keyword colors suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Sep 3, 2023
1 parent 9c0e14e commit 9613bbb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tests/html_files/elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
<header>Another page!</header>
<div class="content" nb-value="12">
<div class="right" data-whatever="a">
<p style="margin:2px;">Some text</p>
<p style="margin:2px;color:#f4f5f5;">Some text</p>
<div>Some text2</div>
</div>
<div class="left" data-whatever="a">
<p style="margin:2px;">Some text</p>
<div class="left" data-whatever="a" style="color:#f4f5f5;">
<p style="margin:2px;color:#f5f5f5;">Some text</p>
<span style="height:1px;display:block;"></span>
<div>Some text2</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions tests/test-js/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ function checkCssParser(x) {
p = new CssParser('rgba(255, 180, 76, 0.85)');
p2 = new CssParser('#ffb44cd9');
x.assert(p2.sameFormatAs(p), 'rgba(255, 180, 76, 0.85)');

p = new CssParser('white');
p2 = new CssParser('#f5f5f4');
x.assert(p2.sameFormatAs(p), 'rgb(245, 245, 244)');

p = new CssParser('white');
p2 = new CssParser('#f00');
x.assert(p2.sameFormatAs(p), 'red');
}

function checkTuple(x) {
Expand Down
7 changes: 7 additions & 0 deletions tests/ui-tests/assert-css.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This test is to ensure that if "show-text" is false, then it fails.
go-to: "file://" + |CURRENT_DIR| + "/" + |DOC_PATH| + "/elements.html"
show-text: true
// This test should fail and suggest "whitesmoke".
assert-css: (".content>.left>p", {"color": "white"})
// This test should fail and suggest an RGB color.
assert-css: (".content>.right>p", {"color": "white"})
8 changes: 8 additions & 0 deletions tests/ui-tests/assert-css.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
=> Starting doc-ui tests...

assert-css... FAILED
[ERROR] (line 5) The following errors happened (for selector `.content>.left>p`): [expected `white` for key `color`, found `whitesmoke`]: for command `assert-css: (".content>.left>p", {"color": "white"})`
[ERROR] (line 7) The following errors happened (for selector `.content>.right>p`): [expected `white` for key `color`, found `rgb(244, 245, 245)`]: for command `assert-css: (".content>.right>p", {"color": "white"})`


<= doc-ui tests done: 0 succeeded, 1 failed
2 changes: 1 addition & 1 deletion tests/ui-tests/functions.output
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ functions... FAILED
[ERROR] (line 8 from line 22) The following errors happened (for selector `header`): [expected `a` for key `background-color`, found `rgb(17, 17, 17)`; expected `y` for key `color`, found `rgb(255, 255, 255)`]: for command `assert-css: ("header", {"background-color": |background_color|, "color": |color|})`
[ERROR] (line 9 from line 22) The following errors happened (for selector `header`): [expected `a` for key `color`, found `rgb(255, 255, 255)`]: for command `assert-css: ("header", |whole_check|)`
[ERROR] (line 12 from line 15 from line 22) Error: Evaluation failed: The following errors happened (for selector `header`): [No attribute named `color`]: for command `assert-attribute: ("header", {"color": "blue"})`
[ERROR] (line 16 from line 22) The following errors happened (for selector `header`): [expected `red` for key `color`, found `red`]: for command `assert-css: ("header", {"color": "red"})`
[ERROR] (line 16 from line 22) The following errors happened (for selector `header`): [expected `red` for key `color`, found `white`]: for command `assert-css: ("header", {"color": "red"})`
[ERROR] (line 27 from line 32) The following errors happened (for selector `header`): [expected `a` for key `background-color`, found `rgb(17, 17, 17)`]: for command `assert-css: ("header", {"background-color": |background_color|})`
[ERROR] (line 28 from line 32) The following errors happened (for selector `header`): [expected `a` for key `color`, found `rgb(255, 255, 255)`]: for command `assert-css: ("header", |whole_check|)`
[ERROR] line 34: Missing argument "whole_check"
Expand Down

0 comments on commit 9613bbb

Please sign in to comment.