|
@@ -401,3 +401,56 @@ test('media query as child', (t) => {
|
401
|
401
|
);
|
402
|
402
|
}
|
403
|
403
|
});
|
|
404
|
+
|
|
405
|
+test('mixin as child', (t) => {
|
|
406
|
+ t.plan(2);
|
|
407
|
+ const result = parse('(div (@mixin m () (div :color blue)))');
|
|
408
|
+ t.false(result instanceof ParserError);
|
|
409
|
+ if (!(result instanceof LexerError) && !(result instanceof ParserError)) {
|
|
410
|
+ t.deepEqual(
|
|
411
|
+ result.tree[0],
|
|
412
|
+ new AST.RuleSet(
|
|
413
|
+ [new AST.Selector(literalToken('div'))],
|
|
414
|
+ [
|
|
415
|
+ new AST.Mixin(
|
|
416
|
+ literalToken('m'),
|
|
417
|
+ [],
|
|
418
|
+ [
|
|
419
|
+ new AST.RuleSet(
|
|
420
|
+ [new AST.Selector(literalToken('div'))],
|
|
421
|
+ [new AST.Rule(property('color'), literalNode('blue'))]
|
|
422
|
+ ),
|
|
423
|
+ ]
|
|
424
|
+ )
|
|
425
|
+ ]
|
|
426
|
+ )
|
|
427
|
+ );
|
|
428
|
+ }
|
|
429
|
+});
|
|
430
|
+
|
|
431
|
+test('define a mixin inside another mixin', (t) => {
|
|
432
|
+ t.plan(2);
|
|
433
|
+ const result = parse('(@mixin outer ($x) (@mixin inner ($y) (div :color $y)))');
|
|
434
|
+ t.false(result instanceof ParserError);
|
|
435
|
+ if (!(result instanceof LexerError) && !(result instanceof ParserError)) {
|
|
436
|
+ t.deepEqual(
|
|
437
|
+ result.tree[0],
|
|
438
|
+ new AST.Mixin(
|
|
439
|
+ literalToken('outer'),
|
|
440
|
+ [identifierNode('x')],
|
|
441
|
+ [
|
|
442
|
+ new AST.Mixin(
|
|
443
|
+ literalToken('inner'),
|
|
444
|
+ [identifierNode('y')],
|
|
445
|
+ [
|
|
446
|
+ new AST.RuleSet(
|
|
447
|
+ [new AST.Selector(literalToken('div'))],
|
|
448
|
+ [new AST.Rule(property('color'), identifierNode('y'))]
|
|
449
|
+ ),
|
|
450
|
+ ]
|
|
451
|
+ ),
|
|
452
|
+ ]
|
|
453
|
+ )
|
|
454
|
+ );
|
|
455
|
+ }
|
|
456
|
+});
|