Skip to content

Commit

Permalink
Add tests for MultiSpan
Browse files Browse the repository at this point in the history
  • Loading branch information
ntkme committed Sep 15, 2022
1 parent 5dadbd9 commit 741be51
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
12 changes: 12 additions & 0 deletions spec/sass_compile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,18 @@
end
end
end

it 'with multi-span errors' do
sandbox do |dir|
url = dir.url('foo.scss')
expect { described_class.compile_string('@use "sass:math"; @use "sass:math"', url: url) }
.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.span.start.line).to eq(0)
expect(error.span.url).to eq(url)
end
end
end
end

it 'throws an error for an unrecognized style' do
Expand Down
21 changes: 21 additions & 0 deletions spec/sass_logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@
expect(stdio.err).not_to be_empty
end

describe 'deprecation warning' do
# Regression test for sass/dart-sass#1790
it 'passes the message and span to the logger' do
described_class.compile_string(
'
@mixin foo {@warn heck}
@include foo;
',
logger: {
warn: lambda { |message, span:|
expect(message).to eq('only valid for nesting')
expect(span.start.line).to be(0)
expect(span.start.column).to be(0)
expect(span.end.line).to be(0)
expect(span.end.line).to be(4)
}
}
)
end
end

describe 'with @warn' do
it 'passes the message and stack trace to the logger' do
described_class.compile_string(
Expand Down

0 comments on commit 741be51

Please sign in to comment.