Skip to content

Commit

Permalink
test: alias on directory with _index file (#727)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Aug 16, 2019
1 parent 6be93c8 commit 071fa88
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 1 deletion.
34 changes: 34 additions & 0 deletions test/helpers/getCodeFromSass.js
Expand Up @@ -190,6 +190,22 @@ function getCodeFromSass(testId, options) {
testFolder,
'node_modules/sass-main-field/nested/style.sass'
);
const pathToSCSSAlias = path.resolve(
testFolder,
'scss/directory-6/file/_index.scss'
);
const pathToSassAlias = path.resolve(
testFolder,
'sass/directory-6/file/_index.sass'
);
const pathToSCSSIndexAlias = path.resolve(
testFolder,
'scss/dir-with-underscore-index/_index.scss'
);
const pathToSassIndexAlias = path.resolve(
testFolder,
'sass/dir-with-underscore-index/_index.sass'
);
const pathToScopedNpmPkg = path.resolve(
testFolder,
'node_modules/@org/pkg/index.scss'
Expand Down Expand Up @@ -628,6 +644,24 @@ function getCodeFromSass(testId, options) {
.replace(/^~sass-main-field/, pathToSassMainField)
.replace(/^~scss-custom-sass-field/, pathToSCSSCustomSassField)
.replace(/^~sass-custom-sass-field/, pathToSassCustomSassField)
.replace(/^~@scss$/, pathToSCSSAlias)
.replace(/^~@sass$/, pathToSassAlias)
.replace(
/^~@path-to-scss-dir\/dir-with-underscore-index$/,
pathToSCSSIndexAlias
)
.replace(
/^~@path-to-sass-dir\/dir-with-underscore-index$/,
pathToSassIndexAlias
)
.replace(
/^~@\/path-to-scss-dir\/dir-with-underscore-index$/,
pathToSCSSIndexAlias
)
.replace(
/^~@\/path-to-sass-dir\/dir-with-underscore-index$/,
pathToSassIndexAlias
)
.replace(/^~@org\/pkg/, pathToScopedNpmPkg)
.replace(/^~bootstrap-sass$/, pathToBootstrap3Entry)
.replace(/^~bootstrap-sass/, pathToBootstrap3Package)
Expand Down
18 changes: 18 additions & 0 deletions test/loader.test.js
Expand Up @@ -549,6 +549,24 @@ describe('loader', () => {
'another',
`alias.${syntax}`
),
'@sass': path.resolve(
__dirname,
'sass',
'directory-6',
'file',
'_index.sass'
),
'@scss': path.resolve(
__dirname,
'scss',
'directory-6',
'file',
`_index.scss`
),
'@path-to-scss-dir': path.resolve(__dirname, 'scss'),
'@path-to-sass-dir': path.resolve(__dirname, 'sass'),
'@/path-to-scss-dir': path.resolve(__dirname, 'scss'),
'@/path-to-sass-dir': path.resolve(__dirname, 'sass'),
},
},
loader: { options },
Expand Down
2 changes: 2 additions & 0 deletions test/sass/dir-with-underscore-index/_index.sass
@@ -0,0 +1,2 @@
.dir-with-underscore-index
color: red
5 changes: 4 additions & 1 deletion test/sass/import-alias.sass
@@ -1 +1,4 @@
@import path-to-alias
@import 'path-to-alias'
@import "~@sass"
@import "~@path-to-sass-dir/dir-with-underscore-index"
@import "~@/path-to-sass-dir/dir-with-underscore-index"
3 changes: 3 additions & 0 deletions test/scss/dir-with-underscore-index/_index.scss
@@ -0,0 +1,3 @@
.dir-with-underscore-index {
color: red;
}
3 changes: 3 additions & 0 deletions test/scss/import-alias.scss
@@ -1 +1,4 @@
@import 'path-to-alias';
@import "~@scss";
@import "~@path-to-scss-dir/dir-with-underscore-index";
@import "~@/path-to-scss-dir/dir-with-underscore-index";

0 comments on commit 071fa88

Please sign in to comment.