Skip to content

42tte/test resolve package json filter #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}