Skip to content

Commit

Permalink
Merge pull request #16 from 42tte/42tte/test-resolve-package-json-filter
Browse files Browse the repository at this point in the history
42tte/test resolve package json filter
  • Loading branch information
revelt committed Aug 25, 2023
2 parents 5547806 + d04b493 commit 6afdfeb
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
.DS_Store

# dependencies
node_modules
/node_modules/
.npm

# logs
Expand Down
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
- enable import from `node_modules` - thanks [Kristoffer Nordström](https://github.com/42tte)
- allow use of CSS [url() function syntax](https://developer.mozilla.org/en-US/docs/Web/CSS/url) - thanks [Kristoffer Nordström](https://github.com/42tte)


For example:

```css
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"homepage": "https://github.com/eriklharper/postcss-nested-import",
"scripts": {
"unit": "uvu . '\\.test\\.(ts|js)$'",
"test": "c8 npm run unit && eslint ."
"test": "c8 npm run unit && eslint .",
"format": "prettier --write . --ignore-unknown"
},
"peerDependencies": {
"postcss": "^8.3.0"
Expand Down
19 changes: 17 additions & 2 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,22 @@ test("02 - two instances, different quote styles", async () => {
test("03 - only @import in one line", async () => {
await run(
`@nested-import './test/mocks/vendor.css';`,
`.vendor { background: silver; }.vendor-font { font-size: 14px; }`
`.vendor {
background: silver;
}.vendor-font {
font-size: 14px;
}`
);
});

test("04 - replaces @nested-import nested under :global", async () => {
await run(
`:global { @nested-import './test/mocks/vendor.css'; background: gold; }`,
`:global { .vendor { background: silver; } .vendor-font { font-size: 14px; } background: gold; }`
`:global { .vendor {
background: silver;
} .vendor-font {
font-size: 14px;
} background: gold; }`
);
});

Expand Down Expand Up @@ -189,4 +197,11 @@ test("09 - url() function with line breaks", async () => {
);
});

test("10 - package.json filter style, main & index", async () => {
await run(
`@nested-import './test/mocks/node_modules/style'; @nested-import './test/mocks/node_modules/main'; @nested-import './test/mocks/node_modules/index';`,
`.style {} .main {} .index {}`
);
});

test.run();
1 change: 1 addition & 0 deletions test/mocks/node_modules/index/index.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/mocks/node_modules/index/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/mocks/node_modules/main/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/mocks/node_modules/main/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/mocks/node_modules/style/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/mocks/node_modules/style/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions test/mocks/vendor.css
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
.vendor { background: silver; }
.vendor-font { font-size: 14px; }
.vendor {
background: silver;
}
.vendor-font {
font-size: 14px;
}

0 comments on commit 6afdfeb

Please sign in to comment.