aboutsummaryrefslogtreecommitdiffstats
path: root/test/bem/_next-twin-element.scss
blob: 355e635b9fcccb2ad08c8cef154fd61f06883242 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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-elem') {
    @include assert('single element') { /// 1 ///
        @include output {
            @include bem.block('something') {
                @include bem.elem('child') {
                    @include bem.next-twin-elem {
                        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-elem {
                            font-size: 2em;
                        }
                    }

                    .test & {
                        @include bem.next-twin-elem {
                            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-elem {
                            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-elem {
                        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-elem {
                            font-size: 2em;
                        }
                    }

                    .test & {
                        @include bem.next-twin-elem {
                            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-elem {
                            font-size: 2.5em;
                        }
                    }
                }
            }
        }

        @include expect {
            .something__child1--mod + .something__child1,
            .something__child2--mod + .something__child2 {
                font-size: 2.5em;
            }
        }
    }
}