Skip to content

Commit

Permalink
Add spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ntkme committed Sep 29, 2023
1 parent ede20fd commit bb9ba26
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec/sass/value/argument_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
expect { list.assert_function }.to raise_error(Sass::ScriptError)
expect { list.assert_map }.to raise_error(Sass::ScriptError)
expect(list.to_map).to be_nil
expect { list.assert_mixin }.to raise_error(Sass::ScriptError)
expect { list.assert_number }.to raise_error(Sass::ScriptError)
expect { list.assert_string }.to raise_error(Sass::ScriptError)
end
Expand Down
2 changes: 2 additions & 0 deletions spec/sass/value/boolean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
expect { value.assert_function }.to raise_error(Sass::ScriptError)
expect { value.assert_map }.to raise_error(Sass::ScriptError)
expect(value.to_map).to be_nil
expect { value.assert_mixin }.to raise_error(Sass::ScriptError)
expect { value.assert_number }.to raise_error(Sass::ScriptError)
expect { value.assert_string }.to raise_error(Sass::ScriptError)
end
Expand Down Expand Up @@ -58,6 +59,7 @@
expect { value.assert_function }.to raise_error(Sass::ScriptError)
expect { value.assert_map }.to raise_error(Sass::ScriptError)
expect(value.to_map).to be_nil
expect { value.assert_mixin }.to raise_error(Sass::ScriptError)
expect { value.assert_number }.to raise_error(Sass::ScriptError)
expect { value.assert_string }.to raise_error(Sass::ScriptError)
end
Expand Down
1 change: 1 addition & 0 deletions spec/sass/value/calculation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
expect { calculation.assert_function }.to raise_error(Sass::ScriptError)
expect { calculation.assert_map }.to raise_error(Sass::ScriptError)
expect(calculation.to_map).to be_nil
expect { calculation.assert_mixin }.to raise_error(Sass::ScriptError)
expect { calculation.assert_number }.to raise_error(Sass::ScriptError)
expect { calculation.assert_string }.to raise_error(Sass::ScriptError)
end
Expand Down
1 change: 1 addition & 0 deletions spec/sass/value/color_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def hwb(hue, whiteness, blackness, alpha = nil)
expect { color.assert_function }.to raise_error(Sass::ScriptError)
expect { color.assert_map }.to raise_error(Sass::ScriptError)
expect(color.to_map).to be_nil
expect { color.assert_mixin }.to raise_error(Sass::ScriptError)
expect { color.assert_number }.to raise_error(Sass::ScriptError)
expect { color.assert_string }.to raise_error(Sass::ScriptError)
end
Expand Down
1 change: 1 addition & 0 deletions spec/sass/value/list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
expect { list.assert_function }.to raise_error(Sass::ScriptError)
expect { list.assert_map }.to raise_error(Sass::ScriptError)
expect(list.to_map).to be_nil
expect { list.assert_mixin }.to raise_error(Sass::ScriptError)
expect { list.assert_number }.to raise_error(Sass::ScriptError)
expect { list.assert_string }.to raise_error(Sass::ScriptError)
end
Expand Down
1 change: 1 addition & 0 deletions spec/sass/value/map_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
expect { map.assert_calculation }.to raise_error(Sass::ScriptError)
expect { map.assert_color }.to raise_error(Sass::ScriptError)
expect { map.assert_function }.to raise_error(Sass::ScriptError)
expect { map.assert_mixin }.to raise_error(Sass::ScriptError)
expect { map.assert_number }.to raise_error(Sass::ScriptError)
expect { map.assert_string }.to raise_error(Sass::ScriptError)
end
Expand Down
37 changes: 37 additions & 0 deletions spec/sass/value/mixin_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

require 'spec_helper'

describe Sass::Value::Mixin do
it 'can round-trip a mixin reference from Sass' do
skip 'TODO: enable after dart-sass release'

fn = double
allow(fn).to receive(:call) { |args|
expect(args.length).to eq(1)
expect(args[0]).to be_a(described_class)
args[0]
}

expect(
Sass.compile_string(
"
@use 'sass:meta';
@mixin a() {
a {
b: c;
}
}
@include meta.apply(foo(meta.get-mixin('a')));
",
functions: {
'foo($arg)': fn
}
).css
).to eq("a {\n b: c;\n}")

expect(fn).to have_received(:call)
end
end
1 change: 1 addition & 0 deletions spec/sass/value/null_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
expect { value.assert_function }.to raise_error(Sass::ScriptError)
expect { value.assert_map }.to raise_error(Sass::ScriptError)
expect(value.to_map).to be_nil
expect { value.assert_mixin }.to raise_error(Sass::ScriptError)
expect { value.assert_number }.to raise_error(Sass::ScriptError)
expect { value.assert_string }.to raise_error(Sass::ScriptError)
end
Expand Down
1 change: 1 addition & 0 deletions spec/sass/value/number_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
expect { number.assert_function }.to raise_error(Sass::ScriptError)
expect { number.assert_map }.to raise_error(Sass::ScriptError)
expect(number.to_map).to be_nil
expect { number.assert_mixin }.to raise_error(Sass::ScriptError)
expect { number.assert_string }.to raise_error(Sass::ScriptError)
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/sass/value/string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
expect { value.assert_function }.to raise_error(Sass::ScriptError)
expect { value.assert_map }.to raise_error(Sass::ScriptError)
expect(value.to_map).to be_nil
expect { value.assert_mixin }.to raise_error(Sass::ScriptError)
expect { value.assert_number }.to raise_error(Sass::ScriptError)
end
end
Expand Down

0 comments on commit bb9ba26

Please sign in to comment.