@@ -9,76 +9,70 @@ import { bemToBlocksPlugin } from "../src/index";
9
9
describe ( "converts BEM to blocks" , ( ) => {
10
10
11
11
it ( "converts simple classes to blocks" , async ( ) => {
12
- postcss ( [ bemToBlocksPlugin ] )
12
+ return postcss ( [ bemToBlocksPlugin ] )
13
13
. process ( ".jobs-entry__image--inverse-red {color: blue}" ) . then ( ( output ) => {
14
14
assert . equal ( output . toString ( ) , ".image[inverse-red] {color: blue}" ) ;
15
- } ) . catch ( ) ;
16
-
15
+ } ) ;
17
16
} ) ;
18
17
19
18
it ( "existing attributes remain unchanged" , async ( ) => {
20
- postcss ( [ bemToBlocksPlugin ] )
19
+ return postcss ( [ bemToBlocksPlugin ] )
21
20
. process ( ".jobs-entry__image[state=red] {color: blue}" )
22
21
. then ( output => {
23
22
assert . equal ( output . toString ( ) , ".image[state=red] {color: blue}" ) ;
24
- } ) . catch ( ) ;
23
+ } ) ;
25
24
} ) ;
26
25
27
26
it ( "selector has attributes and a modifier" , async ( ) => {
28
- postcss ( [ bemToBlocksPlugin ] )
27
+ return postcss ( [ bemToBlocksPlugin ] )
29
28
. process ( ".jobs-entry__image--big[state=red] {color: blue}" )
30
29
. then ( output => {
31
30
assert . equal ( output . toString ( ) , ".image[big][state=red] {color: blue}" ) ;
32
- } ) . catch ( ) ;
31
+ } ) ;
33
32
} ) ;
34
33
35
34
it ( "comments are left as is" , async ( ) => {
36
- postcss ( [ bemToBlocksPlugin ] )
35
+ return postcss ( [ bemToBlocksPlugin ] )
37
36
. process ( `/* adding a comment here */.jobs-entry__image--big[state=red] {color: blue}` )
38
37
. then ( output => {
39
38
assert . equal ( output . toString ( ) , `/* adding a comment here */.image[big][state=red] {color: blue}` ) ;
40
- } )
41
- . catch ( ) ;
39
+ } ) ;
42
40
} ) ;
43
41
44
42
it ( "respects pseudo selectors" , async ( ) => {
45
- postcss ( [ bemToBlocksPlugin ] )
43
+ return postcss ( [ bemToBlocksPlugin ] )
46
44
. process ( ".jobs-entry__image--big::before {color: blue}" )
47
45
. then ( output => {
48
46
assert . equal ( output . toString ( ) , ".image[big]::before {color: blue}" ) ;
49
- } )
50
- . catch ( ) ;
47
+ } ) ;
51
48
} ) ;
52
49
53
50
it ( "respects sibling selectors" , async ( ) => {
54
- postcss ( [ bemToBlocksPlugin ] )
51
+ return postcss ( [ bemToBlocksPlugin ] )
55
52
. process ( ".jobs-entry__image--big>.jobs-entry__image--small {color: blue}" )
56
53
. then ( output => {
57
54
assert . equal ( output . toString ( ) , ".image[big]>.image[small] {color: blue}" ) ;
58
- } )
59
- . catch ( ) ;
55
+ } ) ;
60
56
} ) ;
61
57
62
58
it ( "respects scss imports" , async ( ) => {
63
- postcss ( [ bemToBlocksPlugin ] )
59
+ return postcss ( [ bemToBlocksPlugin ] )
64
60
. process ( `@import "restyle"; .jobs-entry__image--big[state=red] {color: blue}` )
65
61
. then ( output => {
66
62
assert . equal ( output . toString ( ) , `@import "restyle"; .image[big][state=red] {color: blue}` ) ;
67
- } )
68
- . catch ( ) ;
63
+ } ) ;
69
64
} ) ;
70
65
71
66
it ( "respects scss nesting" , async ( ) => {
72
- postcss ( [ bemToBlocksPlugin ] )
67
+ return postcss ( [ bemToBlocksPlugin ] )
73
68
. process ( `@import "restyle"; .jobs-entry__image--big[state=red] {color: blue}` )
74
69
. then ( output => {
75
70
assert . equal ( output . toString ( ) , `@import "restyle"; .image[big][state=red] {color: blue}` ) ;
76
- } )
77
- . catch ( ) ;
71
+ } ) ;
78
72
} ) ;
79
73
80
74
it ( "other scss syntax" , async ( ) => {
81
- postcss ( [ bemToBlocksPlugin ] )
75
+ return postcss ( [ bemToBlocksPlugin ] )
82
76
. process ( `
83
77
@mixin artdeco-badge(){
84
78
@keyframes artdecoBadgeAnimationIn1 {
@@ -103,28 +97,27 @@ describe("converts BEM to blocks", () => {
103
97
to { transform: scale(1); }
104
98
}
105
99
}` . trim ( ) ) ;
106
- } ) . catch ( ) ;
100
+ } ) ;
107
101
} ) ;
108
102
109
103
it ( "replaces substates correctly" , async ( ) => {
110
- postcss ( [ bemToBlocksPlugin ] )
111
- . process ( `.jobs-entry__image--size-big {color: blue}
112
- .jobs-entry__image--size-small {color: red}` )
113
- . then ( output => {
114
- assert . equal ( output . toString ( ) , `.image[size="big"] {color: blue}
115
- .image[size="small"] {color: red}` ) ;
116
- } )
117
- . catch ( ) ;
104
+ return postcss ( [ bemToBlocksPlugin ] )
105
+ . process ( `.jobs-entry__image--size-big {color: blue}
106
+ .jobs-entry__image--size-small {color: red}` )
107
+ . then ( output => {
108
+ assert . equal ( output . toString ( ) , `.image[size="big"] {color: blue}
109
+ .image[size="small"] {color: red}` ) ;
110
+ } ) ;
118
111
} ) ;
119
112
120
113
it ( "replaces substates correctly when the modifier is on the block" , async ( ) => {
121
- postcss ( [ bemToBlocksPlugin ] )
114
+ return postcss ( [ bemToBlocksPlugin ] )
122
115
. process ( `.jobs-entry--size-big {color: blue}
123
116
.jobs-entry--size-small {color: red}` )
124
117
. then ( output => {
125
118
assert . equal ( output . toString ( ) , `:scope[size="big"] {color: blue}
126
119
:scope[size="small"] {color: red}` ) ;
127
- } ) . catch ( ) ;
120
+ } ) ;
128
121
} ) ;
129
122
130
123
it ( "calls inquirer for user input" , async ( ) => {
@@ -135,12 +128,12 @@ describe("converts BEM to blocks", () => {
135
128
stub . onCall ( 0 ) . returns ( { block : "my-block" } as any ) ;
136
129
stub . onCall ( 1 ) . returns ( { element : "my-elem" } as any ) ;
137
130
stub . onCall ( 2 ) . returns ( { modifier : "my-mod" } as any ) ;
138
- postcss ( [ bemToBlocksPlugin ] )
139
- . process ( `.CLASSINCAPSTHATISNOTBEM {color: blue}` )
140
- . then ( ( output ) => {
141
- assert . equal ( output . css , ".my-elem[my-mod] {color: blue}" ) ;
142
- assert . equal ( stub . calledThrice , true ) ;
131
+ return postcss ( [ bemToBlocksPlugin ] )
132
+ . process ( `.CLASSINCAPSTHATISNOTBEM {color: blue}` )
133
+ . then ( ( output ) => {
134
+ assert . equal ( output . css , ".my-elem[my-mod] {color: blue}" ) ;
135
+ assert . equal ( stub . calledThrice , true ) ;
143
136
144
- } ) . catch ( ) ;
137
+ } ) ;
145
138
} ) ;
146
139
} ) ;
0 commit comments