Skip to content

Commit

Permalink
Add regression test for sass/dart-sass#2208
Browse files Browse the repository at this point in the history
  • Loading branch information
ntkme committed Apr 5, 2024
1 parent ffcdf8c commit 8c16533
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/custom_importer_test.rb
Expand Up @@ -37,6 +37,16 @@ def imports(_path, parent_path)
end
end

class ParentDirImporter < Importer
def imports(path, parent_path)
if path.include?('path')
Import.new('path.scss', source: "a { from: #{File.basename(File.dirname(parent_path))}; }")
else
Import.new(path)
end
end
end

def test_custom_importer_works
temp_file('styles2.scss', '.hi { color: $var1; }')
temp_file('fonts.scss', '.font { color: $var1; }')
Expand Down Expand Up @@ -87,6 +97,33 @@ def test_custom_importer_works_for_file_in_parent_dir
CSS
end

# regression test for https://github.com/sass/dart-sass/issues/2208
def test_custom_importer_works_for_imports_with_same_name
temp_dir('sub1')
temp_dir('sub1/sub2')
temp_file('sub1/test.scss', '@import "path";')
temp_file('sub1/sub2/test.scss', '@import "path";')

data = <<~SCSS
@import "sub1/test";
@import "sub1/sub2/test";
SCSS

engine = Engine.new(data, {
importer: ParentDirImporter
})

assert_equal <<~CSS, engine.render
a {
from: sub1;
}
a {
from: sub2;
}
CSS
end

def test_dependency_list
base = Dir.pwd

Expand Down

0 comments on commit 8c16533

Please sign in to comment.