Skip to content

Commit

Permalink
Update specs for @import/global builtins deprecations (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntkme committed Jul 19, 2024
1 parent 0e1956c commit a5f980a
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 61 deletions.
12 changes: 6 additions & 6 deletions spec/sass/compiler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

describe 'compile_string' do
it 'performs complete compilations' do
result = compiler.compile_string('@import "bar"; .fn {value: foo(baz)}', importers:, functions:, logger:)
result = compiler.compile_string('@use "bar"; .fn {value: foo(baz)}', importers:, functions:, logger:)
expect(result.css).to eq(".import {\n value: bar;\n}\n\n.fn {\n value: baz;\n}")
expect(logger_instance_double).to have_received(:call).once
end
Expand All @@ -61,7 +61,7 @@
end
}

result = compiler.compile_string('@import "nested"; a {b: c}', importers: [nested_importer])
result = compiler.compile_string('@use "nested"; a {b: c}', importers: [nested_importer])
expect(result.css).to eq("x {\n y: z;\n}\n\na {\n b: c;\n}")
end

Expand All @@ -79,7 +79,7 @@
it 'handles multiple concurrent compilations' do
results = Array.new(100) do |i|
Thread.new do
compiler.compile_string("@import \"#{i}\"; .fn {value: foo(#{i})}",
compiler.compile_string("@use \"#{i}\" as _; .fn {value: foo(#{i})}",
importers:, functions:, logger: Sass::Logger.silent)
end
end.map(&:value)
Expand All @@ -93,7 +93,7 @@
describe 'compile' do
it 'performs complete compilations' do
sandbox do |dir|
dir.write({ 'input.scss' => '@import "bar"; .fn {value: foo(bar)}' })
dir.write({ 'input.scss' => '@use "bar"; .fn {value: foo(bar)}' })
result = compiler.compile(dir.path('input.scss'), importers:, functions:, logger:)
expect(result.css).to eq(".import {\n value: bar;\n}\n\n.fn {\n value: bar;\n}")
expect(logger_instance_double).to have_received(:call).once
Expand All @@ -113,7 +113,7 @@
end
}

dir.write({ 'input.scss' => '@import "nested"; a {b: c}' })
dir.write({ 'input.scss' => '@use "nested"; a {b: c}' })
result = compiler.compile(dir.path('input.scss'), importers: [nested_importer])
expect(result.css).to eq("x {\n y: z;\n}\n\na {\n b: c;\n}")
end
Expand All @@ -132,7 +132,7 @@
results = Array.new(100) do |i|
Thread.new do
filename = "input-#{i}.scss"
dir.write({ filename => "@import \"#{i}\"; .fn {value: foo(#{i})}" })
dir.write({ filename => "@use \"#{i}\" as _; .fn {value: foo(#{i})}" })
compiler.compile(dir.path(filename),
importers:, functions:, logger: Sass::Logger.silent)
end
Expand Down
4 changes: 3 additions & 1 deletion spec/sass_compile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@
'_right.scss' => '@import "upstream"',
'_upstream.scss' => 'a {b: c}'
})
expect(described_class.compile_string('@import "left"; @import "right"', url:).loaded_urls)
expect(described_class.compile_string('@import "left"; @import "right"',
url:,
silence_deprecations: ['import']).loaded_urls)
.to eq([
url,
dir.url('_left.scss'),
Expand Down
Loading

0 comments on commit a5f980a

Please sign in to comment.