Skip to content

Commit

Permalink
chore: fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
iam-medvedev committed Sep 15, 2023
1 parent 4ae859e commit fbb60b8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions __tests__/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ exports[`less-loader > builds imported ._less_ files 1`] = `
`;

exports[`less-loader > builds imported .css files 1`] = `
"#style-5-css{position:-webkit-sticky;position:sticky;background:url(data:image/png;base64,iVBORw0KGgoAAAAASURBVA==) no-repeat}#style-4-css{display:none}.style-3-less{color:red}.style-2-less{color:red;background:url(data:image/jpeg;base64,/9j/) no-repeat}body{background:#ff0000}body article{width:100px}body article:first-child{width:200px}
"#style-5-css{position:-webkit-sticky;position:sticky;background:url(data:image/png;base64,iVBORw0KGgoAAAAASURBVA==) no-repeat}#style-4-css{display:none}.style-3-less{color:red}.style-2-less{color:red;background:url(data:image/jpeg;base64,/9j/) no-repeat}.index-style{transition:.2s all cubic-bezier(.075,.82,.165,1)}body{background:#ff0000}body article{width:100px}body article:first-child{width:200px}
"
`;

exports[`less-loader > builds imported .less files 1`] = `
"#style-5-css{position:-webkit-sticky;position:sticky;background:url(data:image/png;base64,iVBORw0KGgoAAAAASURBVA==) no-repeat}#style-4-css{display:none}.style-3-less{color:red}.style-2-less{color:red;background:url(data:image/jpeg;base64,/9j/) no-repeat}body{background:#ff0000}body article{width:100px}body article:first-child{width:200px}
"#style-5-css{position:-webkit-sticky;position:sticky;background:url(data:image/png;base64,iVBORw0KGgoAAAAASURBVA==) no-repeat}#style-4-css{display:none}.style-3-less{color:red}.style-2-less{color:red;background:url(data:image/jpeg;base64,/9j/) no-repeat}.index-style{transition:.2s all cubic-bezier(.075,.82,.165,1)}body{background:#ff0000}body article{width:100px}body article:first-child{width:200px}
"
`;

exports[`less-loader > builds successful 1`] = `
"#style-5-css{position:-webkit-sticky;position:sticky;background:url(data:image/png;base64,iVBORw0KGgoAAAAASURBVA==) no-repeat}#style-4-css{display:none}.style-3-less{color:red}.style-2-less{color:red;background:url(data:image/jpeg;base64,/9j/) no-repeat}body{background:#ff0000}body article{width:100px}body article:first-child{width:200px}
"#style-5-css{position:-webkit-sticky;position:sticky;background:url(data:image/png;base64,iVBORw0KGgoAAAAASURBVA==) no-repeat}#style-4-css{display:none}.style-3-less{color:red}.style-2-less{color:red;background:url(data:image/jpeg;base64,/9j/) no-repeat}.index-style{transition:.2s all cubic-bezier(.075,.82,.165,1)}body{background:#ff0000}body article{width:100px}body article:first-child{width:200px}
"
`;

Expand All @@ -26,7 +26,7 @@ exports[`less-loader > builds successful custom filter 1`] = `
`;

exports[`less-loader > builds successful with less as entrypoint 1`] = `
"#style-5-css{position:-webkit-sticky;position:sticky;background:url(data:image/png;base64,iVBORw0KGgoAAAAASURBVA==) no-repeat}#style-4-css{display:none}.style-3-less{color:red}.style-2-less{color:red;background:url(data:image/jpeg;base64,/9j/) no-repeat}body{background:#ff0000}body article{width:100px}body article:first-child{width:200px}
"#style-5-css{position:-webkit-sticky;position:sticky;background:url(data:image/png;base64,iVBORw0KGgoAAAAASURBVA==) no-repeat}#style-4-css{display:none}.style-3-less{color:red}.style-2-less{color:red;background:url(data:image/jpeg;base64,/9j/) no-repeat}.index-style{transition:.2s all cubic-bezier(.075,.82,.165,1)}body{background:#ff0000}body article{width:100px}body article:first-child{width:200px}
"
`;

Expand Down
2 changes: 2 additions & 0 deletions __tests__/less-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('less-utils', () => {
expect.stringContaining('styles/inner/style-3.less'),
expect.stringContaining('styles/inner/style-4.css'),
expect.stringContaining('styles/inner/style-5.css'),
expect.stringContaining('styles/without-ext.less'),
]),
);
});
Expand All @@ -27,6 +28,7 @@ describe('less-utils', () => {
expect.stringContaining('styles/inner/style-3.less'),
expect.stringContaining('styles/inner/style-4.css'),
expect.stringContaining('styles/inner/style-5.css'),
expect.stringContaining('styles/without-ext.less'),
]),
);
});
Expand Down
1 change: 1 addition & 0 deletions example/styles/style.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import './style-2.less';
@import './inner/style-4.css';
@import './without-ext';

body {
background: @primaryColor; // This var is defined in build.ts
Expand Down
3 changes: 3 additions & 0 deletions example/styles/without-ext.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.index-style {
transition: 0.2s all cubic-bezier(0.075, 0.82, 0.165, 1);
}
2 changes: 2 additions & 0 deletions src/less-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export const getLessImports = (filePath: string, paths: string[] = []): string[]
// Assume the file exists at the default import. If it does not, check relative to provided
// import paths too, and take the first path that resolves to a real file.
let filepath = path.resolve(dir, path.extname(el) ? el : `${el}.less`);
// NOTE: it's actually covered
/* c8 ignore next 9 */
if (!fs.existsSync(filepath)) {
for (let i = 0; i < paths.length; i++) {
const f = path.resolve(paths[i], path.extname(el) ? el : `${el}.less`);
Expand Down

0 comments on commit fbb60b8

Please sign in to comment.