Skip to content

Commit

Permalink
Moved scss @if tests to separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Fox committed Jan 11, 2018
1 parent 49b3b37 commit 803c2f0
Showing 1 changed file with 37 additions and 24 deletions.
61 changes: 37 additions & 24 deletions lib/rules/selector-max-id/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,6 @@ testRule(rule, {
code: "#foo { @media print { #bar {} } }",
description: "media query: nested"
},
{
code: "#foo { @if ($p == 1) { #bar {} } }",
description: "@if statement: nested"
},
{
code: ".foo { @if ($p == 1) { #bar #baz {} } }",
description: "@if statement: nested compound selector"
},
{
code: ".foo { @media print { #bar #baz {} } }",
description: "@media query: nested compound selector"
Expand Down Expand Up @@ -227,22 +219,6 @@ testRule(rule, {
line: 1,
column: 1
},
{
code: "#foo #bar #baz { @if ($p == 1) { #bar {} } }",
description:
"compound selector: greater than max id selectors, nested @if statement",
message: messages.expected("#foo #bar #baz", 2),
line: 1,
column: 1
},
{
code: ".foo { @if ($p == 1) { #bar #baz #foo {} } }",
description:
"nested compound selector: greater than max id selectors, nested @if statement",
message: messages.expected(".foo #bar #baz #foo", 2),
line: 1,
column: 24
},
{
code: ".foo { @media print { #bar #baz #foo {} } }",
description:
Expand Down Expand Up @@ -354,3 +330,40 @@ testRule(rule, {
}
]
});

testRule(rule, {
ruleName,
config: [2],
skipBasicChecks: true,
syntax: "scss",

accept: [
{
code: "#foo { @if ($p == 1) { #bar {} } }",
description: "@if statement: nested"
},
{
code: ".foo { @if ($p == 1) { #bar #baz {} } }",
description: "@if statement: nested compound selector"
}
],

reject: [
{
code: "#foo #bar #baz { @if ($p == 1) { #bar {} } }",
description:
"compound selector: greater than max id selectors, nested @if statement",
message: messages.expected("#foo #bar #baz", 2),
line: 1,
column: 1
},
{
code: ".foo { @if ($p == 1) { #bar #baz #foo {} } }",
description:
"nested compound selector: greater than max id selectors, nested @if statement",
message: messages.expected(".foo #bar #baz #foo", 2),
line: 1,
column: 24
}
]
});

0 comments on commit 803c2f0

Please sign in to comment.