From dd5f3c463fab336d694f426dcad11a1783590fc9 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 5 Feb 2022 07:52:13 +0100 Subject: Ported from import syntax to modules --- test/bem/_at-theme.scss | 58 +++ test/bem/_block.scss | 88 +++++ test/bem/_composed-of.scss | 152 +++++++ test/bem/_element.scss | 494 +++++++++++++++++++++++ test/bem/_examples.scss | 43 +- test/bem/_iro-bem-at-theme.scss | 55 --- test/bem/_iro-bem-block.scss | 85 ---- test/bem/_iro-bem-composed-of.scss | 149 ------- test/bem/_iro-bem-element.scss | 491 ----------------------- test/bem/_iro-bem-modifier.scss | 654 ------------------------------ test/bem/_iro-bem-multi.scss | 591 ---------------------------- test/bem/_iro-bem-next-twin-element.scss | 153 -------- test/bem/_iro-bem-related-element.scss | 459 ---------------------- test/bem/_iro-bem-state.scss | 177 --------- test/bem/_iro-bem-suffix.scss | 94 ----- test/bem/_modifier.scss | 655 +++++++++++++++++++++++++++++++ test/bem/_multi.scss | 594 ++++++++++++++++++++++++++++ test/bem/_next-twin-element.scss | 156 ++++++++ test/bem/_related-element.scss | 462 ++++++++++++++++++++++ test/bem/_state.scss | 180 +++++++++ test/bem/_suffix.scss | 97 +++++ 21 files changed, 2959 insertions(+), 2928 deletions(-) create mode 100644 test/bem/_at-theme.scss create mode 100644 test/bem/_block.scss create mode 100644 test/bem/_composed-of.scss create mode 100644 test/bem/_element.scss delete mode 100644 test/bem/_iro-bem-at-theme.scss delete mode 100644 test/bem/_iro-bem-block.scss delete mode 100644 test/bem/_iro-bem-composed-of.scss delete mode 100644 test/bem/_iro-bem-element.scss delete mode 100644 test/bem/_iro-bem-modifier.scss delete mode 100644 test/bem/_iro-bem-multi.scss delete mode 100644 test/bem/_iro-bem-next-twin-element.scss delete mode 100644 test/bem/_iro-bem-related-element.scss delete mode 100644 test/bem/_iro-bem-state.scss delete mode 100644 test/bem/_iro-bem-suffix.scss create mode 100644 test/bem/_modifier.scss create mode 100644 test/bem/_multi.scss create mode 100644 test/bem/_next-twin-element.scss create mode 100644 test/bem/_related-element.scss create mode 100644 test/bem/_state.scss create mode 100644 test/bem/_suffix.scss (limited to 'test/bem') diff --git a/test/bem/_at-theme.scss b/test/bem/_at-theme.scss new file mode 100644 index 0000000..29a4eba --- /dev/null +++ b/test/bem/_at-theme.scss @@ -0,0 +1,58 @@ +// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations + +@use 'true' as *; +@use '../../src/bem'; + +// +// Included test cases: +// - /// 1 /// - single theme +// - /// 2 /// - with sub-theme +// + +@include it('at-theme') { + @include assert('single theme') { /// 1 /// + @include output(false) { + @include bem.block('something') { + @include bem.at-theme('theme') { + font-size: 2em; + } + } + } + + @include expect(false) { + .t-theme .something, + [class*=' t-'] .t-theme .something, + [class^='t-'] .t-theme .something { + font-size: 2em; + } + } + } + + @include assert('with sub-theme') { /// 2 /// + @include output(false) { + @include bem.block('something') { + @include bem.at-theme('theme') { + font-size: 2em; + } + + @include bem.at-theme('theme', 'subtheme') { + font-size: 3em; + } + } + } + + @include expect(false) { + .t-theme .something, + [class*=' t-'] .t-theme .something, + [class^='t-'] .t-theme .something { + font-size: 2em; + } + + .t-theme .t-subtheme .something, + [class*=' t-'] .t-theme .t-subtheme .something, + [class^='t-'] .t-theme .t-subtheme .something { + font-size: 3em; + } + } + } +} diff --git a/test/bem/_block.scss b/test/bem/_block.scss new file mode 100644 index 0000000..fb3a545 --- /dev/null +++ b/test/bem/_block.scss @@ -0,0 +1,88 @@ +// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations + +@use 'true' as *; +@use '../../src/bem'; + +// +// Included test cases: +// - /// 1 /// - without namespace +// - /// 2 /// - with namespace +// - /// 3 /// - nested +// - /// 4 /// - within selector +// + +@include it('block') { + @include assert('without namespace') { /// 1 /// + @include output(false) { + @include bem.block('something') { + font-size: 1em; + } + } + + @include expect(false) { + .something { + font-size: 1em; + } + } + } + + @each $ns in map-keys(bem.$namespaces) { + @include assert('with namespace "#{$ns}"') { /// 2 /// + @include output(false) { + @include bem.block('something', $ns) { + font-size: 1em; + } + } + + @include expect(false) { + @if $ns != 'theme' { + .#{map-get(bem.$namespaces, $ns)}-something { + font-size: 1em; + } + } @else { + .t-something, + [class*=' t-'] .t-something, + [class^='t-'] .t-something { + font-size: 1em; + } + } + } + } + } + + @include assert('nested') { /// 3 /// + @include output(false) { + @include bem.theme('theme') { + @include bem.theme('subtheme') { + @include bem.block('something') { + font-size: 2em; + } + } + } + } + + @include expect(false) { + .t-theme .t-subtheme .something, + [class*=' t-'] .t-theme .t-subtheme .something, + [class^='t-'] .t-theme .t-subtheme .something { + font-size: 2em; + } + } + } + + @include assert('within selector') { /// 4 /// + @include output(false) { + .sel { + @include bem.block('something') { + font-size: 2em; + } + } + } + + @include expect(false) { + .sel .something { + font-size: 2em; + } + } + } +} diff --git a/test/bem/_composed-of.scss b/test/bem/_composed-of.scss new file mode 100644 index 0000000..fcbf2c4 --- /dev/null +++ b/test/bem/_composed-of.scss @@ -0,0 +1,152 @@ +// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations + +@use 'true' as *; +@use '../../src/bem'; + +// +// Included test cases: +// - /// 1 /// - without namespace, single +// - /// 2 /// - with namespace, single +// - /// 3 /// - without namespace, multiple +// - /// 4 /// - with namespace, multiple +// + +@include it('composed-of') { + @include assert('without namespace, single') { /// 1 /// + @include output(false) { + @include bem.block('something') { + font-size: 1em; + } + + @include bem.block('another') { + @include bem.composed-of('something'); + + font-size: 2em; + } + } + + @include expect(false) { + .something { + font-size: 1em; + } + + .another { + font-size: 2em; + } + } + } + + @each $ns in map-keys(bem.$namespaces) { + @include assert('with namespace "#{$ns}", single') { /// 2 /// + @include output(false) { + @include bem.block('something', $ns) { + font-size: 1em; + } + + @include bem.block('another') { + @include bem.composed-of('something' $ns); + + font-size: 2em; + } + } + + @include expect(false) { + @if $ns != 'theme' { + .#{map-get(bem.$namespaces, $ns)}-something { + font-size: 1em; + } + } @else { + .t-something, + [class*=' t-'] .t-something, + [class^='t-'] .t-something { + font-size: 1em; + } + } + + .another { + font-size: 2em; + } + } + } + } + + @include assert('without namespace, multiple') { /// 3 /// + @include output(false) { + @include bem.block('something') { + font-size: 1em; + } + + @include bem.block('somethingElse') { + font-size: 1em; + } + + @include bem.block('another') { + @include bem.composed-of('something', 'somethingElse'); + + font-size: 2em; + } + } + + @include expect(false) { + .something { + font-size: 1em; + } + + .somethingElse { + font-size: 1em; + } + + .another { + font-size: 2em; + } + } + } + + @each $ns in map-keys(bem.$namespaces) { + @include assert('with namespace "#{$ns}", multiple') { /// 4 /// + @include output(false) { + @include bem.block('something', $ns) { + font-size: 1em; + } + + @include bem.block('somethingElse', $ns) { + font-size: 1em; + } + + @include bem.block('another') { + @include bem.composed-of('something' $ns, 'somethingElse' $ns); + + font-size: 2em; + } + } + + @include expect(false) { + @if $ns != 'theme' { + .#{map-get(bem.$namespaces, $ns)}-something { + font-size: 1em; + } + + .#{map-get(bem.$namespaces, $ns)}-somethingElse { + font-size: 1em; + } + } @else { + .t-something, + [class*=' t-'] .t-something, + [class^='t-'] .t-something { + font-size: 1em; + } + + .t-somethingElse, + [class*=' t-'] .t-somethingElse, + [class^='t-'] .t-somethingElse { + font-size: 1em; + } + } + + .another { + font-size: 2em; + } + } + } + } +} diff --git a/test/bem/_element.scss b/test/bem/_element.scss new file mode 100644 index 0000000..c8839de --- /dev/null +++ b/test/bem/_element.scss @@ -0,0 +1,494 @@ +// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations + +@use 'true' as *; +@use '../../src/bem'; + +// +// Included test cases: +// - /// 1 /// - single element +// - /// 2 /// - single element, manual selector in-between +// - /// 3 /// - single element, modifier in-between +// - /// 4 /// - single element, nested +// - /// 5 /// - single element, nested, manual selector in-between +// - /// 6 /// - single element, nested, modifier in-between +// - /// 7 /// - single element, in at-theme +// - /// 8 /// - multiple elements +// - /// 9 /// - multiple elements, manual selector in-between +// - /// 10 /// - multiple elements, modifier in-between +// - /// 11 /// - multiple elements, nested +// - /// 12 /// - multiple elements, nested, manual selector in-between +// - /// 13 /// - multiple elements, nested, modifier in-between +// - /// 14 /// - single element, in at-theme +// + +@include it('element') { + @include assert('single element') { /// 1 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + font-size: 2em; + } + } + } + + @include expect { + .something__child { + font-size: 2em; + } + } + } + + @include assert('single element, manual selector in-between') { /// 2 /// + @include output(false) { + @include bem.block('something') { + &:hover { + @include bem.elem('child1') { + font-size: 2em; + } + } + + .test & { + @include bem.elem('child2') { + font-size: 2em; + } + } + } + } + + @include expect(false) { + .something:hover .something__child1 { + font-size: 2em; + } + + .test .something__child2 { + font-size: 2em; + } + } + } + + @include assert('single element, modifier in-between') { /// 3 /// + @include output { + @include bem.block('something') { + @include bem.modifier('mod') { + @include bem.elem('child') { + font-size: 2em; + } + } + } + } + + @include expect { + .something--mod .something__child { + font-size: 2em; + } + } + } + + @include assert('single element, nested') { /// 4 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + font-size: 2em; + + @include bem.elem('subchild') { + font-size: 3em; + } + } + } + } + + @include expect { + .something__child { + font-size: 2em; + } + + .something__child .something__subchild { + font-size: 3em; + } + } + } + + @include assert('single element, nested, manual selector in-between') { /// 5 /// + @include output(false) { + @include bem.block('something') { + &:hover { + @include bem.elem('child1') { + font-size: 2em; + + @include bem.elem('subchild1') { + font-size: 3em; + } + } + } + + .test & { + @include bem.elem('child2') { + font-size: 2em; + + @include bem.elem('subchild2') { + font-size: 3em; + } + } + } + + @include bem.elem('child3') { + font-size: 2em; + + &:hover { + @include bem.elem('subchild3') { + font-size: 3em; + } + } + + .test & { + @include bem.elem('subchild4') { + font-size: 3em; + } + } + } + } + } + + @include expect(false) { + .something:hover .something__child1 { + font-size: 2em; + } + + .something:hover .something__child1 .something__subchild1 { + font-size: 3em; + } + + .test .something__child2 { + font-size: 2em; + } + + .test .something__child2 .something__subchild2 { + font-size: 3em; + } + + .something__child3 { + font-size: 2em; + } + + .something__child3:hover .something__subchild3 { + font-size: 3em; + } + + .test .something__child3 .something__subchild4 { + font-size: 3em; + } + } + } + + @include assert('single element, nested, modifier in-between') { /// 6 /// + @include output { + @include bem.block('something') { + @include bem.modifier('mod') { + @include bem.elem('child') { + font-size: 2em; + + @include bem.elem('subchild') { + font-size: 3em; + } + } + } + + @include bem.elem('child') { + font-size: 2em; + + @include bem.modifier('mod') { + @include bem.elem('subchild') { + font-size: 3em; + } + } + } + } + } + + @include expect { + .something--mod .something__child { + font-size: 2em; + } + + .something--mod .something__child .something__subchild { + font-size: 3em; + } + + .something__child { + font-size: 2em; + } + + .something__child--mod .something__subchild { + font-size: 3em; + } + } + } + + @include assert('single element, in at-theme') { /// 7 /// + @include output(false) { + @include bem.block('something') { + @include bem.at-theme('dark') { + @include bem.elem('child') { + font-size: 2em; + } + } + } + } + + @include expect(false) { + .t-dark .something__child, + [class*=' t-'] .t-dark .something__child, + [class^='t-'] .t-dark .something__child { + font-size: 2em; + } + } + } + + @include assert('multiple elements') { /// 8 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + font-size: 2em; + } + } + } + + @include expect { + .something__child1, + .something__child2 { + font-size: 2em; + } + } + } + + @include assert('multiple elements, manual selector in-between') { /// 9 /// + @include output(false) { + @include bem.block('something') { + &:hover { + @include bem.elem('child1', 'child2') { + font-size: 2em; + } + } + + .test & { + @include bem.elem('child3', 'child4') { + font-size: 2em; + } + } + } + } + + @include expect(false) { + .something:hover .something__child1, + .something:hover .something__child2 { + font-size: 2em; + } + + .test .something__child3, + .test .something__child4 { + font-size: 2em; + } + } + } + + @include assert('multiple elements, modifier in-between') { /// 10 /// + @include output { + @include bem.block('something') { + @include bem.modifier('mod') { + @include bem.elem('child1', 'child2') { + font-size: 2em; + } + } + } + } + + @include expect { + .something--mod .something__child1, + .something--mod .something__child2 { + font-size: 2em; + } + } + } + + @include assert('multiple elements, nested') { /// 11 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + font-size: 2em; + + @include bem.elem('subchild1') { + font-size: 3em; + } + } + + @include bem.elem('child3') { + font-size: 2em; + + @include bem.elem('subchild2', 'subchild3') { + font-size: 3em; + } + } + } + } + + @include expect { + .something__child1, + .something__child2 { + font-size: 2em; + } + + .something__child1 .something__subchild1, + .something__child2 .something__subchild1 { + font-size: 3em; + } + + .something__child3 { + font-size: 2em; + } + + .something__child3 .something__subchild2, + .something__child3 .something__subchild3 { + font-size: 3em; + } + } + } + + @include assert('multiple elements, nested, manual selector in-between') { /// 12 /// + @include output(false) { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + font-size: 2em; + + &:hover { + @include bem.elem('subchild1') { + font-size: 3em; + } + } + + .test & { + @include bem.elem('subchild2') { + font-size: 3em; + } + } + } + + @include bem.elem('child3') { + font-size: 2em; + + &:hover { + @include bem.elem('subchild3', 'subchild4') { + font-size: 3em; + } + } + + .test & { + @include bem.elem('subchild5', 'subchild6') { + font-size: 3em; + } + } + } + } + } + + @include expect(false) { + .something__child1, + .something__child2 { + font-size: 2em; + } + + .something__child1:hover .something__subchild1, + .something__child2:hover .something__subchild1 { + font-size: 3em; + } + + .test .something__child1 .something__subchild2, + .test .something__child2 .something__subchild2 { + font-size: 3em; + } + + .something__child3 { + font-size: 2em; + } + + .something__child3:hover .something__subchild3, + .something__child3:hover .something__subchild4 { + font-size: 3em; + } + + .test .something__child3 .something__subchild5, + .test .something__child3 .something__subchild6 { + font-size: 3em; + } + } + } + + @include assert('multiple elements, nested, modifier in-between') { /// 13 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + font-size: 2em; + + @include bem.modifier('mod') { + @include bem.elem('subchild1') { + font-size: 3em; + } + } + } + + @include bem.elem('child3') { + font-size: 2em; + + @include bem.modifier('mod') { + @include bem.elem('subchild2', 'subchild3') { + font-size: 3em; + } + } + } + } + } + + @include expect { + .something__child1, + .something__child2 { + font-size: 2em; + } + + .something__child1--mod .something__subchild1, + .something__child2--mod .something__subchild1 { + font-size: 3em; + } + + .something__child3 { + font-size: 2em; + } + + .something__child3--mod .something__subchild2, + .something__child3--mod .something__subchild3 { + font-size: 3em; + } + } + } + + @include assert('multiple elements, in at-theme') { /// 14 /// + @include output(false) { + @include bem.block('something') { + @include bem.at-theme('dark') { + @include bem.elem('child1', 'child2') { + font-size: 2em; + } + } + } + } + + @include expect(false) { + .t-dark .something__child1, + [class*=' t-'] .t-dark .something__child1, + [class^='t-'] .t-dark .something__child1, + .t-dark .something__child2, + [class*=' t-'] .t-dark .something__child2, + [class^='t-'] .t-dark .something__child2 { + font-size: 2em; + } + } + } +} diff --git a/test/bem/_examples.scss b/test/bem/_examples.scss index 243ee35..33deca0 100644 --- a/test/bem/_examples.scss +++ b/test/bem/_examples.scss @@ -1,5 +1,8 @@ // sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations no-empty-rulesets +@use 'true' as *; +@use '../../src/bem'; + // // Included test cases: // - /// 1 /// - Media object @@ -10,30 +13,30 @@ @include it('Examples') { @include assert('Media object') { /// 1 /// @include output { - @include iro-bem-object('media') { + @include bem.object('media') { display: flex; align-items: flex-start; justify-content: flex-start; - @include iro-bem-element('image') { + @include bem.elem('image') { display: block; flex: 0 0 auto; order: 1; overflow: hidden; } - @include iro-bem-element('body') { + @include bem.elem('body') { order: 2; } - @include iro-bem-modifier('rtl') { + @include bem.modifier('rtl') { justify-content: flex-end; - @include iro-bem-element('image') { + @include bem.elem('image') { order: 2; } - @include iro-bem-element('body') { + @include bem.elem('body') { order: 1; } } @@ -74,30 +77,30 @@ @include assert('Tabs') { /// 2 /// @include output { - @include iro-bem-component('tabs') { + @include bem.component('tabs') { position: relative; - @include iro-bem-element('tab') { + @include bem.elem('tab') { float: left; } - @include iro-bem-element('tabRadio') { + @include bem.elem('tabRadio') { position: absolute; top: -9999px; left: -9999px; &:checked { - @include iro-bem-sibling-element('tabLabel') { + @include bem.sibling-elem('tabLabel') { font-weight: bold; } - @include iro-bem-sibling-element('tabContent') { + @include bem.sibling-elem('tabContent') { display: block; } } } - @include iro-bem-element('tabLabel') { + @include bem.elem('tabLabel') { cursor: pointer; &:hover, @@ -106,7 +109,7 @@ } } - @include iro-bem-element('tabContent') { + @include bem.elem('tabContent') { position: absolute; left: 0; display: none; @@ -156,28 +159,28 @@ @include assert('Accordion') { /// 3 /// @include output { - @include iro-bem-component('accordion') { - @include iro-bem-element('section') { + @include bem.component('accordion') { + @include bem.elem('section') { // nothing to do } - @include iro-bem-element('sectionCheckbox') { + @include bem.elem('sectionCheckbox') { position: absolute; top: -9999px; left: -9999px; &:checked { - @include iro-bem-sibling-element('sectionLabel') { + @include bem.sibling-elem('sectionLabel') { font-weight: bold; } - @include iro-bem-sibling-element('sectionContent') { + @include bem.sibling-elem('sectionContent') { display: block; } } } - @include iro-bem-element('sectionLabel') { + @include bem.elem('sectionLabel') { cursor: pointer; &:hover, @@ -186,7 +189,7 @@ } } - @include iro-bem-element('sectionContent') { + @include bem.elem('sectionContent') { display: none; } } diff --git a/test/bem/_iro-bem-at-theme.scss b/test/bem/_iro-bem-at-theme.scss deleted file mode 100644 index d2d0696..0000000 --- a/test/bem/_iro-bem-at-theme.scss +++ /dev/null @@ -1,55 +0,0 @@ -// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations - -// -// Included test cases: -// - /// 1 /// - single theme -// - /// 2 /// - with sub-theme -// - -@include it('iro-bem-at-theme') { - @include assert('single theme') { /// 1 /// - @include output(false) { - @include iro-bem-block('something') { - @include iro-bem-at-theme('theme') { - font-size: 2em; - } - } - } - - @include expect(false) { - .t-theme .something, - [class*=' t-'] .t-theme .something, - [class^='t-'] .t-theme .something { - font-size: 2em; - } - } - } - - @include assert('with sub-theme') { /// 2 /// - @include output(false) { - @include iro-bem-block('something') { - @include iro-bem-at-theme('theme') { - font-size: 2em; - } - - @include iro-bem-at-theme('theme', 'subtheme') { - font-size: 3em; - } - } - } - - @include expect(false) { - .t-theme .something, - [class*=' t-'] .t-theme .something, - [class^='t-'] .t-theme .something { - font-size: 2em; - } - - .t-theme .t-subtheme .something, - [class*=' t-'] .t-theme .t-subtheme .something, - [class^='t-'] .t-theme .t-subtheme .something { - font-size: 3em; - } - } - } -} diff --git a/test/bem/_iro-bem-block.scss b/test/bem/_iro-bem-block.scss deleted file mode 100644 index a93d803..0000000 --- a/test/bem/_iro-bem-block.scss +++ /dev/null @@ -1,85 +0,0 @@ -// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations - -// -// Included test cases: -// - /// 1 /// - without namespace -// - /// 2 /// - with namespace -// - /// 3 /// - nested -// - /// 4 /// - within selector -// - -@include it('iro-bem-block') { - @include assert('without namespace') { /// 1 /// - @include output(false) { - @include iro-bem-block('something') { - font-size: 1em; - } - } - - @include expect(false) { - .something { - font-size: 1em; - } - } - } - - @each $ns in map-keys($iro-bem-namespaces) { - @include assert('with namespace "#{$ns}"') { /// 2 /// - @include output(false) { - @include iro-bem-block('something', $ns) { - font-size: 1em; - } - } - - @include expect(false) { - @if $ns != 'theme' { - .#{map-get($iro-bem-namespaces, $ns)}-something { - font-size: 1em; - } - } @else { - .t-something, - [class*=' t-'] .t-something, - [class^='t-'] .t-something { - font-size: 1em; - } - } - } - } - } - - @include assert('nested') { /// 3 /// - @include output(false) { - @include iro-bem-theme('theme') { - @include iro-bem-theme('subtheme') { - @include iro-bem-block('something') { - font-size: 2em; - } - } - } - } - - @include expect(false) { - .t-theme .t-subtheme .something, - [class*=' t-'] .t-theme .t-subtheme .something, - [class^='t-'] .t-theme .t-subtheme .something { - font-size: 2em; - } - } - } - - @include assert('within selector') { /// 4 /// - @include output(false) { - .sel { - @include iro-bem-block('something') { - font-size: 2em; - } - } - } - - @include expect(false) { - .sel .something { - font-size: 2em; - } - } - } -} diff --git a/test/bem/_iro-bem-composed-of.scss b/test/bem/_iro-bem-composed-of.scss deleted file mode 100644 index e724eb8..0000000 --- a/test/bem/_iro-bem-composed-of.scss +++ /dev/null @@ -1,149 +0,0 @@ -// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations - -// -// Included test cases: -// - /// 1 /// - without namespace, single -// - /// 2 /// - with namespace, single -// - /// 3 /// - without namespace, multiple -// - /// 4 /// - with namespace, multiple -// - -@include it('iro-bem-composed-of') { - @include assert('without namespace, single') { /// 1 /// - @include output(false) { - @include iro-bem-block('something') { - font-size: 1em; - } - - @include iro-bem-block('another') { - @include iro-bem-composed-of('something'); - - font-size: 2em; - } - } - - @include expect(false) { - .something { - font-size: 1em; - } - - .another { - font-size: 2em; - } - } - } - - @each $ns in map-keys($iro-bem-namespaces) { - @include assert('with namespace "#{$ns}", single') { /// 2 /// - @include output(false) { - @include iro-bem-block('something', $ns) { - font-size: 1em; - } - - @include iro-bem-block('another') { - @include iro-bem-composed-of('something' $ns); - - font-size: 2em; - } - } - - @include expect(false) { - @if $ns != 'theme' { - .#{map-get($iro-bem-namespaces, $ns)}-something { - font-size: 1em; - } - } @else { - .t-something, - [class*=' t-'] .t-something, - [class^='t-'] .t-something { - font-size: 1em; - } - } - - .another { - font-size: 2em; - } - } - } - } - - @include assert('without namespace, multiple') { /// 3 /// - @include output(false) { - @include iro-bem-block('something') { - font-size: 1em; - } - - @include iro-bem-block('somethingElse') { - font-size: 1em; - } - - @include iro-bem-block('another') { - @include iro-bem-composed-of('something', 'somethingElse'); - - font-size: 2em; - } - } - - @include expect(false) { - .something { - font-size: 1em; - } - - .somethingElse { - font-size: 1em; - } - - .another { - font-size: 2em; - } - } - } - - @each $ns in map-keys($iro-bem-namespaces) { - @include assert('with namespace "#{$ns}", multiple') { /// 4 /// - @include output(false) { - @include iro-bem-block('something', $ns) { - font-size: 1em; - } - - @include iro-bem-block('somethingElse', $ns) { - font-size: 1em; - } - - @include iro-bem-block('another') { - @include iro-bem-composed-of('something' $ns, 'somethingElse' $ns); - - font-size: 2em; - } - } - - @include expect(false) { - @if $ns != 'theme' { - .#{map-get($iro-bem-namespaces, $ns)}-something { - font-size: 1em; - } - - .#{map-get($iro-bem-namespaces, $ns)}-somethingElse { - font-size: 1em; - } - } @else { - .t-something, - [class*=' t-'] .t-something, - [class^='t-'] .t-something { - font-size: 1em; - } - - .t-somethingElse, - [class*=' t-'] .t-somethingElse, - [class^='t-'] .t-somethingElse { - font-size: 1em; - } - } - - .another { - font-size: 2em; - } - } - } - } -} diff --git a/test/bem/_iro-bem-element.scss b/test/bem/_iro-bem-element.scss deleted file mode 100644 index f69f133..0000000 --- a/test/bem/_iro-bem-element.scss +++ /dev/null @@ -1,491 +0,0 @@ -// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations - -// -// Included test cases: -// - /// 1 /// - single element -// - /// 2 /// - single element, manual selector in-between -// - /// 3 /// - single element, modifier in-between -// - /// 4 /// - single element, nested -// - /// 5 /// - single element, nested, manual selector in-between -// - /// 6 /// - single element, nested, modifier in-between -// - /// 7 /// - single element, in at-theme -// - /// 8 /// - multiple elements -// - /// 9 /// - multiple elements, manual selector in-between -// - /// 10 /// - multiple elements, modifier in-between -// - /// 11 /// - multiple elements, nested -// - /// 12 /// - multiple elements, nested, manual selector in-between -// - /// 13 /// - multiple elements, nested, modifier in-between -// - /// 14 /// - single element, in at-theme -// - -@include it('iro-bem-element') { - @include assert('single element') { /// 1 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - font-size: 2em; - } - } - } - - @include expect { - .something__child { - font-size: 2em; - } - } - } - - @include assert('single element, manual selector in-between') { /// 2 /// - @include output(false) { - @include iro-bem-block('something') { - &:hover { - @include iro-bem-element('child1') { - font-size: 2em; - } - } - - .test & { - @include iro-bem-element('child2') { - font-size: 2em; - } - } - } - } - - @include expect(false) { - .something:hover .something__child1 { - font-size: 2em; - } - - .test .something__child2 { - font-size: 2em; - } - } - } - - @include assert('single element, modifier in-between') { /// 3 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-modifier('mod') { - @include iro-bem-element('child') { - font-size: 2em; - } - } - } - } - - @include expect { - .something--mod .something__child { - font-size: 2em; - } - } - } - - @include assert('single element, nested') { /// 4 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - font-size: 2em; - - @include iro-bem-element('subchild') { - font-size: 3em; - } - } - } - } - - @include expect { - .something__child { - font-size: 2em; - } - - .something__child .something__subchild { - font-size: 3em; - } - } - } - - @include assert('single element, nested, manual selector in-between') { /// 5 /// - @include output(false) { - @include iro-bem-block('something') { - &:hover { - @include iro-bem-element('child1') { - font-size: 2em; - - @include iro-bem-element('subchild1') { - font-size: 3em; - } - } - } - - .test & { - @include iro-bem-element('child2') { - font-size: 2em; - - @include iro-bem-element('subchild2') { - font-size: 3em; - } - } - } - - @include iro-bem-element('child3') { - font-size: 2em; - - &:hover { - @include iro-bem-element('subchild3') { - font-size: 3em; - } - } - - .test & { - @include iro-bem-element('subchild4') { - font-size: 3em; - } - } - } - } - } - - @include expect(false) { - .something:hover .something__child1 { - font-size: 2em; - } - - .something:hover .something__child1 .something__subchild1 { - font-size: 3em; - } - - .test .something__child2 { - font-size: 2em; - } - - .test .something__child2 .something__subchild2 { - font-size: 3em; - } - - .something__child3 { - font-size: 2em; - } - - .something__child3:hover .something__subchild3 { - font-size: 3em; - } - - .test .something__child3 .something__subchild4 { - font-size: 3em; - } - } - } - - @include assert('single element, nested, modifier in-between') { /// 6 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-modifier('mod') { - @include iro-bem-element('child') { - font-size: 2em; - - @include iro-bem-element('subchild') { - font-size: 3em; - } - } - } - - @include iro-bem-element('child') { - font-size: 2em; - - @include iro-bem-modifier('mod') { - @include iro-bem-element('subchild') { - font-size: 3em; - } - } - } - } - } - - @include expect { - .something--mod .something__child { - font-size: 2em; - } - - .something--mod .something__child .something__subchild { - font-size: 3em; - } - - .something__child { - font-size: 2em; - } - - .something__child--mod .something__subchild { - font-size: 3em; - } - } - } - - @include assert('single element, in at-theme') { /// 7 /// - @include output(false) { - @include iro-bem-block('something') { - @include iro-bem-at-theme('dark') { - @include iro-bem-element('child') { - font-size: 2em; - } - } - } - } - - @include expect(false) { - .t-dark .something__child, - [class*=' t-'] .t-dark .something__child, - [class^='t-'] .t-dark .something__child { - font-size: 2em; - } - } - } - - @include assert('multiple elements') { /// 8 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - font-size: 2em; - } - } - } - - @include expect { - .something__child1, - .something__child2 { - font-size: 2em; - } - } - } - - @include assert('multiple elements, manual selector in-between') { /// 9 /// - @include output(false) { - @include iro-bem-block('something') { - &:hover { - @include iro-bem-element('child1', 'child2') { - font-size: 2em; - } - } - - .test & { - @include iro-bem-element('child3', 'child4') { - font-size: 2em; - } - } - } - } - - @include expect(false) { - .something:hover .something__child1, - .something:hover .something__child2 { - font-size: 2em; - } - - .test .something__child3, - .test .something__child4 { - font-size: 2em; - } - } - } - - @include assert('multiple elements, modifier in-between') { /// 10 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-modifier('mod') { - @include iro-bem-element('child1', 'child2') { - font-size: 2em; - } - } - } - } - - @include expect { - .something--mod .something__child1, - .something--mod .something__child2 { - font-size: 2em; - } - } - } - - @include assert('multiple elements, nested') { /// 11 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - font-size: 2em; - - @include iro-bem-element('subchild1') { - font-size: 3em; - } - } - - @include iro-bem-element('child3') { - font-size: 2em; - - @include iro-bem-element('subchild2', 'subchild3') { - font-size: 3em; - } - } - } - } - - @include expect { - .something__child1, - .something__child2 { - font-size: 2em; - } - - .something__child1 .something__subchild1, - .something__child2 .something__subchild1 { - font-size: 3em; - } - - .something__child3 { - font-size: 2em; - } - - .something__child3 .something__subchild2, - .something__child3 .something__subchild3 { - font-size: 3em; - } - } - } - - @include assert('multiple elements, nested, manual selector in-between') { /// 12 /// - @include output(false) { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - font-size: 2em; - - &:hover { - @include iro-bem-element('subchild1') { - font-size: 3em; - } - } - - .test & { - @include iro-bem-element('subchild2') { - font-size: 3em; - } - } - } - - @include iro-bem-element('child3') { - font-size: 2em; - - &:hover { - @include iro-bem-element('subchild3', 'subchild4') { - font-size: 3em; - } - } - - .test & { - @include iro-bem-element('subchild5', 'subchild6') { - font-size: 3em; - } - } - } - } - } - - @include expect(false) { - .something__child1, - .something__child2 { - font-size: 2em; - } - - .something__child1:hover .something__subchild1, - .something__child2:hover .something__subchild1 { - font-size: 3em; - } - - .test .something__child1 .something__subchild2, - .test .something__child2 .something__subchild2 { - font-size: 3em; - } - - .something__child3 { - font-size: 2em; - } - - .something__child3:hover .something__subchild3, - .something__child3:hover .something__subchild4 { - font-size: 3em; - } - - .test .something__child3 .something__subchild5, - .test .something__child3 .something__subchild6 { - font-size: 3em; - } - } - } - - @include assert('multiple elements, nested, modifier in-between') { /// 13 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - font-size: 2em; - - @include iro-bem-modifier('mod') { - @include iro-bem-element('subchild1') { - font-size: 3em; - } - } - } - - @include iro-bem-element('child3') { - font-size: 2em; - - @include iro-bem-modifier('mod') { - @include iro-bem-element('subchild2', 'subchild3') { - font-size: 3em; - } - } - } - } - } - - @include expect { - .something__child1, - .something__child2 { - font-size: 2em; - } - - .something__child1--mod .something__subchild1, - .something__child2--mod .something__subchild1 { - font-size: 3em; - } - - .something__child3 { - font-size: 2em; - } - - .something__child3--mod .something__subchild2, - .something__child3--mod .something__subchild3 { - font-size: 3em; - } - } - } - - @include assert('multiple elements, in at-theme') { /// 14 /// - @include output(false) { - @include iro-bem-block('something') { - @include iro-bem-at-theme('dark') { - @include iro-bem-element('child1', 'child2') { - font-size: 2em; - } - } - } - } - - @include expect(false) { - .t-dark .something__child1, - [class*=' t-'] .t-dark .something__child1, - [class^='t-'] .t-dark .something__child1, - .t-dark .something__child2, - [class*=' t-'] .t-dark .something__child2, - [class^='t-'] .t-dark .something__child2 { - font-size: 2em; - } - } - } -} diff --git a/test/bem/_iro-bem-modifier.scss b/test/bem/_iro-bem-modifier.scss deleted file mode 100644 index 60e2fe4..0000000 --- a/test/bem/_iro-bem-modifier.scss +++ /dev/null @@ -1,654 +0,0 @@ -// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations - -// -// Included test cases: -// - /// 1 /// - block modifier -// - /// 2 /// - block modifier, in at-theme -// - /// 3 /// - element modifier, single element -// - /// 4 /// - element modifier, multiple elements -// - /// 5 /// - element modifier, single related element -// - /// 6 /// - element modifier, multiple related elements -// - /// 7 /// - element modifier, single element, manual selector before -// - /// 8 /// - element modifier, multiple elements, manual selector before -// - /// 9 /// - element modifier, single related element, manual selector before -// - /// 10 /// - element modifier, multiple related elements, manual selector before -// - /// 11 /// - element modifier, in at-theme -// - /// 12 /// - nested block modifiers, extending -// - /// 13 /// - nested element modifiers, extending -// - /// 14 /// - block and element modifiers, single element -// - /// 15 /// - block and element modifiers, multiple elements -// - -@include it('iro-bem-modifier') { - @include assert('block modifier') { /// 1 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-modifier('mod') { - font-size: 1.5em; - - @include iro-bem-modifier('submod') { - font-size: 1.75em; - } - } - } - } - - @include expect { - .something--mod { - font-size: 1.5em; - } - - .something--mod.something--submod { - font-size: 1.75em; - } - } - } - - @include assert('block modifier, in at-theme') { /// 2 /// - @include output(false) { - @include iro-bem-block('something') { - @include iro-bem-at-theme('dark') { - @include iro-bem-modifier('mod') { - font-size: 1.5em; - - @include iro-bem-modifier('submod') { - font-size: 1.75em; - } - } - } - } - } - - @include expect(false) { - .t-dark .something--mod, - [class*=' t-'] .t-dark .something--mod, - [class^='t-'] .t-dark .something--mod { - font-size: 1.5em; - } - - .t-dark .something--mod.something--submod, - [class*=' t-'] .t-dark .something--mod.something--submod, - [class^='t-'] .t-dark .something--mod.something--submod { - font-size: 1.75em; - } - } - } - - @include assert('element modifier, single element') { /// 3 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - @include iro-bem-modifier('mod') { - font-size: 2.5em; - - @include iro-bem-modifier('submod') { - font-size: 2.75em; - } - } - } - } - } - - @include expect { - .something__child--mod { - font-size: 2.5em; - } - - .something__child--mod.something__child--submod { - font-size: 2.75em; - } - } - } - - @include assert('element modifier, multiple elements') { /// 4 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - @include iro-bem-modifier('mod') { - font-size: 2.5em; - - @include iro-bem-modifier('submod') { - font-size: 2.75em; - } - } - } - } - } - - @include expect { - .something__child1--mod, - .something__child2--mod { - font-size: 2.5em; - } - - .something__child1--mod.something__child1--submod, - .something__child2--mod.something__child2--submod { - font-size: 2.75em; - } - } - } - - @include assert('element modifier, single related element') { /// 5 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1') { - @include iro-bem-next-element('child2') { - @include iro-bem-modifier('mod') { - font-size: 2.5em; - - @include iro-bem-modifier('submod') { - font-size: 2.75em; - } - } - } - } - } - } - - @include expect { - .something__child1 + .something__child2--mod { - font-size: 2.5em; - } - - .something__child1 + .something__child2--mod.something__child2--submod { - font-size: 2.75em; - } - } - } - - @include assert('element modifier, multiple related elements') { /// 6 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1') { - @include iro-bem-next-element('child2', 'child3') { - @include iro-bem-modifier('mod') { - font-size: 2.5em; - - @include iro-bem-modifier('submod') { - font-size: 2.75em; - } - } - } - } - } - } - - @include expect { - .something__child1 + .something__child2--mod, - .something__child1 + .something__child3--mod { - font-size: 2.5em; - } - - .something__child1 + .something__child2--mod.something__child2--submod, - .something__child1 + .something__child3--mod.something__child3--submod { - font-size: 2.75em; - } - } - } - - @include assert('element modifier, single element, manual selector before') { /// 7 /// - @include output(false) { - @include iro-bem-block('something') { - &:hover { - @include iro-bem-element('child1') { - @include iro-bem-modifier('mod') { - font-size: 2.5em; - - @include iro-bem-modifier('submod') { - font-size: 2.75em; - } - } - } - } - - .test & { - @include iro-bem-element('child2') { - @include iro-bem-modifier('mod') { - font-size: 2.5em; - - @include iro-bem-modifier('submod') { - font-size: 2.75em; - } - } - } - } - } - } - - @include expect(false) { - .something:hover .something__child1--mod { - font-size: 2.5em; - } - - .something:hover .something__child1--mod.something__child1--submod { - font-size: 2.75em; - } - - .test .something__child2--mod { - font-size: 2.5em; - } - - .test .something__child2--mod.something__child2--submod { - font-size: 2.75em; - } - } - } - - @include assert('element modifier, multiple elements, manual selector before') { /// 8 /// - @include output(false) { - @include iro-bem-block('something') { - &:hover { - @include iro-bem-element('child1', 'child2') { - @include iro-bem-modifier('mod') { - font-size: 2.5em; - - @include iro-bem-modifier('submod') { - font-size: 2.75em; - } - } - } - } - - .test & { - @include iro-bem-element('child3', 'child4') { - @include iro-bem-modifier('mod') { - font-size: 2.5em; - - @include iro-bem-modifier('submod') { - font-size: 2.75em; - } - } - } - } - } - } - - @include expect(false) { - .something:hover .something__child1--mod, - .something:hover .something__child2--mod { - font-size: 2.5em; - } - - .something:hover .something__child1--mod.something__child1--submod, - .something:hover .something__child2--mod.something__child2--submod { - font-size: 2.75em; - } - - .test .something__child3--mod, - .test .something__child4--mod { - font-size: 2.5em; - } - - .test .something__child3--mod.something__child3--submod, - .test .something__child4--mod.something__child4--submod { - font-size: 2.75em; - } - } - } - - @include assert('element modifier, single related element, manual selector before') { /// 9 /// - @include output(false) { - @include iro-bem-block('something') { - &:hover { - @include iro-bem-element('child1') { - @include iro-bem-next-element('child2') { - @include iro-bem-modifier('mod1') { - font-size: 2.5em; - - @include iro-bem-modifier('submod1') { - font-size: 2.75em; - } - } - } - } - } - - .test & { - @include iro-bem-element('child3') { - @include iro-bem-next-element('child4') { - @include iro-bem-modifier('mod1') { - font-size: 2.5em; - - @include iro-bem-modifier('submod1') { - font-size: 2.75em; - } - } - } - } - } - - @include iro-bem-element('child5') { - &:hover { - @include iro-bem-next-element('child6') { - @include iro-bem-modifier('mod2') { - font-size: 2.5em; - - @include iro-bem-modifier('submod2') { - font-size: 2.75em; - } - } - } - } - - .test & { - @include iro-bem-next-element('child7') { - @include iro-bem-modifier('mod2') { - font-size: 2.5em; - - @include iro-bem-modifier('submod2') { - font-size: 2.75em; - } - } - } - } - } - } - } - - @include expect(false) { - .something:hover .something__child1 + .something__child2--mod1 { - font-size: 2.5em; - } - - .something:hover .something__child1 + .something__child2--mod1.something__child2--submod1 { - font-size: 2.75em; - } - - .test .something__child3 + .something__child4--mod1 { - font-size: 2.5em; - } - - .test .something__child3 + .something__child4--mod1.something__child4--submod1 { - font-size: 2.75em; - } - - .something__child5:hover + .something__child6--mod2 { - font-size: 2.5em; - } - - .something__child5:hover + .something__child6--mod2.something__child6--submod2 { - font-size: 2.75em; - } - - .test .something__child5 + .something__child7--mod2 { - font-size: 2.5em; - } - - .test .something__child5 + .something__child7--mod2.something__child7--submod2 { - font-size: 2.75em; - } - } - } - - @include assert('element modifier, multiple related elements, manual selector before') { /// 10 /// - @include output(false) { - @include iro-bem-block('something') { - &:hover { - @include iro-bem-element('child1') { - @include iro-bem-next-element('child2', 'child3') { - @include iro-bem-modifier('mod1') { - font-size: 2.5em; - - @include iro-bem-modifier('submod1') { - font-size: 2.75em; - } - } - } - } - } - - .test & { - @include iro-bem-element('child4') { - @include iro-bem-next-element('child5', 'child6') { - @include iro-bem-modifier('mod1') { - font-size: 2.5em; - - @include iro-bem-modifier('submod1') { - font-size: 2.75em; - } - } - } - } - } - - @include iro-bem-element('child7') { - &:hover { - @include iro-bem-next-element('child8', 'child9') { - @include iro-bem-modifier('mod2') { - font-size: 2.5em; - - @include iro-bem-modifier('submod2') { - font-size: 2.75em; - } - } - } - } - - .test & { - @include iro-bem-next-element('child10', 'child11') { - @include iro-bem-modifier('mod2') { - font-size: 2.5em; - - @include iro-bem-modifier('submod2') { - font-size: 2.75em; - } - } - } - } - } - } - } - - @include expect(false) { - .something:hover .something__child1 + .something__child2--mod1, - .something:hover .something__child1 + .something__child3--mod1 { - font-size: 2.5em; - } - - .something:hover .something__child1 + .something__child2--mod1.something__child2--submod1, - .something:hover .something__child1 + .something__child3--mod1.something__child3--submod1 { - font-size: 2.75em; - } - - .test .something__child4 + .something__child5--mod1, - .test .something__child4 + .something__child6--mod1 { - font-size: 2.5em; - } - - .test .something__child4 + .something__child5--mod1.something__child5--submod1, - .test .something__child4 + .something__child6--mod1.something__child6--submod1 { - font-size: 2.75em; - } - - .something__child7:hover + .something__child8--mod2, - .something__child7:hover + .something__child9--mod2 { - font-size: 2.5em; - } - - .something__child7:hover + .something__child8--mod2.something__child8--submod2, - .something__child7:hover + .something__child9--mod2.something__child9--submod2 { - font-size: 2.75em; - } - - .test .something__child7 + .something__child10--mod2, - .test .something__child7 + .something__child11--mod2 { - font-size: 2.5em; - } - - .test .something__child7 + .something__child10--mod2.something__child10--submod2, - .test .something__child7 + .something__child11--mod2.something__child11--submod2 { - font-size: 2.75em; - } - } - } - - /* - @include assert('element modifier, in at-theme') { /// 11 /// - @include output(false) { - @include iro-bem-block('something') { - @include iro-bem-at-theme('dark') { - @include iro-bem-element('child') { - @include iro-bem-modifier('mod') { - font-size: 2.5em; - - @include iro-bem-modifier('submod') { - font-size: 2.75em; - } - } - } - } - } - } - - @include expect(false) { - .t-dark .something__child--mod, - [class*=' t-'] .t-dark .something__child--mod, - [class^='t-'] .t-dark .something__child--mod { - font-size: 2.5em; - } - - .t-dark .something__child--mod.something__child--submod, - [class*=' t-'] .t-dark .something__child--mod.something__child--submod, - [class^='t-'] .t-dark .something__child--mod.something__child--submod { - font-size: 2.75em; - } - } - } - */ - - @include assert('nested block modifiers, extending') { /// 12 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-modifier('mod') { - font-size: 1.5em; - - @include iro-bem-modifier('submod' true) { - font-size: 1.75em; - } - } - } - } - - @include expect { - .something--mod { - font-size: 1.5em; - } - - .something--mod--submod { - font-size: 1.75em; - } - } - } - - @include assert('nested element modifiers, extending') { /// 13 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - @include iro-bem-modifier('mod') { - font-size: 2.5em; - - @include iro-bem-modifier('submod' true) { - font-size: 2.75em; - } - } - } - } - } - - @include expect { - .something__child--mod { - font-size: 2.5em; - } - - .something__child--mod--submod { - font-size: 2.75em; - } - } - } - - @include assert('block and element modifiers, single element') { /// 14 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-modifier('mod1') { - font-size: 1.5em; - - @include iro-bem-modifier('submod1') { - font-size: 1.75em; - } - - @include iro-bem-element('child') { - @include iro-bem-modifier('mod2') { - font-size: 2.5em; - - @include iro-bem-modifier('submod2') { - font-size: 2.75em; - } - } - } - } - } - } - - @include expect { - .something--mod1 { - font-size: 1.5em; - } - - .something--mod1.something--submod1 { - font-size: 1.75em; - } - - .something--mod1 .something__child--mod2 { - font-size: 2.5em; - } - - .something--mod1 .something__child--mod2.something__child--submod2 { - font-size: 2.75em; - } - } - } - - @include assert('block and element modifiers, multiple elements') { /// 15 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-modifier('mod1') { - font-size: 1.5em; - - @include iro-bem-modifier('submod') { - font-size: 1.75em; - } - - @include iro-bem-element('child1', 'child2') { - @include iro-bem-modifier('mod2') { - font-size: 2.5em; - - @include iro-bem-modifier('submod2') { - font-size: 2.75em; - } - } - } - } - } - } - - @include expect { - .something--mod1 { - font-size: 1.5em; - } - - .something--mod1.something--submod1 { - font-size: 1.75em; - } - - .something--mod1 .something__child1--mod2, - .something--mod1 .something__child2--mod2 { - font-size: 2.5em; - } - - .something--mod1 .something__child1--mod2.something__child1--submod2, - .something--mod1 .something__child2--mod2.something__child2--submod2 { - font-size: 2.75em; - } - } - } -} diff --git a/test/bem/_iro-bem-multi.scss b/test/bem/_iro-bem-multi.scss deleted file mode 100644 index 84bbca2..0000000 --- a/test/bem/_iro-bem-multi.scss +++ /dev/null @@ -1,591 +0,0 @@ -// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations - -// -// Included test cases: -// - /// 1 /// - in root, 2 blocks -// - /// 2 /// - in root, 1 block, 1 manual selector -// - /// 3 /// - in block, 2 elements -// - /// 4 /// - in block, 1 element, 1 modifier -// - /// 5 /// - in block, 1 element, 1 extending modifier -// - /// 6 /// - in block, 1 element, 1 & selector -// - /// 7 /// - in block, 1 element, 1 manual selector -// - /// 8 /// - in element, 2 elements, 1 modifier -// - /// 9 /// - in element, 1 element, 1 & selector -// - /// 10 /// - in element in manual selector, 2 elements -// - /// 11 /// - in element in manual selector, 1 element, 1 & selector -// - /// 12 /// - in multiple elements, 2 elements, 1 modifier -// - /// 13 /// - in multiple elements, 1 element, 1 & selector -// - /// 14 /// - in related elements, 2 elements, 1 modifier -// - /// 15 /// - in related elements, 1 element, 1 & selector -// - /// 16 /// - in element, 2 related elements, 1 modifier -// - /// 17 /// - in element, 1 twin element, 1 modifier -// - /// 18 /// - in multiple elements, 1 twin element, 1 modifier -// - -@include it('iro-bem-state') { - @include assert('in root, 2 blocks') { /// 1 /// - @include output { - @include iro-bem-multi('component:' 'block1', 'object:' 'block2') { - font-size: 1em; - - @include iro-bem-element('child2') { - font-size: 2em; - } - } - } - - @include expect { - .c-block1 { - font-size: 1em; - } - - .c-block1__child2 { - font-size: 2em; - } - - .o-block2 { - font-size: 1em; - } - - .o-block2__child2 { - font-size: 2em; - } - } - } - - @include assert('in root, 1 block, 1 manual selector') { /// 2 /// - @include output { - @include iro-bem-multi('component:' 'block1', 'a:hover') { - font-size: 1em; - } - } - - @include expect { - .c-block1 { - font-size: 1em; - } - - a:hover { - font-size: 1em; - } - } - } - - @include assert('in block, 2 elements') { /// 3 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-multi('element:' 'child1' 'child2') { - font-size: 2em; - - @include iro-bem-modifier('mod') { - font-size: 2.5em; - } - } - } - } - - @include expect { - .something__child1, - .something__child2 { - font-size: 2em; - } - - .something__child1--mod, - .something__child2--mod { - font-size: 2.5em; - } - } - } - - @include assert('in block, 1 element, 1 modifier') { /// 4 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-multi('element:' 'child', 'modifier:' 'mod1') { - font-size: 2em; - - @include iro-bem-modifier('mod2') { - font-size: 2.5em; - } - } - } - } - - @include expect { - .something__child { - font-size: 2em; - } - - .something__child--mod2 { - font-size: 2.5em; - } - - .something--mod1 { - font-size: 2em; - } - - .something--mod1.something--mod2 { - font-size: 2.5em; - } - } - } - - @include assert('in block, 1 element, 1 extending modifier') { /// 5 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-multi('element:' 'child', 'modifier:' 'mod1') { - font-size: 2em; - - @include iro-bem-modifier('mod2' true) { - font-size: 2.5em; - } - } - } - } - - @include expect { - .something__child { - font-size: 2em; - } - - .something__child--mod2 { - font-size: 2.5em; - } - - .something--mod1 { - font-size: 2em; - } - - .something--mod1--mod2 { - font-size: 2.5em; - } - } - } - - @include assert('in block, 1 element, 1 & selector') { /// 6 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-multi('&', 'element:' 'child') { - font-size: 2em; - - @include iro-bem-modifier('mod') { - font-size: 2.5em; - } - } - } - } - - @include expect { - .something { - font-size: 2em; - } - - .something--mod { - font-size: 2.5em; - } - - .something__child { - font-size: 2em; - } - - .something__child--mod { - font-size: 2.5em; - } - } - } - - @include assert('in block, 1 element, 1 manual selector') { /// 7 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-multi('> a:hover', 'element:' 'child1') { - font-size: 2em; - - @include iro-bem-element('child2') { - font-size: 3em; - } - } - } - } - - @include expect { - .something > a:hover { - font-size: 2em; - } - - .something > a:hover .something__child2 { - font-size: 3em; - } - - .something__child1 { - font-size: 2em; - } - - .something__child1 .something__child2 { - font-size: 3em; - } - } - } - - @include assert('in element, 2 elements, 1 modifier') { /// 8 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - @include iro-bem-multi('element:' 'subchild1' 'subchild2', 'modifier:' 'mod1') { - font-size: 3em; - - @include iro-bem-modifier('mod2') { - font-size: 3.5em; - } - } - } - } - } - - @include expect { - .something__child .something__subchild1, - .something__child .something__subchild2 { - font-size: 3em; - } - - .something__child .something__subchild1--mod2, - .something__child .something__subchild2--mod2 { - font-size: 3.5em; - } - - .something__child--mod1 { - font-size: 3em; - } - - .something__child--mod1.something__child--mod2 { - font-size: 3.5em; - } - } - } - - @include assert('in element, 1 element, 1 & selector') { /// 9 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - @include iro-bem-multi('element:' 'subchild', '&') { - font-size: 3em; - - @include iro-bem-modifier('mod') { - font-size: 3.5em; - } - } - } - } - } - - @include expect { - .something__child .something__subchild { - font-size: 3em; - } - - .something__child .something__subchild--mod { - font-size: 3.5em; - } - - .something__child { - font-size: 3em; - } - - .something__child--mod { - font-size: 3.5em; - } - } - } - - @include assert('in element in manual selector, 2 elements') { /// 10 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - &:hover { - @include iro-bem-multi('element:' 'subchild1' 'subchild2') { - font-size: 3em; - - @include iro-bem-modifier('mod2') { - font-size: 3.5em; - } - } - } - } - } - } - - @include expect { - .something__child:hover .something__subchild1, - .something__child:hover .something__subchild2 { - font-size: 3em; - } - - .something__child:hover .something__subchild1--mod2, - .something__child:hover .something__subchild2--mod2 { - font-size: 3.5em; - } - } - } - - @include assert('in element in manual selector, 1 element, 1 & selector') { /// 11 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - &:hover { - @include iro-bem-multi('element:' 'subchild', '&') { - font-size: 3em; - } - } - } - } - } - - @include expect { - .something__child:hover .something__subchild { - font-size: 3em; - } - - .something__child:hover { - font-size: 3em; - } - } - } - - @include assert('in multiple elements, 2 elements, 1 modifier') { /// 12 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - @include iro-bem-multi('element:' 'subchild1' 'subchild2', 'modifier:' 'mod') { - font-size: 3em; - } - } - } - } - - @include expect { - .something__child1 .something__subchild1, - .something__child2 .something__subchild1, - .something__child1 .something__subchild2, - .something__child2 .something__subchild2 { - font-size: 3em; - } - - .something__child1--mod, - .something__child2--mod { - font-size: 3em; - } - } - } - - @include assert('in multiple elements, 1 element, 1 & selector') { /// 13 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - @include iro-bem-multi('element:' 'subchild', '&') { - font-size: 3em; - - @include iro-bem-modifier('mod') { - font-size: 3.5em; - } - } - } - } - } - - @include expect { - .something__child1 .something__subchild, - .something__child2 .something__subchild { - font-size: 3em; - } - - .something__child1 .something__subchild--mod, - .something__child2 .something__subchild--mod { - font-size: 3.5em; - } - - .something__child1, - .something__child2 { - font-size: 3em; - } - - .something__child1--mod, - .something__child2--mod { - font-size: 3.5em; - } - } - } - - @include assert('in related elements, 2 elements, 1 modifier') { /// 14 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1') { - @include iro-bem-next-element('child2', 'child3') { - @include iro-bem-multi('element:' 'subchild1' 'subchild2', 'modifier:' 'mod') { - font-size: 3em; - } - } - } - } - } - - @include expect { - .something__child1 + .something__child2 .something__subchild1, - .something__child1 + .something__child3 .something__subchild1, - .something__child1 + .something__child2 .something__subchild2, - .something__child1 + .something__child3 .something__subchild2 { - font-size: 3em; - } - - .something__child1 + .something__child2--mod, - .something__child1 + .something__child3--mod { - font-size: 3em; - } - } - } - - @include assert('in related elements, 1 element, 1 & selector') { /// 15 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1') { - @include iro-bem-next-element('child2', 'child3') { - @include iro-bem-multi('element:' 'subchild', '&') { - font-size: 4em; - - @include iro-bem-modifier('mod') { - font-size: 4.5em; - } - } - } - } - } - } - - @include expect { - .something__child1 + .something__child2 .something__subchild, - .something__child1 + .something__child3 .something__subchild { - font-size: 4em; - } - - .something__child1 + .something__child2 .something__subchild--mod, - .something__child1 + .something__child3 .something__subchild--mod { - font-size: 4.5em; - } - - .something__child1 + .something__child2, - .something__child1 + .something__child3 { - font-size: 4em; - } - - .something__child1 + .something__child2--mod, - .something__child1 + .something__child3--mod { - font-size: 4.5em; - } - } - } - - @include assert('in element, 2 related elements, 1 modifier') { /// 16 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1') { - @include iro-bem-multi('next-element:' 'child2' 'child3', 'modifier:' 'mod1') { - font-size: 3em; - - @include iro-bem-modifier('mod2') { - font-size: 3.5em; - } - } - } - } - } - - @include expect { - .something__child1 + .something__child2, - .something__child1 + .something__child3 { - font-size: 3em; - } - - .something__child1 + .something__child2--mod2, - .something__child1 + .something__child3--mod2 { - font-size: 3.5em; - } - - .something__child1--mod1 { - font-size: 3em; - } - - .something__child1--mod1.something__child1--mod2 { - font-size: 3.5em; - } - } - } - - @include assert('in element, 1 twin element, 1 modifier') { /// 17 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - @include iro-bem-multi('next-twin-element', 'modifier:' 'mod1') { - font-size: 3em; - - @include iro-bem-modifier('mod2') { - font-size: 3.5em; - } - } - } - } - } - - @include expect { - .something__child + .something__child { - font-size: 3em; - } - - .something__child + .something__child--mod2 { - font-size: 3.5em; - } - - .something__child--mod1 { - font-size: 3em; - } - - .something__child--mod1.something__child--mod2 { - font-size: 3.5em; - } - } - } - - @include assert('in multiple elements, 1 twin element, 1 modifier') { /// 18 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - @include iro-bem-multi('next-twin-element', 'modifier:' 'mod1') { - font-size: 3em; - - @include iro-bem-modifier('mod2') { - font-size: 3.5em; - } - } - } - } - } - - @include expect { - .something__child1 + .something__child1, - .something__child2 + .something__child2 { - font-size: 3em; - } - - .something__child1 + .something__child1--mod2, - .something__child2 + .something__child2--mod2 { - font-size: 3.5em; - } - - .something__child1--mod1, - .something__child2--mod1 { - font-size: 3em; - } - - .something__child1--mod1.something__child1--mod2, - .something__child2--mod1.something__child2--mod2 { - font-size: 3.5em; - } - } - } -} diff --git a/test/bem/_iro-bem-next-twin-element.scss b/test/bem/_iro-bem-next-twin-element.scss deleted file mode 100644 index 96fc3a9..0000000 --- a/test/bem/_iro-bem-next-twin-element.scss +++ /dev/null @@ -1,153 +0,0 @@ -// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations - -// -// Included test cases: -// - /// 1 /// - single element -// - /// 2 /// - single element, manual selector in-between -// - /// 3 /// - single element, modifier in-between -// - /// 4 /// - multiple elements -// - /// 5 /// - multiple elements, manual selector in-between -// - /// 6 /// - multiple elements, modifier in-between -// - -@include it('iro-bem-next-twin-element') { - @include assert('single element') { /// 1 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - @include iro-bem-next-twin-element { - font-size: 2em; - } - } - } - } - - @include expect { - .something__child + .something__child { - font-size: 2em; - } - } - } - - @include assert('single element, manual selector in-between') { /// 2 /// - @include output(false) { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - &:hover { - @include iro-bem-next-twin-element { - font-size: 2em; - } - } - - .test & { - @include iro-bem-next-twin-element { - font-size: 2em; - } - } - } - } - } - - @include expect(false) { - .something__child:hover + .something__child { - font-size: 2em; - } - - .test .something__child + .something__child { - font-size: 2em; - } - } - } - - @include assert('single element, modifier in-between') { /// 3 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - @include iro-bem-modifier('mod') { - @include iro-bem-next-twin-element { - font-size: 2.5em; - } - } - } - } - } - - @include expect { - .something__child--mod + .something__child { - font-size: 2.5em; - } - } - } - - @include assert('multiple elements') { /// 4 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - @include iro-bem-next-twin-element { - font-size: 2em; - } - } - } - } - - @include expect { - .something__child1 + .something__child1, - .something__child2 + .something__child2 { - font-size: 2em; - } - } - } - - @include assert('multiple elements, manual selector in-between') { /// 5 /// - @include output(false) { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - &:hover { - @include iro-bem-next-twin-element { - font-size: 2em; - } - } - - .test & { - @include iro-bem-next-twin-element { - font-size: 2em; - } - } - } - } - } - - @include expect(false) { - .something__child1:hover + .something__child1, - .something__child2:hover + .something__child2 { - font-size: 2em; - } - - .test .something__child1 + .something__child1, - .test .something__child2 + .something__child2 { - font-size: 2em; - } - } - } - - @include assert('multiple elements, modifier in-between') { /// 6 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - @include iro-bem-modifier('mod') { - @include iro-bem-next-twin-element { - font-size: 2.5em; - } - } - } - } - } - - @include expect { - .something__child1--mod + .something__child1, - .something__child2--mod + .something__child2 { - font-size: 2.5em; - } - } - } -} diff --git a/test/bem/_iro-bem-related-element.scss b/test/bem/_iro-bem-related-element.scss deleted file mode 100644 index b0c6b94..0000000 --- a/test/bem/_iro-bem-related-element.scss +++ /dev/null @@ -1,459 +0,0 @@ -// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations - -// -// Included test cases: -// - /// 1 /// - single element, single related element -// - /// 2 /// - single element, single related element, manual selector in-between -// - /// 3 /// - single element, single related element, modifier in-between -// - /// 4 /// - single element, multiple related elements -// - /// 5 /// - single element, multiple related elements, manual selector in-between -// - /// 6 /// - single element, multiple related elements, modifier in-between -// - /// 7 /// - multiple elements, single related element -// - /// 8 /// - multiple elements, single related element, manual selector in-between -// - /// 9 /// - multiple elements, single related element, modifier in-between -// - /// 10 /// - multiple elements, multiple related elements -// - /// 11 /// - multiple elements, multiple related elements, manual selector in-between -// - /// 12 /// - multiple elements, multiple related elements, modifier in-between -// - -@include it('iro-bem-related-element') { - @include assert('single element, single related element') { /// 1 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - @include iro-bem-related-element('+', 'subchild1') { - font-size: 2em; - } - - @include iro-bem-related-element('~', 'subchild2') { - font-size: 2em; - } - } - } - } - - @include expect { - .something__child + .something__subchild1 { - font-size: 2em; - } - - .something__child ~ .something__subchild2 { - font-size: 2em; - } - } - } - - @include assert('single element, single related element, manual selector in-between') { /// 2 /// - @include output(false) { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - &:hover { - @include iro-bem-related-element('+', 'subchild1') { - font-size: 2em; - } - - @include iro-bem-related-element('~', 'subchild2') { - font-size: 2em; - } - } - - .test & { - @include iro-bem-related-element('+', 'subchild3') { - font-size: 2em; - } - - @include iro-bem-related-element('~', 'subchild4') { - font-size: 2em; - } - } - } - } - } - - @include expect(false) { - .something__child:hover + .something__subchild1 { - font-size: 2em; - } - - .something__child:hover ~ .something__subchild2 { - font-size: 2em; - } - - .test .something__child + .something__subchild3 { - font-size: 2em; - } - - .test .something__child ~ .something__subchild4 { - font-size: 2em; - } - } - } - - @include assert('single element, single related element, modifier in-between') { /// 3 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - @include iro-bem-modifier('mod') { - @include iro-bem-related-element('+', 'subchild1') { - font-size: 2.5em; - } - - @include iro-bem-related-element('~', 'subchild2') { - font-size: 2.5em; - } - } - } - } - } - - @include expect { - .something__child--mod + .something__subchild1 { - font-size: 2.5em; - } - - .something__child--mod ~ .something__subchild2 { - font-size: 2.5em; - } - } - } - - @include assert('single element, multiple related elements') { /// 4 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - @include iro-bem-related-element('+', 'subchild1', 'subchild2') { - font-size: 2.5em; - } - - @include iro-bem-related-element('~', 'subchild3', 'subchild4') { - font-size: 2.5em; - } - } - } - } - - @include expect { - .something__child + .something__subchild1, - .something__child + .something__subchild2 { - font-size: 2.5em; - } - - .something__child ~ .something__subchild3, - .something__child ~ .something__subchild4 { - font-size: 2.5em; - } - } - } - - @include assert('single element, multiple related elements, manual selector in-between') { /// 5 /// - @include output(false) { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - &:hover { - @include iro-bem-related-element('+', 'subchild1', 'subchild2') { - font-size: 2.5em; - } - - @include iro-bem-related-element('~', 'subchild3', 'subchild4') { - font-size: 2.5em; - } - } - - .test & { - @include iro-bem-related-element('+', 'subchild5', 'subchild6') { - font-size: 2.5em; - } - - @include iro-bem-related-element('~', 'subchild7', 'subchild8') { - font-size: 2.5em; - } - } - } - } - } - - @include expect(false) { - .something__child:hover + .something__subchild1, - .something__child:hover + .something__subchild2 { - font-size: 2.5em; - } - - .something__child:hover ~ .something__subchild3, - .something__child:hover ~ .something__subchild4 { - font-size: 2.5em; - } - - .test .something__child + .something__subchild5, - .test .something__child + .something__subchild6 { - font-size: 2.5em; - } - - .test .something__child ~ .something__subchild7, - .test .something__child ~ .something__subchild8 { - font-size: 2.5em; - } - } - } - - @include assert('single element, multiple related elements, modifier in-between') { /// 6 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - @include iro-bem-modifier('mod') { - @include iro-bem-related-element('+', 'subchild1', 'subchild2') { - font-size: 2.5em; - } - - @include iro-bem-related-element('~', 'subchild3', 'subchild4') { - font-size: 2.5em; - } - } - } - } - } - - @include expect { - .something__child--mod + .something__subchild1, - .something__child--mod + .something__subchild2 { - font-size: 2.5em; - } - - .something__child--mod ~ .something__subchild3, - .something__child--mod ~ .something__subchild4 { - font-size: 2.5em; - } - } - } - - @include assert('multiple elements, single related element') { /// 7 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - @include iro-bem-related-element('+', 'subchild1') { - font-size: 2em; - } - - @include iro-bem-related-element('~', 'subchild2') { - font-size: 2em; - } - } - } - } - - @include expect { - .something__child1 + .something__subchild1, - .something__child2 + .something__subchild1 { - font-size: 2em; - } - - .something__child1 ~ .something__subchild2, - .something__child2 ~ .something__subchild2 { - font-size: 2em; - } - } - } - - @include assert('multiple elements, single related element, manual selector in-between') { /// 8 /// - @include output(false) { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - &:hover { - @include iro-bem-related-element('+', 'subchild1') { - font-size: 2em; - } - - @include iro-bem-related-element('~', 'subchild2') { - font-size: 2em; - } - } - - .test & { - @include iro-bem-related-element('+', 'subchild3') { - font-size: 2em; - } - - @include iro-bem-related-element('~', 'subchild4') { - font-size: 2em; - } - } - } - } - } - - @include expect(false) { - .something__child1:hover + .something__subchild1, - .something__child2:hover + .something__subchild1 { - font-size: 2em; - } - - .something__child1:hover ~ .something__subchild2, - .something__child2:hover ~ .something__subchild2 { - font-size: 2em; - } - - .test .something__child1 + .something__subchild3, - .test .something__child2 + .something__subchild3 { - font-size: 2em; - } - - .test .something__child1 ~ .something__subchild4, - .test .something__child2 ~ .something__subchild4 { - font-size: 2em; - } - } - } - - @include assert('multiple elements, single related element, modifier in-between') { /// 9 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - @include iro-bem-modifier('mod') { - @include iro-bem-related-element('+', 'subchild1') { - font-size: 2.5em; - } - - @include iro-bem-related-element('~', 'subchild2') { - font-size: 2.5em; - } - } - } - } - } - - @include expect { - .something__child1--mod + .something__subchild1, - .something__child2--mod + .something__subchild1 { - font-size: 2.5em; - } - - .something__child1--mod ~ .something__subchild2, - .something__child2--mod ~ .something__subchild2 { - font-size: 2.5em; - } - } - } - - @include assert('multiple elements, multiple related elements') { /// 10 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - @include iro-bem-related-element('+', 'subchild1', 'subchild2') { - font-size: 2em; - } - - @include iro-bem-related-element('~', 'subchild3', 'subchild4') { - font-size: 2em; - } - } - } - } - - @include expect { - .something__child1 + .something__subchild1, - .something__child2 + .something__subchild1, - .something__child1 + .something__subchild2, - .something__child2 + .something__subchild2 { - font-size: 2em; - } - - .something__child1 ~ .something__subchild3, - .something__child2 ~ .something__subchild3, - .something__child1 ~ .something__subchild4, - .something__child2 ~ .something__subchild4 { - font-size: 2em; - } - } - } - - @include assert('multiple elements, multiple related elements, manual selector in-between') { /// 11 /// - @include output(false) { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - &:hover { - @include iro-bem-related-element('+', 'subchild1', 'subchild2') { - font-size: 2em; - } - - @include iro-bem-related-element('~', 'subchild3', 'subchild4') { - font-size: 2em; - } - } - - .test & { - @include iro-bem-related-element('+', 'subchild5', 'subchild6') { - font-size: 2em; - } - - @include iro-bem-related-element('~', 'subchild7', 'subchild8') { - font-size: 2em; - } - } - } - } - } - - @include expect(false) { - .something__child1:hover + .something__subchild1, - .something__child2:hover + .something__subchild1, - .something__child1:hover + .something__subchild2, - .something__child2:hover + .something__subchild2 { - font-size: 2em; - } - - .something__child1:hover ~ .something__subchild3, - .something__child2:hover ~ .something__subchild3, - .something__child1:hover ~ .something__subchild4, - .something__child2:hover ~ .something__subchild4 { - font-size: 2em; - } - - .test .something__child1 + .something__subchild5, - .test .something__child2 + .something__subchild5, - .test .something__child1 + .something__subchild6, - .test .something__child2 + .something__subchild6 { - font-size: 2em; - } - - .test .something__child1 ~ .something__subchild7, - .test .something__child2 ~ .something__subchild7, - .test .something__child1 ~ .something__subchild8, - .test .something__child2 ~ .something__subchild8 { - font-size: 2em; - } - } - } - - @include assert('multiple elements, multiple related elements, modifier in-between') { /// 12 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - @include iro-bem-modifier('mod') { - @include iro-bem-related-element('+', 'subchild1', 'subchild2') { - font-size: 2em; - } - - @include iro-bem-related-element('~', 'subchild3', 'subchild4') { - font-size: 2em; - } - } - } - } - } - - @include expect { - .something__child1--mod + .something__subchild1, - .something__child2--mod + .something__subchild1, - .something__child1--mod + .something__subchild2, - .something__child2--mod + .something__subchild2 { - font-size: 2em; - } - - .something__child1--mod ~ .something__subchild3, - .something__child2--mod ~ .something__subchild3, - .something__child1--mod ~ .something__subchild4, - .something__child2--mod ~ .something__subchild4 { - font-size: 2em; - } - } - } -} diff --git a/test/bem/_iro-bem-state.scss b/test/bem/_iro-bem-state.scss deleted file mode 100644 index 57eb233..0000000 --- a/test/bem/_iro-bem-state.scss +++ /dev/null @@ -1,177 +0,0 @@ -// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations - -// -// Included test cases: -// - /// 1 /// - single block, single state -// - /// 2 /// - single element, single state -// - /// 3 /// - single block, multiple states -// - /// 4 /// - single element, multiple states -// - /// 5 /// - multiple elements, single state -// - /// 6 /// - multiple elements, multiple states -// - -@include it('iro-bem-state') { - @include assert('single block, single state') { /// 1 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-is('active') { - font-size: 1.25em; - } - - @include iro-bem-has('state') { - font-size: 1.75em; - } - } - } - - @include expect { - .something.is-active { - font-size: 1.25em; - } - - .something.has-state { - font-size: 1.75em; - } - } - } - - @include assert('single element, single state') { /// 2 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - @include iro-bem-is('active') { - font-size: 2.25em; - } - - @include iro-bem-has('state') { - font-size: 2.75em; - } - } - } - } - - @include expect { - .something__child.is-active { - font-size: 2.25em; - } - - .something__child.has-state { - font-size: 2.75em; - } - } - } - - @include assert('single block, multiple states') { /// 3 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-is('active', 'primary') { - font-size: 1.25em; - } - - @include iro-bem-has('state', 'indicator') { - font-size: 1.75em; - } - } - } - - @include expect { - .something.is-active, - .something.is-primary { - font-size: 1.25em; - } - - .something.has-state, - .something.has-indicator { - font-size: 1.75em; - } - } - } - - @include assert('single element, multiple states') { /// 4 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - @include iro-bem-is('active', 'primary') { - font-size: 2.25em; - } - - @include iro-bem-has('state', 'indicator') { - font-size: 2.75em; - } - } - } - } - - @include expect { - .something__child.is-active, - .something__child.is-primary { - font-size: 2.25em; - } - - .something__child.has-state, - .something__child.has-indicator { - font-size: 2.75em; - } - } - } - - @include assert('multiple elements, single state') { /// 5 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - @include iro-bem-is('active') { - font-size: 2.25em; - } - - @include iro-bem-has('state') { - font-size: 2.75em; - } - } - } - } - - @include expect { - .something__child1.is-active, - .something__child2.is-active { - font-size: 2.25em; - } - - .something__child1.has-state, - .something__child2.has-state { - font-size: 2.75em; - } - } - } - - @include assert('multiple elements, multiple states') { /// 6 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - @include iro-bem-is('active', 'primary') { - font-size: 2.25em; - } - - @include iro-bem-has('state', 'indicator') { - font-size: 2.75em; - } - } - } - } - - @include expect { - .something__child1.is-active, - .something__child2.is-active, - .something__child1.is-primary, - .something__child2.is-primary { - font-size: 2.25em; - } - - .something__child1.has-state, - .something__child2.has-state, - .something__child1.has-indicator, - .something__child2.has-indicator { - font-size: 2.75em; - } - } - } -} diff --git a/test/bem/_iro-bem-suffix.scss b/test/bem/_iro-bem-suffix.scss deleted file mode 100644 index c6ca787..0000000 --- a/test/bem/_iro-bem-suffix.scss +++ /dev/null @@ -1,94 +0,0 @@ -// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations - -// -// Included test cases: -// - /// 1 /// - block suffix -// - /// 2 /// - element suffix -// - /// 3 /// - modifier suffix -// - /// 4 /// - multiple element suffix -// - -@include it('iro-bem-suffix') { - @include assert('block suffix') { /// 1 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-suffix('sm') { - font-size: 1.5em; - } - } - } - - @include expect { - .something\@sm { - font-size: 1.5em; - } - } - } - - @include assert('element suffix') { /// 2 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child') { - @include iro-bem-suffix('sm') { - font-size: 2.5em; - } - } - } - } - - @include expect { - .something__child\@sm { - font-size: 2.5em; - } - } - } - - @include assert('modifier suffix') { /// 3 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-modifier('mod1') { - @include iro-bem-suffix('sm') { - font-size: 1.75em; - } - } - - @include iro-bem-element('child') { - @include iro-bem-modifier('mod2') { - @include iro-bem-suffix('sm') { - font-size: 2.75em; - } - } - } - } - } - - @include expect { - .something--mod1\@sm { - font-size: 1.75em; - } - - .something__child--mod2\@sm { - font-size: 2.75em; - } - } - } - - @include assert('multiple element suffix') { /// 4 /// - @include output { - @include iro-bem-block('something') { - @include iro-bem-element('child1', 'child2') { - @include iro-bem-suffix('sm') { - font-size: 2.5em; - } - } - } - } - - @include expect { - .something__child1\@sm, - .something__child2\@sm { - font-size: 2.5em; - } - } - } -} diff --git a/test/bem/_modifier.scss b/test/bem/_modifier.scss new file mode 100644 index 0000000..934efa3 --- /dev/null +++ b/test/bem/_modifier.scss @@ -0,0 +1,655 @@ +// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations + +@use 'true' as *; +@use '../../src/bem'; + +// +// Included test cases: +// - /// 1 /// - block modifier +// - /// 2 /// - block modifier, in at-theme +// - /// 3 /// - element modifier, single element +// - /// 4 /// - element modifier, multiple elements +// - /// 5 /// - element modifier, single related element +// - /// 6 /// - element modifier, multiple related elements +// - /// 7 /// - element modifier, single element, manual selector before +// - /// 8 /// - element modifier, multiple elements, manual selector before +// - /// 9 /// - element modifier, single related element, manual selector before +// - /// 10 /// - element modifier, multiple related elements, manual selector before +// - /// 11 /// - element modifier, in at-theme +// - /// 12 /// - nested block modifiers, extending +// - /// 13 /// - nested element modifiers, extending +// - /// 14 /// - block and element modifiers, single element +// - /// 15 /// - block and element modifiers, multiple elements +// + +@include it('modifier') { + @include assert('block modifier') { /// 1 /// + @include output { + @include bem.block('something') { + @include bem.modifier('mod') { + font-size: 1.5em; + + @include bem.modifier('submod') { + font-size: 1.75em; + } + } + } + } + + @include expect { + .something--mod { + font-size: 1.5em; + } + + .something--mod.something--submod { + font-size: 1.75em; + } + } + } + + @include assert('block modifier, in at-theme') { /// 2 /// + @include output(false) { + @include bem.block('something') { + @include bem.at-theme('dark') { + @include bem.modifier('mod') { + font-size: 1.5em; + + @include bem.modifier('submod') { + font-size: 1.75em; + } + } + } + } + } + + @include expect(false) { + .t-dark .something--mod, + [class*=' t-'] .t-dark .something--mod, + [class^='t-'] .t-dark .something--mod { + font-size: 1.5em; + } + + .t-dark .something--mod.something--submod, + [class*=' t-'] .t-dark .something--mod.something--submod, + [class^='t-'] .t-dark .something--mod.something--submod { + font-size: 1.75em; + } + } + } + + @include assert('element modifier, single element') { /// 3 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + @include bem.modifier('mod') { + font-size: 2.5em; + + @include bem.modifier('submod') { + font-size: 2.75em; + } + } + } + } + } + + @include expect { + .something__child--mod { + font-size: 2.5em; + } + + .something__child--mod.something__child--submod { + font-size: 2.75em; + } + } + } + + @include assert('element modifier, multiple elements') { /// 4 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + @include bem.modifier('mod') { + font-size: 2.5em; + + @include bem.modifier('submod') { + font-size: 2.75em; + } + } + } + } + } + + @include expect { + .something__child1--mod, + .something__child2--mod { + font-size: 2.5em; + } + + .something__child1--mod.something__child1--submod, + .something__child2--mod.something__child2--submod { + font-size: 2.75em; + } + } + } + + @include assert('element modifier, single related element') { /// 5 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1') { + @include bem.next-elem('child2') { + @include bem.modifier('mod') { + font-size: 2.5em; + + @include bem.modifier('submod') { + font-size: 2.75em; + } + } + } + } + } + } + + @include expect { + .something__child1 + .something__child2--mod { + font-size: 2.5em; + } + + .something__child1 + .something__child2--mod.something__child2--submod { + font-size: 2.75em; + } + } + } + + @include assert('element modifier, multiple related elements') { /// 6 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1') { + @include bem.next-elem('child2', 'child3') { + @include bem.modifier('mod') { + font-size: 2.5em; + + @include bem.modifier('submod') { + font-size: 2.75em; + } + } + } + } + } + } + + @include expect { + .something__child1 + .something__child2--mod, + .something__child1 + .something__child3--mod { + font-size: 2.5em; + } + + .something__child1 + .something__child2--mod.something__child2--submod, + .something__child1 + .something__child3--mod.something__child3--submod { + font-size: 2.75em; + } + } + } + + @include assert('element modifier, single element, manual selector before') { /// 7 /// + @include output(false) { + @include bem.block('something') { + &:hover { + @include bem.elem('child1') { + @include bem.modifier('mod') { + font-size: 2.5em; + + @include bem.modifier('submod') { + font-size: 2.75em; + } + } + } + } + + .test & { + @include bem.elem('child2') { + @include bem.modifier('mod') { + font-size: 2.5em; + + @include bem.modifier('submod') { + font-size: 2.75em; + } + } + } + } + } + } + + @include expect(false) { + .something:hover .something__child1--mod { + font-size: 2.5em; + } + + .something:hover .something__child1--mod.something__child1--submod { + font-size: 2.75em; + } + + .test .something__child2--mod { + font-size: 2.5em; + } + + .test .something__child2--mod.something__child2--submod { + font-size: 2.75em; + } + } + } + + @include assert('element modifier, multiple elements, manual selector before') { /// 8 /// + @include output(false) { + @include bem.block('something') { + &:hover { + @include bem.elem('child1', 'child2') { + @include bem.modifier('mod') { + font-size: 2.5em; + + @include bem.modifier('submod') { + font-size: 2.75em; + } + } + } + } + + .test & { + @include bem.elem('child3', 'child4') { + @include bem.modifier('mod') { + font-size: 2.5em; + + @include bem.modifier('submod') { + font-size: 2.75em; + } + } + } + } + } + } + + @include expect(false) { + .something:hover .something__child1--mod, + .something:hover .something__child2--mod { + font-size: 2.5em; + } + + .something:hover .something__child1--mod.something__child1--submod, + .something:hover .something__child2--mod.something__child2--submod { + font-size: 2.75em; + } + + .test .something__child3--mod, + .test .something__child4--mod { + font-size: 2.5em; + } + + .test .something__child3--mod.something__child3--submod, + .test .something__child4--mod.something__child4--submod { + font-size: 2.75em; + } + } + } + + @include assert('element modifier, single related element, manual selector before') { /// 9 /// + @include output(false) { + @include bem.block('something') { + &:hover { + @include bem.elem('child1') { + @include bem.next-elem('child2') { + @include bem.modifier('mod1') { + font-size: 2.5em; + + @include bem.modifier('submod1') { + font-size: 2.75em; + } + } + } + } + } + + .test & { + @include bem.elem('child3') { + @include bem.next-elem('child4') { + @include bem.modifier('mod1') { + font-size: 2.5em; + + @include bem.modifier('submod1') { + font-size: 2.75em; + } + } + } + } + } + + @include bem.elem('child5') { + &:hover { + @include bem.next-elem('child6') { + @include bem.modifier('mod2') { + font-size: 2.5em; + + @include bem.modifier('submod2') { + font-size: 2.75em; + } + } + } + } + + .test & { + @include bem.next-elem('child7') { + @include bem.modifier('mod2') { + font-size: 2.5em; + + @include bem.modifier('submod2') { + font-size: 2.75em; + } + } + } + } + } + } + } + + @include expect(false) { + .something:hover .something__child1 + .something__child2--mod1 { + font-size: 2.5em; + } + + .something:hover .something__child1 + .something__child2--mod1.something__child2--submod1 { + font-size: 2.75em; + } + + .test .something__child3 + .something__child4--mod1 { + font-size: 2.5em; + } + + .test .something__child3 + .something__child4--mod1.something__child4--submod1 { + font-size: 2.75em; + } + + .something__child5:hover + .something__child6--mod2 { + font-size: 2.5em; + } + + .something__child5:hover + .something__child6--mod2.something__child6--submod2 { + font-size: 2.75em; + } + + .test .something__child5 + .something__child7--mod2 { + font-size: 2.5em; + } + + .test .something__child5 + .something__child7--mod2.something__child7--submod2 { + font-size: 2.75em; + } + } + } + + @include assert('element modifier, multiple related elements, manual selector before') { /// 10 /// + @include output(false) { + @include bem.block('something') { + &:hover { + @include bem.elem('child1') { + @include bem.next-elem('child2', 'child3') { + @include bem.modifier('mod1') { + font-size: 2.5em; + + @include bem.modifier('submod1') { + font-size: 2.75em; + } + } + } + } + } + + .test & { + @include bem.elem('child4') { + @include bem.next-elem('child5', 'child6') { + @include bem.modifier('mod1') { + font-size: 2.5em; + + @include bem.modifier('submod1') { + font-size: 2.75em; + } + } + } + } + } + + @include bem.elem('child7') { + &:hover { + @include bem.next-elem('child8', 'child9') { + @include bem.modifier('mod2') { + font-size: 2.5em; + + @include bem.modifier('submod2') { + font-size: 2.75em; + } + } + } + } + + .test & { + @include bem.next-elem('child10', 'child11') { + @include bem.modifier('mod2') { + font-size: 2.5em; + + @include bem.modifier('submod2') { + font-size: 2.75em; + } + } + } + } + } + } + } + + @include expect(false) { + .something:hover .something__child1 + .something__child2--mod1, + .something:hover .something__child1 + .something__child3--mod1 { + font-size: 2.5em; + } + + .something:hover .something__child1 + .something__child2--mod1.something__child2--submod1, + .something:hover .something__child1 + .something__child3--mod1.something__child3--submod1 { + font-size: 2.75em; + } + + .test .something__child4 + .something__child5--mod1, + .test .something__child4 + .something__child6--mod1 { + font-size: 2.5em; + } + + .test .something__child4 + .something__child5--mod1.something__child5--submod1, + .test .something__child4 + .something__child6--mod1.something__child6--submod1 { + font-size: 2.75em; + } + + .something__child7:hover + .something__child8--mod2, + .something__child7:hover + .something__child9--mod2 { + font-size: 2.5em; + } + + .something__child7:hover + .something__child8--mod2.something__child8--submod2, + .something__child7:hover + .something__child9--mod2.something__child9--submod2 { + font-size: 2.75em; + } + + .test .something__child7 + .something__child10--mod2, + .test .something__child7 + .something__child11--mod2 { + font-size: 2.5em; + } + + .test .something__child7 + .something__child10--mod2.something__child10--submod2, + .test .something__child7 + .something__child11--mod2.something__child11--submod2 { + font-size: 2.75em; + } + } + } + + // @include assert('element modifier, in at-theme') { /// 11 /// + // @include output(false) { + // @include bem.block('something') { + // @include bem.at-theme('dark') { + // @include bem.elem('child') { + // @include bem.modifier('mod') { + // font-size: 2.5em; + // + // @include bem.modifier('submod') { + // font-size: 2.75em; + // } + // } + // } + // } + // } + // } + // + // @include expect(false) { + // .t-dark .something__child--mod, + // [class*=' t-'] .t-dark .something__child--mod, + // [class^='t-'] .t-dark .something__child--mod { + // font-size: 2.5em; + // } + // + // .t-dark .something__child--mod.something__child--submod, + // [class*=' t-'] .t-dark .something__child--mod.something__child--submod, + // [class^='t-'] .t-dark .something__child--mod.something__child--submod { + // font-size: 2.75em; + // } + // } + // } + + @include assert('nested block modifiers, extending') { /// 12 /// + @include output { + @include bem.block('something') { + @include bem.modifier('mod') { + font-size: 1.5em; + + @include bem.modifier('submod' true) { + font-size: 1.75em; + } + } + } + } + + @include expect { + .something--mod { + font-size: 1.5em; + } + + .something--mod--submod { + font-size: 1.75em; + } + } + } + + @include assert('nested element modifiers, extending') { /// 13 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + @include bem.modifier('mod') { + font-size: 2.5em; + + @include bem.modifier('submod' true) { + font-size: 2.75em; + } + } + } + } + } + + @include expect { + .something__child--mod { + font-size: 2.5em; + } + + .something__child--mod--submod { + font-size: 2.75em; + } + } + } + + @include assert('block and element modifiers, single element') { /// 14 /// + @include output { + @include bem.block('something') { + @include bem.modifier('mod1') { + font-size: 1.5em; + + @include bem.modifier('submod1') { + font-size: 1.75em; + } + + @include bem.elem('child') { + @include bem.modifier('mod2') { + font-size: 2.5em; + + @include bem.modifier('submod2') { + font-size: 2.75em; + } + } + } + } + } + } + + @include expect { + .something--mod1 { + font-size: 1.5em; + } + + .something--mod1.something--submod1 { + font-size: 1.75em; + } + + .something--mod1 .something__child--mod2 { + font-size: 2.5em; + } + + .something--mod1 .something__child--mod2.something__child--submod2 { + font-size: 2.75em; + } + } + } + + @include assert('block and element modifiers, multiple elements') { /// 15 /// + @include output { + @include bem.block('something') { + @include bem.modifier('mod1') { + font-size: 1.5em; + + @include bem.modifier('submod1') { + font-size: 1.75em; + } + + @include bem.elem('child1', 'child2') { + @include bem.modifier('mod2') { + font-size: 2.5em; + + @include bem.modifier('submod2') { + font-size: 2.75em; + } + } + } + } + } + } + + @include expect { + .something--mod1 { + font-size: 1.5em; + } + + .something--mod1.something--submod1 { + font-size: 1.75em; + } + + .something--mod1 .something__child1--mod2, + .something--mod1 .something__child2--mod2 { + font-size: 2.5em; + } + + .something--mod1 .something__child1--mod2.something__child1--submod2, + .something--mod1 .something__child2--mod2.something__child2--submod2 { + font-size: 2.75em; + } + } + } +} diff --git a/test/bem/_multi.scss b/test/bem/_multi.scss new file mode 100644 index 0000000..255fb45 --- /dev/null +++ b/test/bem/_multi.scss @@ -0,0 +1,594 @@ +// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations + +@use 'true' as *; +@use '../../src/bem'; + +// +// Included test cases: +// - /// 1 /// - in root, 2 blocks +// - /// 2 /// - in root, 1 block, 1 manual selector +// - /// 3 /// - in block, 2 elements +// - /// 4 /// - in block, 1 element, 1 modifier +// - /// 5 /// - in block, 1 element, 1 extending modifier +// - /// 6 /// - in block, 1 element, 1 & selector +// - /// 7 /// - in block, 1 element, 1 manual selector +// - /// 8 /// - in element, 2 elements, 1 modifier +// - /// 9 /// - in element, 1 element, 1 & selector +// - /// 10 /// - in element in manual selector, 2 elements +// - /// 11 /// - in element in manual selector, 1 element, 1 & selector +// - /// 12 /// - in multiple elements, 2 elements, 1 modifier +// - /// 13 /// - in multiple elements, 1 element, 1 & selector +// - /// 14 /// - in related elements, 2 elements, 1 modifier +// - /// 15 /// - in related elements, 1 element, 1 & selector +// - /// 16 /// - in element, 2 related elements, 1 modifier +// - /// 17 /// - in element, 1 twin element, 1 modifier +// - /// 18 /// - in multiple elements, 1 twin element, 1 modifier +// + +@include it('multi') { + @include assert('in root, 2 blocks') { /// 1 /// + @include output { + @include bem.multi('component:' 'block1', 'object:' 'block2') { + font-size: 1em; + + @include bem.elem('child2') { + font-size: 2em; + } + } + } + + @include expect { + .c-block1 { + font-size: 1em; + } + + .c-block1__child2 { + font-size: 2em; + } + + .o-block2 { + font-size: 1em; + } + + .o-block2__child2 { + font-size: 2em; + } + } + } + + @include assert('in root, 1 block, 1 manual selector') { /// 2 /// + @include output { + @include bem.multi('component:' 'block1', 'a:hover') { + font-size: 1em; + } + } + + @include expect { + .c-block1 { + font-size: 1em; + } + + a:hover { + font-size: 1em; + } + } + } + + @include assert('in block, 2 elements') { /// 3 /// + @include output { + @include bem.block('something') { + @include bem.multi('elem:' 'child1' 'child2') { + font-size: 2em; + + @include bem.modifier('mod') { + font-size: 2.5em; + } + } + } + } + + @include expect { + .something__child1, + .something__child2 { + font-size: 2em; + } + + .something__child1--mod, + .something__child2--mod { + font-size: 2.5em; + } + } + } + + @include assert('in block, 1 element, 1 modifier') { /// 4 /// + @include output { + @include bem.block('something') { + @include bem.multi('elem:' 'child', 'modifier:' 'mod1') { + font-size: 2em; + + @include bem.modifier('mod2') { + font-size: 2.5em; + } + } + } + } + + @include expect { + .something__child { + font-size: 2em; + } + + .something__child--mod2 { + font-size: 2.5em; + } + + .something--mod1 { + font-size: 2em; + } + + .something--mod1.something--mod2 { + font-size: 2.5em; + } + } + } + + @include assert('in block, 1 element, 1 extending modifier') { /// 5 /// + @include output { + @include bem.block('something') { + @include bem.multi('elem:' 'child', 'modifier:' 'mod1') { + font-size: 2em; + + @include bem.modifier('mod2' true) { + font-size: 2.5em; + } + } + } + } + + @include expect { + .something__child { + font-size: 2em; + } + + .something__child--mod2 { + font-size: 2.5em; + } + + .something--mod1 { + font-size: 2em; + } + + .something--mod1--mod2 { + font-size: 2.5em; + } + } + } + + @include assert('in block, 1 element, 1 & selector') { /// 6 /// + @include output { + @include bem.block('something') { + @include bem.multi('&', 'elem:' 'child') { + font-size: 2em; + + @include bem.modifier('mod') { + font-size: 2.5em; + } + } + } + } + + @include expect { + .something { + font-size: 2em; + } + + .something--mod { + font-size: 2.5em; + } + + .something__child { + font-size: 2em; + } + + .something__child--mod { + font-size: 2.5em; + } + } + } + + @include assert('in block, 1 element, 1 manual selector') { /// 7 /// + @include output { + @include bem.block('something') { + @include bem.multi('> a:hover', 'elem:' 'child1') { + font-size: 2em; + + @include bem.elem('child2') { + font-size: 3em; + } + } + } + } + + @include expect { + .something > a:hover { + font-size: 2em; + } + + .something > a:hover .something__child2 { + font-size: 3em; + } + + .something__child1 { + font-size: 2em; + } + + .something__child1 .something__child2 { + font-size: 3em; + } + } + } + + @include assert('in element, 2 elements, 1 modifier') { /// 8 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + @include bem.multi('elem:' 'subchild1' 'subchild2', 'modifier:' 'mod1') { + font-size: 3em; + + @include bem.modifier('mod2') { + font-size: 3.5em; + } + } + } + } + } + + @include expect { + .something__child .something__subchild1, + .something__child .something__subchild2 { + font-size: 3em; + } + + .something__child .something__subchild1--mod2, + .something__child .something__subchild2--mod2 { + font-size: 3.5em; + } + + .something__child--mod1 { + font-size: 3em; + } + + .something__child--mod1.something__child--mod2 { + font-size: 3.5em; + } + } + } + + @include assert('in element, 1 element, 1 & selector') { /// 9 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + @include bem.multi('elem:' 'subchild', '&') { + font-size: 3em; + + @include bem.modifier('mod') { + font-size: 3.5em; + } + } + } + } + } + + @include expect { + .something__child .something__subchild { + font-size: 3em; + } + + .something__child .something__subchild--mod { + font-size: 3.5em; + } + + .something__child { + font-size: 3em; + } + + .something__child--mod { + font-size: 3.5em; + } + } + } + + @include assert('in element in manual selector, 2 elements') { /// 10 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + &:hover { + @include bem.multi('elem:' 'subchild1' 'subchild2') { + font-size: 3em; + + @include bem.modifier('mod2') { + font-size: 3.5em; + } + } + } + } + } + } + + @include expect { + .something__child:hover .something__subchild1, + .something__child:hover .something__subchild2 { + font-size: 3em; + } + + .something__child:hover .something__subchild1--mod2, + .something__child:hover .something__subchild2--mod2 { + font-size: 3.5em; + } + } + } + + @include assert('in element in manual selector, 1 element, 1 & selector') { /// 11 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + &:hover { + @include bem.multi('elem:' 'subchild', '&') { + font-size: 3em; + } + } + } + } + } + + @include expect { + .something__child:hover .something__subchild { + font-size: 3em; + } + + .something__child:hover { + font-size: 3em; + } + } + } + + @include assert('in multiple elements, 2 elements, 1 modifier') { /// 12 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + @include bem.multi('elem:' 'subchild1' 'subchild2', 'modifier:' 'mod') { + font-size: 3em; + } + } + } + } + + @include expect { + .something__child1 .something__subchild1, + .something__child2 .something__subchild1, + .something__child1 .something__subchild2, + .something__child2 .something__subchild2 { + font-size: 3em; + } + + .something__child1--mod, + .something__child2--mod { + font-size: 3em; + } + } + } + + @include assert('in multiple elements, 1 element, 1 & selector') { /// 13 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + @include bem.multi('elem:' 'subchild', '&') { + font-size: 3em; + + @include bem.modifier('mod') { + font-size: 3.5em; + } + } + } + } + } + + @include expect { + .something__child1 .something__subchild, + .something__child2 .something__subchild { + font-size: 3em; + } + + .something__child1 .something__subchild--mod, + .something__child2 .something__subchild--mod { + font-size: 3.5em; + } + + .something__child1, + .something__child2 { + font-size: 3em; + } + + .something__child1--mod, + .something__child2--mod { + font-size: 3.5em; + } + } + } + + @include assert('in related elements, 2 elements, 1 modifier') { /// 14 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1') { + @include bem.next-elem('child2', 'child3') { + @include bem.multi('elem:' 'subchild1' 'subchild2', 'modifier:' 'mod') { + font-size: 3em; + } + } + } + } + } + + @include expect { + .something__child1 + .something__child2 .something__subchild1, + .something__child1 + .something__child3 .something__subchild1, + .something__child1 + .something__child2 .something__subchild2, + .something__child1 + .something__child3 .something__subchild2 { + font-size: 3em; + } + + .something__child1 + .something__child2--mod, + .something__child1 + .something__child3--mod { + font-size: 3em; + } + } + } + + @include assert('in related elements, 1 element, 1 & selector') { /// 15 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1') { + @include bem.next-elem('child2', 'child3') { + @include bem.multi('elem:' 'subchild', '&') { + font-size: 4em; + + @include bem.modifier('mod') { + font-size: 4.5em; + } + } + } + } + } + } + + @include expect { + .something__child1 + .something__child2 .something__subchild, + .something__child1 + .something__child3 .something__subchild { + font-size: 4em; + } + + .something__child1 + .something__child2 .something__subchild--mod, + .something__child1 + .something__child3 .something__subchild--mod { + font-size: 4.5em; + } + + .something__child1 + .something__child2, + .something__child1 + .something__child3 { + font-size: 4em; + } + + .something__child1 + .something__child2--mod, + .something__child1 + .something__child3--mod { + font-size: 4.5em; + } + } + } + + @include assert('in element, 2 related elements, 1 modifier') { /// 16 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1') { + @include bem.multi('next-elem:' 'child2' 'child3', 'modifier:' 'mod1') { + font-size: 3em; + + @include bem.modifier('mod2') { + font-size: 3.5em; + } + } + } + } + } + + @include expect { + .something__child1 + .something__child2, + .something__child1 + .something__child3 { + font-size: 3em; + } + + .something__child1 + .something__child2--mod2, + .something__child1 + .something__child3--mod2 { + font-size: 3.5em; + } + + .something__child1--mod1 { + font-size: 3em; + } + + .something__child1--mod1.something__child1--mod2 { + font-size: 3.5em; + } + } + } + + @include assert('in element, 1 twin element, 1 modifier') { /// 17 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + @include bem.multi('next-twin-elem', 'modifier:' 'mod1') { + font-size: 3em; + + @include bem.modifier('mod2') { + font-size: 3.5em; + } + } + } + } + } + + @include expect { + .something__child + .something__child { + font-size: 3em; + } + + .something__child + .something__child--mod2 { + font-size: 3.5em; + } + + .something__child--mod1 { + font-size: 3em; + } + + .something__child--mod1.something__child--mod2 { + font-size: 3.5em; + } + } + } + + @include assert('in multiple elements, 1 twin element, 1 modifier') { /// 18 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + @include bem.multi('next-twin-elem', 'modifier:' 'mod1') { + font-size: 3em; + + @include bem.modifier('mod2') { + font-size: 3.5em; + } + } + } + } + } + + @include expect { + .something__child1 + .something__child1, + .something__child2 + .something__child2 { + font-size: 3em; + } + + .something__child1 + .something__child1--mod2, + .something__child2 + .something__child2--mod2 { + font-size: 3.5em; + } + + .something__child1--mod1, + .something__child2--mod1 { + font-size: 3em; + } + + .something__child1--mod1.something__child1--mod2, + .something__child2--mod1.something__child2--mod2 { + font-size: 3.5em; + } + } + } +} diff --git a/test/bem/_next-twin-element.scss b/test/bem/_next-twin-element.scss new file mode 100644 index 0000000..85fe473 --- /dev/null +++ b/test/bem/_next-twin-element.scss @@ -0,0 +1,156 @@ +// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations + +@use 'true' as *; +@use '../../src/bem'; + +// +// Included test cases: +// - /// 1 /// - single element +// - /// 2 /// - single element, manual selector in-between +// - /// 3 /// - single element, modifier in-between +// - /// 4 /// - multiple elements +// - /// 5 /// - multiple elements, manual selector in-between +// - /// 6 /// - multiple elements, modifier in-between +// + +@include it('next-twin-element') { + @include assert('single element') { /// 1 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + @include bem.next-twin-element { + font-size: 2em; + } + } + } + } + + @include expect { + .something__child + .something__child { + font-size: 2em; + } + } + } + + @include assert('single element, manual selector in-between') { /// 2 /// + @include output(false) { + @include bem.block('something') { + @include bem.elem('child') { + &:hover { + @include bem.next-twin-element { + font-size: 2em; + } + } + + .test & { + @include bem.next-twin-element { + font-size: 2em; + } + } + } + } + } + + @include expect(false) { + .something__child:hover + .something__child { + font-size: 2em; + } + + .test .something__child + .something__child { + font-size: 2em; + } + } + } + + @include assert('single element, modifier in-between') { /// 3 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + @include bem.modifier('mod') { + @include bem.next-twin-element { + font-size: 2.5em; + } + } + } + } + } + + @include expect { + .something__child--mod + .something__child { + font-size: 2.5em; + } + } + } + + @include assert('multiple elements') { /// 4 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + @include bem.next-twin-element { + font-size: 2em; + } + } + } + } + + @include expect { + .something__child1 + .something__child1, + .something__child2 + .something__child2 { + font-size: 2em; + } + } + } + + @include assert('multiple elements, manual selector in-between') { /// 5 /// + @include output(false) { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + &:hover { + @include bem.next-twin-element { + font-size: 2em; + } + } + + .test & { + @include bem.next-twin-element { + font-size: 2em; + } + } + } + } + } + + @include expect(false) { + .something__child1:hover + .something__child1, + .something__child2:hover + .something__child2 { + font-size: 2em; + } + + .test .something__child1 + .something__child1, + .test .something__child2 + .something__child2 { + font-size: 2em; + } + } + } + + @include assert('multiple elements, modifier in-between') { /// 6 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + @include bem.modifier('mod') { + @include bem.next-twin-element { + font-size: 2.5em; + } + } + } + } + } + + @include expect { + .something__child1--mod + .something__child1, + .something__child2--mod + .something__child2 { + font-size: 2.5em; + } + } + } +} diff --git a/test/bem/_related-element.scss b/test/bem/_related-element.scss new file mode 100644 index 0000000..5a829e8 --- /dev/null +++ b/test/bem/_related-element.scss @@ -0,0 +1,462 @@ +// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations + +@use 'true' as *; +@use '../../src/bem'; + +// +// Included test cases: +// - /// 1 /// - single element, single related element +// - /// 2 /// - single element, single related element, manual selector in-between +// - /// 3 /// - single element, single related element, modifier in-between +// - /// 4 /// - single element, multiple related elements +// - /// 5 /// - single element, multiple related elements, manual selector in-between +// - /// 6 /// - single element, multiple related elements, modifier in-between +// - /// 7 /// - multiple elements, single related element +// - /// 8 /// - multiple elements, single related element, manual selector in-between +// - /// 9 /// - multiple elements, single related element, modifier in-between +// - /// 10 /// - multiple elements, multiple related elements +// - /// 11 /// - multiple elements, multiple related elements, manual selector in-between +// - /// 12 /// - multiple elements, multiple related elements, modifier in-between +// + +@include it('related-element') { + @include assert('single element, single related element') { /// 1 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + @include bem.related-elem('+', 'subchild1') { + font-size: 2em; + } + + @include bem.related-elem('~', 'subchild2') { + font-size: 2em; + } + } + } + } + + @include expect { + .something__child + .something__subchild1 { + font-size: 2em; + } + + .something__child ~ .something__subchild2 { + font-size: 2em; + } + } + } + + @include assert('single element, single related element, manual selector in-between') { /// 2 /// + @include output(false) { + @include bem.block('something') { + @include bem.elem('child') { + &:hover { + @include bem.related-elem('+', 'subchild1') { + font-size: 2em; + } + + @include bem.related-elem('~', 'subchild2') { + font-size: 2em; + } + } + + .test & { + @include bem.related-elem('+', 'subchild3') { + font-size: 2em; + } + + @include bem.related-elem('~', 'subchild4') { + font-size: 2em; + } + } + } + } + } + + @include expect(false) { + .something__child:hover + .something__subchild1 { + font-size: 2em; + } + + .something__child:hover ~ .something__subchild2 { + font-size: 2em; + } + + .test .something__child + .something__subchild3 { + font-size: 2em; + } + + .test .something__child ~ .something__subchild4 { + font-size: 2em; + } + } + } + + @include assert('single element, single related element, modifier in-between') { /// 3 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + @include bem.modifier('mod') { + @include bem.related-elem('+', 'subchild1') { + font-size: 2.5em; + } + + @include bem.related-elem('~', 'subchild2') { + font-size: 2.5em; + } + } + } + } + } + + @include expect { + .something__child--mod + .something__subchild1 { + font-size: 2.5em; + } + + .something__child--mod ~ .something__subchild2 { + font-size: 2.5em; + } + } + } + + @include assert('single element, multiple related elements') { /// 4 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + @include bem.related-elem('+', 'subchild1', 'subchild2') { + font-size: 2.5em; + } + + @include bem.related-elem('~', 'subchild3', 'subchild4') { + font-size: 2.5em; + } + } + } + } + + @include expect { + .something__child + .something__subchild1, + .something__child + .something__subchild2 { + font-size: 2.5em; + } + + .something__child ~ .something__subchild3, + .something__child ~ .something__subchild4 { + font-size: 2.5em; + } + } + } + + @include assert('single element, multiple related elements, manual selector in-between') { /// 5 /// + @include output(false) { + @include bem.block('something') { + @include bem.elem('child') { + &:hover { + @include bem.related-elem('+', 'subchild1', 'subchild2') { + font-size: 2.5em; + } + + @include bem.related-elem('~', 'subchild3', 'subchild4') { + font-size: 2.5em; + } + } + + .test & { + @include bem.related-elem('+', 'subchild5', 'subchild6') { + font-size: 2.5em; + } + + @include bem.related-elem('~', 'subchild7', 'subchild8') { + font-size: 2.5em; + } + } + } + } + } + + @include expect(false) { + .something__child:hover + .something__subchild1, + .something__child:hover + .something__subchild2 { + font-size: 2.5em; + } + + .something__child:hover ~ .something__subchild3, + .something__child:hover ~ .something__subchild4 { + font-size: 2.5em; + } + + .test .something__child + .something__subchild5, + .test .something__child + .something__subchild6 { + font-size: 2.5em; + } + + .test .something__child ~ .something__subchild7, + .test .something__child ~ .something__subchild8 { + font-size: 2.5em; + } + } + } + + @include assert('single element, multiple related elements, modifier in-between') { /// 6 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + @include bem.modifier('mod') { + @include bem.related-elem('+', 'subchild1', 'subchild2') { + font-size: 2.5em; + } + + @include bem.related-elem('~', 'subchild3', 'subchild4') { + font-size: 2.5em; + } + } + } + } + } + + @include expect { + .something__child--mod + .something__subchild1, + .something__child--mod + .something__subchild2 { + font-size: 2.5em; + } + + .something__child--mod ~ .something__subchild3, + .something__child--mod ~ .something__subchild4 { + font-size: 2.5em; + } + } + } + + @include assert('multiple elements, single related element') { /// 7 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + @include bem.related-elem('+', 'subchild1') { + font-size: 2em; + } + + @include bem.related-elem('~', 'subchild2') { + font-size: 2em; + } + } + } + } + + @include expect { + .something__child1 + .something__subchild1, + .something__child2 + .something__subchild1 { + font-size: 2em; + } + + .something__child1 ~ .something__subchild2, + .something__child2 ~ .something__subchild2 { + font-size: 2em; + } + } + } + + @include assert('multiple elements, single related element, manual selector in-between') { /// 8 /// + @include output(false) { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + &:hover { + @include bem.related-elem('+', 'subchild1') { + font-size: 2em; + } + + @include bem.related-elem('~', 'subchild2') { + font-size: 2em; + } + } + + .test & { + @include bem.related-elem('+', 'subchild3') { + font-size: 2em; + } + + @include bem.related-elem('~', 'subchild4') { + font-size: 2em; + } + } + } + } + } + + @include expect(false) { + .something__child1:hover + .something__subchild1, + .something__child2:hover + .something__subchild1 { + font-size: 2em; + } + + .something__child1:hover ~ .something__subchild2, + .something__child2:hover ~ .something__subchild2 { + font-size: 2em; + } + + .test .something__child1 + .something__subchild3, + .test .something__child2 + .something__subchild3 { + font-size: 2em; + } + + .test .something__child1 ~ .something__subchild4, + .test .something__child2 ~ .something__subchild4 { + font-size: 2em; + } + } + } + + @include assert('multiple elements, single related element, modifier in-between') { /// 9 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + @include bem.modifier('mod') { + @include bem.related-elem('+', 'subchild1') { + font-size: 2.5em; + } + + @include bem.related-elem('~', 'subchild2') { + font-size: 2.5em; + } + } + } + } + } + + @include expect { + .something__child1--mod + .something__subchild1, + .something__child2--mod + .something__subchild1 { + font-size: 2.5em; + } + + .something__child1--mod ~ .something__subchild2, + .something__child2--mod ~ .something__subchild2 { + font-size: 2.5em; + } + } + } + + @include assert('multiple elements, multiple related elements') { /// 10 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + @include bem.related-elem('+', 'subchild1', 'subchild2') { + font-size: 2em; + } + + @include bem.related-elem('~', 'subchild3', 'subchild4') { + font-size: 2em; + } + } + } + } + + @include expect { + .something__child1 + .something__subchild1, + .something__child2 + .something__subchild1, + .something__child1 + .something__subchild2, + .something__child2 + .something__subchild2 { + font-size: 2em; + } + + .something__child1 ~ .something__subchild3, + .something__child2 ~ .something__subchild3, + .something__child1 ~ .something__subchild4, + .something__child2 ~ .something__subchild4 { + font-size: 2em; + } + } + } + + @include assert('multiple elements, multiple related elements, manual selector in-between') { /// 11 /// + @include output(false) { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + &:hover { + @include bem.related-elem('+', 'subchild1', 'subchild2') { + font-size: 2em; + } + + @include bem.related-elem('~', 'subchild3', 'subchild4') { + font-size: 2em; + } + } + + .test & { + @include bem.related-elem('+', 'subchild5', 'subchild6') { + font-size: 2em; + } + + @include bem.related-elem('~', 'subchild7', 'subchild8') { + font-size: 2em; + } + } + } + } + } + + @include expect(false) { + .something__child1:hover + .something__subchild1, + .something__child2:hover + .something__subchild1, + .something__child1:hover + .something__subchild2, + .something__child2:hover + .something__subchild2 { + font-size: 2em; + } + + .something__child1:hover ~ .something__subchild3, + .something__child2:hover ~ .something__subchild3, + .something__child1:hover ~ .something__subchild4, + .something__child2:hover ~ .something__subchild4 { + font-size: 2em; + } + + .test .something__child1 + .something__subchild5, + .test .something__child2 + .something__subchild5, + .test .something__child1 + .something__subchild6, + .test .something__child2 + .something__subchild6 { + font-size: 2em; + } + + .test .something__child1 ~ .something__subchild7, + .test .something__child2 ~ .something__subchild7, + .test .something__child1 ~ .something__subchild8, + .test .something__child2 ~ .something__subchild8 { + font-size: 2em; + } + } + } + + @include assert('multiple elements, multiple related elements, modifier in-between') { /// 12 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + @include bem.modifier('mod') { + @include bem.related-elem('+', 'subchild1', 'subchild2') { + font-size: 2em; + } + + @include bem.related-elem('~', 'subchild3', 'subchild4') { + font-size: 2em; + } + } + } + } + } + + @include expect { + .something__child1--mod + .something__subchild1, + .something__child2--mod + .something__subchild1, + .something__child1--mod + .something__subchild2, + .something__child2--mod + .something__subchild2 { + font-size: 2em; + } + + .something__child1--mod ~ .something__subchild3, + .something__child2--mod ~ .something__subchild3, + .something__child1--mod ~ .something__subchild4, + .something__child2--mod ~ .something__subchild4 { + font-size: 2em; + } + } + } +} diff --git a/test/bem/_state.scss b/test/bem/_state.scss new file mode 100644 index 0000000..674da5f --- /dev/null +++ b/test/bem/_state.scss @@ -0,0 +1,180 @@ +// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations + +@use 'true' as *; +@use '../../src/bem'; + +// +// Included test cases: +// - /// 1 /// - single block, single state +// - /// 2 /// - single element, single state +// - /// 3 /// - single block, multiple states +// - /// 4 /// - single element, multiple states +// - /// 5 /// - multiple elements, single state +// - /// 6 /// - multiple elements, multiple states +// + +@include it('state') { + @include assert('single block, single state') { /// 1 /// + @include output { + @include bem.block('something') { + @include bem.is('active') { + font-size: 1.25em; + } + + @include bem.has('state') { + font-size: 1.75em; + } + } + } + + @include expect { + .something.is-active { + font-size: 1.25em; + } + + .something.has-state { + font-size: 1.75em; + } + } + } + + @include assert('single element, single state') { /// 2 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + @include bem.is('active') { + font-size: 2.25em; + } + + @include bem.has('state') { + font-size: 2.75em; + } + } + } + } + + @include expect { + .something__child.is-active { + font-size: 2.25em; + } + + .something__child.has-state { + font-size: 2.75em; + } + } + } + + @include assert('single block, multiple states') { /// 3 /// + @include output { + @include bem.block('something') { + @include bem.is('active', 'primary') { + font-size: 1.25em; + } + + @include bem.has('state', 'indicator') { + font-size: 1.75em; + } + } + } + + @include expect { + .something.is-active, + .something.is-primary { + font-size: 1.25em; + } + + .something.has-state, + .something.has-indicator { + font-size: 1.75em; + } + } + } + + @include assert('single element, multiple states') { /// 4 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + @include bem.is('active', 'primary') { + font-size: 2.25em; + } + + @include bem.has('state', 'indicator') { + font-size: 2.75em; + } + } + } + } + + @include expect { + .something__child.is-active, + .something__child.is-primary { + font-size: 2.25em; + } + + .something__child.has-state, + .something__child.has-indicator { + font-size: 2.75em; + } + } + } + + @include assert('multiple elements, single state') { /// 5 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + @include bem.is('active') { + font-size: 2.25em; + } + + @include bem.has('state') { + font-size: 2.75em; + } + } + } + } + + @include expect { + .something__child1.is-active, + .something__child2.is-active { + font-size: 2.25em; + } + + .something__child1.has-state, + .something__child2.has-state { + font-size: 2.75em; + } + } + } + + @include assert('multiple elements, multiple states') { /// 6 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + @include bem.is('active', 'primary') { + font-size: 2.25em; + } + + @include bem.has('state', 'indicator') { + font-size: 2.75em; + } + } + } + } + + @include expect { + .something__child1.is-active, + .something__child2.is-active, + .something__child1.is-primary, + .something__child2.is-primary { + font-size: 2.25em; + } + + .something__child1.has-state, + .something__child2.has-state, + .something__child1.has-indicator, + .something__child2.has-indicator { + font-size: 2.75em; + } + } + } +} diff --git a/test/bem/_suffix.scss b/test/bem/_suffix.scss new file mode 100644 index 0000000..34f55b6 --- /dev/null +++ b/test/bem/_suffix.scss @@ -0,0 +1,97 @@ +// sass-lint:disable class-name-format force-element-nesting force-pseudo-nesting mixins-before-declarations + +@use 'true' as *; +@use '../../src/bem'; + +// +// Included test cases: +// - /// 1 /// - block suffix +// - /// 2 /// - element suffix +// - /// 3 /// - modifier suffix +// - /// 4 /// - multiple element suffix +// + +@include it('suffix') { + @include assert('block suffix') { /// 1 /// + @include output { + @include bem.block('something') { + @include bem.suffix('sm') { + font-size: 1.5em; + } + } + } + + @include expect { + .something\@sm { + font-size: 1.5em; + } + } + } + + @include assert('element suffix') { /// 2 /// + @include output { + @include bem.block('something') { + @include bem.elem('child') { + @include bem.suffix('sm') { + font-size: 2.5em; + } + } + } + } + + @include expect { + .something__child\@sm { + font-size: 2.5em; + } + } + } + + @include assert('modifier suffix') { /// 3 /// + @include output { + @include bem.block('something') { + @include bem.modifier('mod1') { + @include bem.suffix('sm') { + font-size: 1.75em; + } + } + + @include bem.elem('child') { + @include bem.modifier('mod2') { + @include bem.suffix('sm') { + font-size: 2.75em; + } + } + } + } + } + + @include expect { + .something--mod1\@sm { + font-size: 1.75em; + } + + .something__child--mod2\@sm { + font-size: 2.75em; + } + } + } + + @include assert('multiple element suffix') { /// 4 /// + @include output { + @include bem.block('something') { + @include bem.elem('child1', 'child2') { + @include bem.suffix('sm') { + font-size: 2.5em; + } + } + } + } + + @include expect { + .something__child1\@sm, + .something__child2\@sm { + font-size: 2.5em; + } + } + } +} -- cgit v1.2.3-70-g09d2