Skip to content

Commit

Permalink
add tests for first class mixins
Browse files Browse the repository at this point in the history
  • Loading branch information
connorskees committed Aug 25, 2023
1 parent 2918dab commit ad782cd
Show file tree
Hide file tree
Showing 11 changed files with 1,038 additions and 0 deletions.
40 changes: 40 additions & 0 deletions spec/core_functions/meta/accepts_content.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<===> accepts/direct-child/input.scss
@use "sass:meta";

@mixin foo() {
@content;
}

a {b: meta.accepts-content(meta.get-mixin("foo"))}

<===> accepts/direct-child/output.css
a {
b: true;
}

<===> accepts/nested-child/input.scss
@use "sass:meta";

@mixin foo() {
@if false {
@content;
}
}

a {b: meta.accepts-content(meta.get-mixin("foo"))}

<===> accepts/nested-child/output.css
a {
b: true;
}

<===> doesnt-accept/empty/input.scss
@use "sass:meta";
@mixin foo() {}

a {b: meta.accepts-content(meta.get-mixin("foo"))}

<===> doesnt-accept/empty/output.css
a {
b: false;
}
1 change: 1 addition & 0 deletions spec/core_functions/meta/apply.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// todo
1 change: 1 addition & 0 deletions spec/core_functions/meta/get_mixin/content.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// todo
137 changes: 137 additions & 0 deletions spec/core_functions/meta/get_mixin/different_module.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<===>
================================================================================
<===> defined/input.scss
@use "sass:meta";
@use "foo";
a {@include meta.apply(meta.get-mixin("foo", $module: "color"), #abcdef)}

<===> chosen_prefix/foo.scss
@mixin foo($color) {
b: red($color)
}

<===> defined/output.css
a {
b: 171;
}

<===>
================================================================================
<===> chosen_prefix/input.scss
@use "sass:meta";
@use "foo" as a;
b {@include meta.apply(meta.get-mixin("foo", $module: "a"), #abcdef)}

<===> chosen_prefix/foo.scss
@mixin foo($color) {
c: red($color)
}

<===> chosen_prefix/output.css
b {
c: 171;
}

<===>
================================================================================
<===> through_use/input.scss
@use "sass:meta";
@use "other" as *;
a {@include meta.apply(meta.get-mixin(add-two), 10)}

<===> through_use/other.scss
@mixin add-two($v) {b: $v + 2}

<===> through_use/output.css
a {
b: 12;
}

<===>
================================================================================
<===> through_forward/bare/input.scss
@use "sass:meta";
@use "midstream" as *;
a {@include meta.apply(meta.get-mixin(c))}

<===> through_forward/bare/_midstream.scss
@forward "upstream";

<===> through_forward/bare/_upstream.scss
@mixin c() {b: c}

<===> through_forward/bare/output.css
a {
b: c;
}

<===>
================================================================================
<===> through_forward/as/input.scss
@use "sass:meta";
@use "midstream" as *;
a {@include meta.apply(meta.get-mixin(c-d))}

<===> through_forward/as/_midstream.scss
@forward "upstream" as c-*;

<===> through_forward/as/_upstream.scss
@mixin d() {b: d}

<===> through_forward/as/output.css
a {
b: d;
}

<===>
================================================================================
<===> through_forward/show/input.scss
@use "sass:meta";
@use "midstream" as *;
a {@include meta.apply(meta.get-mixin(c))}

<===> through_forward/show/_midstream.scss
@forward "upstream" show c;

<===> through_forward/show/_upstream.scss
@mixin c() {b: c}

<===> through_forward/show/output.css
a {
b: c;
}

<===>
================================================================================
<===> through_forward/hide/input.scss
@use "sass:meta";
@use "midstream" as *;
a {@include meta.apply(meta.get-mixin(d))}

<===> through_forward/hide/_midstream.scss
@forward "upstream" hide c;

<===> through_forward/hide/_upstream.scss
@mixin d() {b: d}

<===> through_forward/hide/output.css
a {
b: d;
}

<===>
================================================================================
<===> named/input.scss
@use "sass:meta";
@use "foo";
a {@include meta.apply(meta.get-mixin($name: "foo", $module: "color"), #abcdef)}

<===> named/foo.scss
@mixin foo($color) {
b: red($color)
}

<===> named/output.css
a {
b: 171;
}
74 changes: 74 additions & 0 deletions spec/core_functions/meta/get_mixin/equality.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<===> same_value/input.scss
@use "sass:meta";
@mixin foo() {}
$a: meta.get-mixin(foo);
a {b: $a == $a}

<===> same_value/output.css
a {
b: true;
}

<===>
================================================================================
<===> built_in/same/input.scss
@use "sass:meta";
a {b: meta.get-mixin(load-css, meta) == meta.get-mixin(load-css, meta)}

<===> built_in/same/output.css
a {
b: true;
}

<===>
================================================================================
<===> built_in/different/input.scss
@use "sass:meta";
@mixin foo() {}
a {b: meta.get-mixin(load-css, meta) == meta.get-mixin(foo)}

<===> built_in/different/output.css
a {
b: false;
}

<===>
================================================================================
<===> user_defined/same/input.scss
@use "sass:meta";
@mixin user-defined() {}
a {b: meta.get-mixin(user-defined) == meta.get-mixin(user-defined)}

<===> user_defined/same/output.css
a {
b: true;
}

<===>
================================================================================
<===> user_defined/different/input.scss
@use "sass:meta";
@mixin user-defined-1() {}
@mixin user-defined-2() {}
a {b: meta.get-mixin(user-defined-1) == meta.get-mixin(user-defined-2)}

<===> user_defined/different/output.css
a {
b: false;
}

<===>
================================================================================
<===> user_defined/redefined/input.scss
@use "sass:meta";
@mixin user-defined() {}
$first-reference: meta.get-mixin(user-defined);

@mixin user-defined() {}
$second-reference: meta.get-mixin(user-defined);
a {b: $first-reference == $second-reference}

<===> user_defined/redefined/output.css
a {
b: false;
}
Loading

0 comments on commit ad782cd

Please sign in to comment.