Skip to content

Commit 83149e8

Browse files
committed
test: Refactor module import tests
In preparation for #573 Imports without file extensions are deprecated in LibSass and even not supported in DartSass.
1 parent d0b35cb commit 83149e8

File tree

8 files changed

+16
-10
lines changed

8 files changed

+16
-10
lines changed

test/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ describe("sass-loader", () => {
205205
sourceMap.should.not.have.property("file");
206206
sourceMap.should.have.property("sourceRoot", fakeCwd);
207207
// This number needs to be updated if imports.scss or any dependency of that changes
208-
sourceMap.sources.should.have.length(13);
208+
sourceMap.sources.should.have.length(12);
209209
sourceMap.sources.forEach(sourcePath =>
210210
fs.existsSync(path.resolve(sourceMap.sourceRoot, sourcePath))
211211
);

test/node_modules/another/package.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

test/node_modules/module/package.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/node_modules/other-module

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/sass/imports.sass

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
/* scoped import @import language */
1919
.scoped-imporr
2020
@import language
21+
2122
// The local util file should take precedence over Node's util module
2223
// See https://github.com/webpack-contrib/sass-loader/issues/556
2324
/* @import util */
2425
@import util
2526
/* @import ~module */
2627
@import ~module
27-
/* @import ~other-module */
28-
@import ~other-module
28+
/* @import ~another */
29+
@import ~another

test/scss/imports.scss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/* @import "another/module"; */
22
@import "another/module";
3-
/* @import "~another/module"; */
4-
@import "~another/module";
53
/* @import "another/underscore"; */
64
@import "another/underscore";
75
/* @import "another/_underscore"; */
@@ -27,5 +25,5 @@
2725
@import "util";
2826
/* @import "~module"; */
2927
@import "~module";
30-
/* @import "~other-module"; */
31-
@import "~other-module";
28+
/* @import "~another"; */
29+
@import "~another";

test/tools/createSpec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ function createSpec(ext) {
1515
const testNodeModules = path.relative(basePath, path.join(testFolder, "node_modules")) + path.sep;
1616
const pathToBootstrap = path.relative(basePath, path.resolve(testFolder, "..", "node_modules", "bootstrap-sass"));
1717
const pathToScopedNpmPkg = path.relative(basePath, path.resolve(testFolder, "node_modules", "@org", "pkg", "./index.scss"));
18+
const pathToModule = path.relative(basePath, path.resolve(testFolder, "node_modules", "module", "module.scss"));
19+
const pathToAnother = path.relative(basePath, path.resolve(testFolder, "node_modules", "another", "module.scss"));
1820
const pathToFooAlias = path.relative(basePath, path.resolve(testFolder, ext, "another", "alias." + ext));
1921

2022
fs.readdirSync(path.join(testFolder, ext))
@@ -33,6 +35,8 @@ function createSpec(ext) {
3335
url = url
3436
.replace(/^~bootstrap-sass/, pathToBootstrap)
3537
.replace(/^~@org\/pkg/, pathToScopedNpmPkg)
38+
.replace(/^~module/, pathToModule)
39+
.replace(/^~another/, pathToAnother)
3640
.replace(/^~/, testNodeModules)
3741
.replace(/^path-to-alias/, pathToFooAlias);
3842
}

0 commit comments

Comments
 (0)