File tree 2 files changed +94
-1
lines changed
2 files changed +94
-1
lines changed Original file line number Diff line number Diff line change @@ -80,3 +80,45 @@ describe('rejects a function signature that', () => {
80
80
it ( 'has no closing parenthesis' , ( ) => rejectsSignature ( 'foo(' ) ) ;
81
81
it ( 'has a non-identifier name' , ( ) => rejectsSignature ( '$foo()' ) ) ;
82
82
} ) ;
83
+
84
+ it ( 'rejects a compiler function from a different compilation' , ( ) => {
85
+ let plusOne : Value | undefined ;
86
+ compileString (
87
+ `
88
+ @use 'sass:meta';
89
+
90
+ @function plusOne($n) {@return $n + 1}
91
+ a {b: meta.call(foo(meta.get-function('plusOne')), 2)}
92
+ ` ,
93
+ {
94
+ functions : {
95
+ 'foo($arg)' : ( args : Value [ ] ) => {
96
+ plusOne = args [ 0 ] ;
97
+ return plusOne ;
98
+ } ,
99
+ } ,
100
+ }
101
+ ) ;
102
+
103
+ let plusTwo ;
104
+ expect ( ( ) => {
105
+ compileString (
106
+ `
107
+ @use 'sass:meta';
108
+
109
+ @function plusTwo($n) {@return $n + 2}
110
+ a {b: meta.call(foo(meta.get-function('plusTwo')), 2)}
111
+ ` ,
112
+ {
113
+ functions : {
114
+ 'foo($arg)' : ( args : Value [ ] ) => {
115
+ plusTwo = args [ 0 ] ;
116
+ return plusOne ! ;
117
+ } ,
118
+ } ,
119
+ }
120
+ ) ;
121
+ } ) . toThrowSassException ( { line : 4 } ) ;
122
+
123
+ expect ( plusOne ) . not . toEqual ( plusTwo ) ;
124
+ } ) ;
Original file line number Diff line number Diff line change 2
2
// MIT-style license that can be found in the LICENSE file or at
3
3
// https://opensource.org/licenses/MIT.
4
4
5
- import { SassMixin , compileString } from 'sass' ;
5
+ import { SassMixin , compileString , Value } from 'sass' ;
6
6
7
7
import { spy } from '../utils' ;
8
8
@@ -44,3 +44,54 @@ it('can round-trip a mixin reference from Sass', () => {
44
44
45
45
expect ( fn ) . toHaveBeenCalled ( ) ;
46
46
} ) ;
47
+
48
+ it ( 'rejects a compiler mixin from a different compilation' , ( ) => {
49
+ let a : Value | undefined ;
50
+ compileString (
51
+ `
52
+ @use 'sass:meta';
53
+
54
+ @mixin a() {
55
+ a {
56
+ b: c;
57
+ }
58
+ }
59
+
60
+ @include meta.apply(foo(meta.get-mixin('a')));
61
+ ` ,
62
+ {
63
+ functions : {
64
+ 'foo($arg)' : ( args : Value [ ] ) => {
65
+ a = args [ 0 ] ;
66
+ return a ;
67
+ } ,
68
+ } ,
69
+ }
70
+ ) ;
71
+
72
+ let b ;
73
+ expect ( ( ) => {
74
+ compileString (
75
+ `
76
+ @use 'sass:meta';
77
+
78
+ @mixin b() {
79
+ c {
80
+ d: e;
81
+ }
82
+ }
83
+ @include meta.apply(foo(meta.get-mixin('b')));
84
+ ` ,
85
+ {
86
+ functions : {
87
+ 'foo($arg)' : ( args : Value [ ] ) => {
88
+ b = args [ 0 ] ;
89
+ return a ! ;
90
+ } ,
91
+ } ,
92
+ }
93
+ ) ;
94
+ } ) . toThrowSassException ( { line : 8 } ) ;
95
+
96
+ expect ( a ) . not . toEqual ( b ) ;
97
+ } ) ;
You can’t perform that action at this time.
0 commit comments