Skip to content

Commit 6afdfeb

Browse files
authored
Merge pull request #16 from 42tte/42tte/test-resolve-package-json-filter
42tte/test resolve package json filter
2 parents 5547806 + d04b493 commit 6afdfeb

File tree

11 files changed

+38
-7
lines changed

11 files changed

+38
-7
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
.DS_Store
88

99
# dependencies
10-
node_modules
10+
/node_modules/
1111
.npm
1212

1313
# logs

CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
1010
- enable import from `node_modules` - thanks [Kristoffer Nordström](https://github.com/42tte)
1111
- 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)
1212

13-
1413
For example:
1514

1615
```css

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"homepage": "https://github.com/eriklharper/postcss-nested-import",
1818
"scripts": {
1919
"unit": "uvu . '\\.test\\.(ts|js)$'",
20-
"test": "c8 npm run unit && eslint ."
20+
"test": "c8 npm run unit && eslint .",
21+
"format": "prettier --write . --ignore-unknown"
2122
},
2223
"peerDependencies": {
2324
"postcss": "^8.3.0"

test/index.test.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,22 @@ test("02 - two instances, different quote styles", async () => {
7272
test("03 - only @import in one line", async () => {
7373
await run(
7474
`@nested-import './test/mocks/vendor.css';`,
75-
`.vendor { background: silver; }.vendor-font { font-size: 14px; }`
75+
`.vendor {
76+
background: silver;
77+
}.vendor-font {
78+
font-size: 14px;
79+
}`
7680
);
7781
});
7882

7983
test("04 - replaces @nested-import nested under :global", async () => {
8084
await run(
8185
`:global { @nested-import './test/mocks/vendor.css'; background: gold; }`,
82-
`:global { .vendor { background: silver; } .vendor-font { font-size: 14px; } background: gold; }`
86+
`:global { .vendor {
87+
background: silver;
88+
} .vendor-font {
89+
font-size: 14px;
90+
} background: gold; }`
8391
);
8492
});
8593

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

200+
test("10 - package.json filter style, main & index", async () => {
201+
await run(
202+
`@nested-import './test/mocks/node_modules/style'; @nested-import './test/mocks/node_modules/main'; @nested-import './test/mocks/node_modules/index';`,
203+
`.style {} .main {} .index {}`
204+
);
205+
});
206+
192207
test.run();

test/mocks/node_modules/index/index.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/mocks/node_modules/index/package.json

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/mocks/node_modules/main/main.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/mocks/node_modules/main/package.json

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/mocks/node_modules/style/package.json

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/mocks/node_modules/style/style.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/mocks/vendor.css

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
.vendor { background: silver; }
2-
.vendor-font { font-size: 14px; }
1+
.vendor {
2+
background: silver;
3+
}
4+
.vendor-font {
5+
font-size: 14px;
6+
}

0 commit comments

Comments
 (0)