Skip to content

Commit 5ade923

Browse files
committed
Fix tests and lint warnings
1 parent eeb42cd commit 5ade923

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1095
-920
lines changed

__tests__/applyAtRule.test.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import postcss from 'postcss'
2-
import plugin from '../src/lib/substituteClassApplyAtRules'
3-
import generateUtilities from '../src/legacy/generateUtilities'
2+
import substituteClassApplyAtRules from '../src/lib/substituteClassApplyAtRules'
3+
import processPlugins from '../src/util/processPlugins'
4+
import defaultPlugins from '../src/defaultPlugins'
45
import defaultConfig from '../defaultConfig.stub.js'
56

6-
const defaultUtilities = generateUtilities(defaultConfig, [])
7+
const { utilities: defaultUtilities } = processPlugins(defaultPlugins(defaultConfig), defaultConfig)
78

89
function run(input, config = defaultConfig, utilities = defaultUtilities) {
9-
return postcss([plugin(config, utilities)]).process(input, { from: undefined })
10+
return postcss([substituteClassApplyAtRules(config, utilities)]).process(input, {
11+
from: undefined,
12+
})
1013
}
1114

1215
test("it copies a class's declarations into itself", () => {
@@ -206,10 +209,12 @@ test('you can apply utility classes without using the given prefix', () => {
206209
experiments: { shadowLookup: true },
207210
}
208211

209-
return run(input, config, generateUtilities(config, [])).then(result => {
210-
expect(result.css).toEqual(expected)
211-
expect(result.warnings().length).toBe(0)
212-
})
212+
return run(input, config, processPlugins(defaultPlugins(defaultConfig), config).utilities).then(
213+
result => {
214+
expect(result.css).toEqual(expected)
215+
expect(result.warnings().length).toBe(0)
216+
}
217+
)
213218
})
214219

215220
test('you can apply utility classes without using the given prefix when using a function for the prefix', () => {
@@ -232,8 +237,10 @@ test('you can apply utility classes without using the given prefix when using a
232237
experiments: { shadowLookup: true },
233238
}
234239

235-
return run(input, config, generateUtilities(config, [])).then(result => {
236-
expect(result.css).toEqual(expected)
237-
expect(result.warnings().length).toBe(0)
238-
})
240+
return run(input, config, processPlugins(defaultPlugins(defaultConfig), config).utilities).then(
241+
result => {
242+
expect(result.css).toEqual(expected)
243+
expect(result.warnings().length).toBe(0)
244+
}
245+
)
239246
})

__tests__/containerPlugin.test.js

Lines changed: 51 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,13 @@ function config(overrides) {
1616
xl: '1200px',
1717
},
1818
options: {
19-
prefix: "",
19+
prefix: '',
2020
important: false,
21-
separator: ":"
22-
}
21+
separator: ':',
22+
},
2323
})
2424
}
2525

26-
function processPluginsWithValidConfig(config) {
27-
return processPlugins(
28-
_.defaultsDeep(config, {
29-
screens: {
30-
sm: '576px',
31-
md: '768px',
32-
lg: '992px',
33-
xl: '1200px',
34-
},
35-
options: {
36-
prefix: '',
37-
important: false,
38-
separator: ':',
39-
},
40-
})
41-
)
42-
}
43-
4426
test.only('options are not required', () => {
4527
const { components } = processPlugins([container()], config())
4628

@@ -62,14 +44,17 @@ test.only('options are not required', () => {
6244
})
6345

6446
test.only('screens can be specified explicitly', () => {
65-
const { components } = processPlugins([
66-
container({
67-
screens: {
68-
sm: '400px',
69-
lg: '500px',
70-
},
71-
}),
72-
], config())
47+
const { components } = processPlugins(
48+
[
49+
container({
50+
screens: {
51+
sm: '400px',
52+
lg: '500px',
53+
},
54+
}),
55+
],
56+
config()
57+
)
7358

7459
expect(css(components)).toMatchCss(`
7560
.container { width: 100% }
@@ -83,11 +68,14 @@ test.only('screens can be specified explicitly', () => {
8368
})
8469

8570
test.only('screens can be an array', () => {
86-
const { components } = processPlugins([
87-
container({
88-
screens: ['400px', '500px'],
89-
}),
90-
], config())
71+
const { components } = processPlugins(
72+
[
73+
container({
74+
screens: ['400px', '500px'],
75+
}),
76+
],
77+
config()
78+
)
9179

9280
expect(css(components)).toMatchCss(`
9381
.container { width: 100% }
@@ -101,11 +89,14 @@ test.only('screens can be an array', () => {
10189
})
10290

10391
test.only('the container can be centered by default', () => {
104-
const { components } = processPlugins([
105-
container({
106-
center: true,
107-
}),
108-
], config())
92+
const { components } = processPlugins(
93+
[
94+
container({
95+
center: true,
96+
}),
97+
],
98+
config()
99+
)
109100

110101
expect(css(components)).toMatchCss(`
111102
.container {
@@ -129,11 +120,14 @@ test.only('the container can be centered by default', () => {
129120
})
130121

131122
test.only('horizontal padding can be included by default', () => {
132-
const { components } = processPlugins([
133-
container({
134-
padding: '2rem',
135-
}),
136-
], config())
123+
const { components } = processPlugins(
124+
[
125+
container({
126+
padding: '2rem',
127+
}),
128+
],
129+
config()
130+
)
137131

138132
expect(css(components)).toMatchCss(`
139133
.container {
@@ -157,16 +151,19 @@ test.only('horizontal padding can be included by default', () => {
157151
})
158152

159153
test.only('setting all options at once', () => {
160-
const { components } = processPlugins([
161-
container({
162-
screens: {
163-
sm: '400px',
164-
lg: '500px',
165-
},
166-
center: true,
167-
padding: '2rem',
168-
}),
169-
], config())
154+
const { components } = processPlugins(
155+
[
156+
container({
157+
screens: {
158+
sm: '400px',
159+
lg: '500px',
160+
},
161+
center: true,
162+
padding: '2rem',
163+
}),
164+
],
165+
config()
166+
)
170167

171168
expect(css(components)).toMatchCss(`
172169
.container {

0 commit comments

Comments
 (0)