Skip to content

Commit 66ec10e

Browse files
committed
Add test to document plugin extend behavior
1 parent 94a1d30 commit 66ec10e

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

__tests__/resolveConfig.test.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,3 +1569,79 @@ test('plugin configs take precedence over plugin configs registered by that plug
15691569
plugins: userConfig.plugins,
15701570
})
15711571
})
1572+
1573+
test('plugin theme extensions are added even if user overrides top-level theme config', () => {
1574+
const userConfig = {
1575+
plugins: [
1576+
{
1577+
config: {
1578+
theme: {
1579+
width: {
1580+
'1px': '1px'
1581+
}
1582+
},
1583+
plugins: [
1584+
{
1585+
config: {
1586+
theme: {
1587+
extend: {
1588+
width: {
1589+
'2px': '2px',
1590+
'3px': '3px',
1591+
}
1592+
}
1593+
},
1594+
},
1595+
},
1596+
],
1597+
},
1598+
handler() {},
1599+
},
1600+
],
1601+
}
1602+
1603+
const defaultConfig = {
1604+
prefix: '',
1605+
important: false,
1606+
separator: ':',
1607+
theme: {
1608+
width: {
1609+
sm: '1rem',
1610+
md: '2rem',
1611+
lg: '3rem',
1612+
},
1613+
screens: {
1614+
mobile: '400px',
1615+
},
1616+
},
1617+
variants: {
1618+
appearance: ['responsive'],
1619+
borderCollapse: [],
1620+
borderColors: ['responsive', 'hover', 'focus'],
1621+
},
1622+
}
1623+
1624+
const result = resolveConfig([userConfig, defaultConfig])
1625+
1626+
expect(result).toEqual({
1627+
prefix: '',
1628+
important: false,
1629+
separator: ':',
1630+
theme: {
1631+
width: {
1632+
'1px': '1px',
1633+
'2px': '2px',
1634+
'3px': '3px',
1635+
},
1636+
screens: {
1637+
mobile: '400px',
1638+
},
1639+
},
1640+
variants: {
1641+
appearance: ['responsive'],
1642+
borderCollapse: [],
1643+
borderColors: ['responsive', 'hover', 'focus'],
1644+
},
1645+
plugins: userConfig.plugins,
1646+
})
1647+
})

0 commit comments

Comments
 (0)