|
| 1 | +// ============================================================================================= // |
| 2 | +// TEST // |
| 3 | +// ============================================================================================= // |
| 4 | + |
| 5 | +@use "true" as *; |
| 6 | +@use "../index" as css; |
| 7 | +@use "../custom-properties"; |
| 8 | + |
| 9 | +@include describe("mixins") { |
| 10 | + @include describe("declaration()") { |
| 11 | + @include it("Should return a css declaration.") { |
| 12 | + @include assert { |
| 13 | + @include output(false) { |
| 14 | + .foo { |
| 15 | + @include css.declaration(color, darkcyan); |
| 16 | + } |
| 17 | + } |
| 18 | + |
| 19 | + @include expect(false) { |
| 20 | + .foo { |
| 21 | + color: darkcyan; |
| 22 | + } |
| 23 | + } |
| 24 | + } |
| 25 | + } |
| 26 | + |
| 27 | + @include it("Should return a css declaration with custom property.") { |
| 28 | + @include assert { |
| 29 | + @include output(false) { |
| 30 | + .test { |
| 31 | + @include css.declaration(--foo, darkcyan); |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + @include expect(false) { |
| 36 | + .test { |
| 37 | + --foo: darkcyan; |
| 38 | + } |
| 39 | + } |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + @include it("Should return a css declaration with `!important` option.") { |
| 44 | + @include assert { |
| 45 | + @include output(false) { |
| 46 | + .foo { |
| 47 | + @include css.declaration(color, darkcyan, true); |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + @include expect(false) { |
| 52 | + .foo { |
| 53 | + color: darkcyan !important; |
| 54 | + } |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + @include it("Should return a css mixed declaration.") { |
| 60 | + @include assert { |
| 61 | + @include output(false) { |
| 62 | + .foo { |
| 63 | + @include css.declaration(box-shadow, (0 0 10px 5px rgba(darkcyan, 0.75), inset 0 0 10px 5px rgba(darkcyan, 0.75))); |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + @include expect(false) { |
| 68 | + .foo { |
| 69 | + box-shadow: 0 0 10px 5px rgba(0, 139, 139, 0.75), inset 0 0 10px 5px rgba(0, 139, 139, 0.75); |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + @include describe("declaration() with custom properties") { |
| 77 | + @include it("Should return a css declaration with custom property from `custom-properties.create()` function.") { |
| 78 | + @include assert { |
| 79 | + @include output(false) { |
| 80 | + .test { |
| 81 | + @include css.declaration(custom-properties.create(--foo, darkcyan)); |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + @include expect(false) { |
| 86 | + .test { |
| 87 | + --foo: darkcyan; |
| 88 | + } |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + @include it("Should return a css declaration with custom property from `custom-properties.create()` function with missing `--`.") { |
| 94 | + @include assert { |
| 95 | + @include output(false) { |
| 96 | + .test { |
| 97 | + @include css.declaration(custom-properties.create(foo, darkcyan)); |
| 98 | + } |
| 99 | + } |
| 100 | + |
| 101 | + @include expect(false) { |
| 102 | + .test { |
| 103 | + --foo: darkcyan; |
| 104 | + } |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | + |
| 109 | + @include it("Should return a css declaration with `var()`.") { |
| 110 | + @include assert { |
| 111 | + @include output(false) { |
| 112 | + .test { |
| 113 | + @include css.declaration(color, custom-properties.create(--foo, darkcyan)); |
| 114 | + } |
| 115 | + } |
| 116 | + |
| 117 | + @include expect(false) { |
| 118 | + .test { |
| 119 | + color: var(--foo, darkcyan); |
| 120 | + } |
| 121 | + } |
| 122 | + } |
| 123 | + } |
| 124 | + |
| 125 | + @include it("Should return a css declaration with nested `var()`.") { |
| 126 | + @include assert { |
| 127 | + @include output(false) { |
| 128 | + .test { |
| 129 | + @include css.declaration(color, custom-properties.create(--foo, custom-properties.create(--bar, darkcyan))); |
| 130 | + } |
| 131 | + } |
| 132 | + |
| 133 | + @include expect(false) { |
| 134 | + .test { |
| 135 | + color: var(--foo, var(--bar, darkcyan)); |
| 136 | + } |
| 137 | + } |
| 138 | + } |
| 139 | + } |
| 140 | + } |
| 141 | + |
| 142 | + @include describe("selector()") { |
| 143 | + @include it("Should return prefixed selector.") { |
| 144 | + @include assert { |
| 145 | + @include output(false) { |
| 146 | + .foo { |
| 147 | + @include css.selector("md") { |
| 148 | + color: darkcyan; |
| 149 | + } |
| 150 | + } |
| 151 | + } |
| 152 | + |
| 153 | + @include expect(false) { |
| 154 | + .md\:foo { |
| 155 | + color: darkcyan; |
| 156 | + } |
| 157 | + } |
| 158 | + } |
| 159 | + } |
| 160 | + |
| 161 | + @include it("Should return prefixed selector with custom separator.") { |
| 162 | + @include assert { |
| 163 | + @include output(false) { |
| 164 | + .foo { |
| 165 | + @include css.selector("md", "@") { |
| 166 | + color: darkcyan; |
| 167 | + } |
| 168 | + } |
| 169 | + } |
| 170 | + |
| 171 | + @include expect(false) { |
| 172 | + .md\@foo { |
| 173 | + color: darkcyan; |
| 174 | + } |
| 175 | + } |
| 176 | + } |
| 177 | + } |
| 178 | + |
| 179 | + @include it("Should return prefixed selector with numbers.") { |
| 180 | + @include assert { |
| 181 | + @include output(false) { |
| 182 | + .foo { |
| 183 | + @include css.selector("2xl") { |
| 184 | + color: darkcyan; |
| 185 | + } |
| 186 | + } |
| 187 | + } |
| 188 | + |
| 189 | + @include expect(false) { |
| 190 | + .\32 xl\:foo { |
| 191 | + color: darkcyan; |
| 192 | + } |
| 193 | + } |
| 194 | + } |
| 195 | + } |
| 196 | + |
| 197 | + @include it("Should return suffixed selector.") { |
| 198 | + @include assert { |
| 199 | + @include output(false) { |
| 200 | + .foo { |
| 201 | + @include css.selector("md", $suffix: true) { |
| 202 | + color: darkcyan; |
| 203 | + } |
| 204 | + } |
| 205 | + } |
| 206 | + |
| 207 | + @include expect(false) { |
| 208 | + .foo\:md { |
| 209 | + color: darkcyan; |
| 210 | + } |
| 211 | + } |
| 212 | + } |
| 213 | + } |
| 214 | + |
| 215 | + @include it("Should return suffixed selector with custom separator.") { |
| 216 | + @include assert { |
| 217 | + @include output(false) { |
| 218 | + .foo { |
| 219 | + @include css.selector("md", "@", true) { |
| 220 | + color: darkcyan; |
| 221 | + } |
| 222 | + } |
| 223 | + } |
| 224 | + |
| 225 | + @include expect(false) { |
| 226 | + .foo\@md { |
| 227 | + color: darkcyan; |
| 228 | + } |
| 229 | + } |
| 230 | + } |
| 231 | + } |
| 232 | + |
| 233 | + @include it("Should return suffixed selector with numbers.") { |
| 234 | + @include assert { |
| 235 | + @include output(false) { |
| 236 | + .foo { |
| 237 | + @include css.selector("2xl", $suffix: true) { |
| 238 | + color: darkcyan; |
| 239 | + } |
| 240 | + } |
| 241 | + } |
| 242 | + |
| 243 | + @include expect(false) { |
| 244 | + .foo\:2xl { |
| 245 | + color: darkcyan; |
| 246 | + } |
| 247 | + } |
| 248 | + } |
| 249 | + } |
| 250 | + |
| 251 | + @include it("Should return prefixed custom selector.") { |
| 252 | + @include assert { |
| 253 | + @include output(false) { |
| 254 | + @include css.selector("md", $selector: ".foo") { |
| 255 | + color: darkcyan; |
| 256 | + } |
| 257 | + } |
| 258 | + |
| 259 | + @include expect(false) { |
| 260 | + .md\:foo { |
| 261 | + color: darkcyan; |
| 262 | + } |
| 263 | + } |
| 264 | + } |
| 265 | + } |
| 266 | + |
| 267 | + @include it("Should return prefixed custom selector.") { |
| 268 | + @include assert { |
| 269 | + @include output(false) { |
| 270 | + @include css.selector("md", $selector: ".foo") { |
| 271 | + color: darkcyan; |
| 272 | + } |
| 273 | + } |
| 274 | + |
| 275 | + @include expect(false) { |
| 276 | + .md\:foo { |
| 277 | + color: darkcyan; |
| 278 | + } |
| 279 | + } |
| 280 | + } |
| 281 | + } |
| 282 | + |
| 283 | + @include it("Should return prefixed custom selector with custom separator.") { |
| 284 | + @include assert { |
| 285 | + @include output(false) { |
| 286 | + @include css.selector("md", "@", $selector: ".foo") { |
| 287 | + color: darkcyan; |
| 288 | + } |
| 289 | + } |
| 290 | + |
| 291 | + @include expect(false) { |
| 292 | + .md\@foo { |
| 293 | + color: darkcyan; |
| 294 | + } |
| 295 | + } |
| 296 | + } |
| 297 | + } |
| 298 | + |
| 299 | + @include it("Should return suffixed custom selector.") { |
| 300 | + @include assert { |
| 301 | + @include output(false) { |
| 302 | + @include css.selector("md", $suffix: true, $selector: ".foo") { |
| 303 | + color: darkcyan; |
| 304 | + } |
| 305 | + } |
| 306 | + |
| 307 | + @include expect(false) { |
| 308 | + .foo\:md { |
| 309 | + color: darkcyan; |
| 310 | + } |
| 311 | + } |
| 312 | + } |
| 313 | + } |
| 314 | + |
| 315 | + @include it("Should return suffixed custom selector with custom separator.") { |
| 316 | + @include assert { |
| 317 | + @include output(false) { |
| 318 | + @include css.selector("md", "@", true, ".foo") { |
| 319 | + color: darkcyan; |
| 320 | + } |
| 321 | + } |
| 322 | + |
| 323 | + @include expect(false) { |
| 324 | + .foo\@md { |
| 325 | + color: darkcyan; |
| 326 | + } |
| 327 | + } |
| 328 | + } |
| 329 | + } |
| 330 | + } |
| 331 | +} |
0 commit comments