Skip to content
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
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"extends": ["eslint-config-postcss", "prettier"],
"plugins": ["prettier"],
"rules": {
"no-unused-vars": [2, {"args": "all", "argsIgnorePattern": "^_"}],
"prettier/prettier": [
"error",
{
Expand Down
83 changes: 82 additions & 1 deletion __tests__/processPlugins.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test('plugins can create utilities with object syntax', () => {
object-fit: cover
}
}
`)
`)
})

test('plugins can create utilities with arrays of objects', () => {
Expand Down Expand Up @@ -1206,3 +1206,84 @@ test('prefix will prefix all classes in a selector', () => {
}
`)
})

test('plugins can be provided as an object with a handler function', () => {
const { components, utilities } = processPlugins(
[
{
handler({ addUtilities }) {
addUtilities({
'.object-fill': {
'object-fit': 'fill',
},
'.object-contain': {
'object-fit': 'contain',
},
'.object-cover': {
'object-fit': 'cover',
},
})
},
},
],
makeConfig()
)

expect(components.length).toBe(0)
expect(css(utilities)).toMatchCss(`
@variants {
.object-fill {
object-fit: fill
}
.object-contain {
object-fit: contain
}
.object-cover {
object-fit: cover
}
}
`)
})

test('plugins can provide a config but no handler', () => {
const { components, utilities } = processPlugins(
[
{
config: {
prefix: 'tw-',
},
},
{
handler({ addUtilities }) {
addUtilities({
'.object-fill': {
'object-fit': 'fill',
},
'.object-contain': {
'object-fit': 'contain',
},
'.object-cover': {
'object-fit': 'cover',
},
})
},
},
],
makeConfig()
)

expect(components.length).toBe(0)
expect(css(utilities)).toMatchCss(`
@variants {
.object-fill {
object-fit: fill
}
.object-contain {
object-fit: contain
}
.object-cover {
object-fit: cover
}
}
`)
})
Loading