Skip to content

Commit 47f0b38

Browse files
committed
add test
Could help with #3360
1 parent 3fa7a22 commit 47f0b38

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

__tests__/applyAtRule.test.js

+83
Original file line numberDiff line numberDiff line change
@@ -1400,3 +1400,86 @@ test('lookup tree is correctly cached based on used tailwind atrules', async ()
14001400
.foo { margin-top: 1rem; }
14011401
`)
14021402
})
1403+
1404+
test('ensure @apply works with multiple definitions of the same class', async () => {
1405+
const input = `
1406+
.aspect-w-16 {
1407+
position: relative;
1408+
padding-bottom: calc(var(--tw-aspect-h) / var(--tw-aspect-w) * 100%);
1409+
}
1410+
1411+
.aspect-w-16 > * {
1412+
position: absolute;
1413+
height: 100%;
1414+
width: 100%;
1415+
top: 0;
1416+
right: 0;
1417+
bottom: 0;
1418+
left: 0;
1419+
}
1420+
1421+
.aspect-w-16 {
1422+
--tw-aspect-w: 16;
1423+
}
1424+
1425+
.aspect-h-9 {
1426+
--tw-aspect-h: 9;
1427+
}
1428+
1429+
.sixteen-by-nine {
1430+
@apply aspect-w-16 aspect-h-9;
1431+
}
1432+
`
1433+
1434+
const expected = `
1435+
.aspect-w-16 {
1436+
position: relative;
1437+
padding-bottom: calc(var(--tw-aspect-h) / var(--tw-aspect-w) * 100%);
1438+
}
1439+
1440+
.aspect-w-16 > * {
1441+
position: absolute;
1442+
height: 100%;
1443+
width: 100%;
1444+
top: 0;
1445+
right: 0;
1446+
bottom: 0;
1447+
left: 0;
1448+
}
1449+
1450+
.aspect-w-16 {
1451+
--tw-aspect-w: 16;
1452+
}
1453+
1454+
.aspect-h-9 {
1455+
--tw-aspect-h: 9;
1456+
}
1457+
1458+
.sixteen-by-nine {
1459+
position: relative;
1460+
padding-bottom: calc(var(--tw-aspect-h) / var(--tw-aspect-w) * 100%);
1461+
}
1462+
1463+
.sixteen-by-nine > * {
1464+
position: absolute;
1465+
height: 100%;
1466+
width: 100%;
1467+
top: 0;
1468+
right: 0;
1469+
bottom: 0;
1470+
left: 0;
1471+
}
1472+
1473+
.sixteen-by-nine {
1474+
--tw-aspect-w: 16;
1475+
--tw-aspect-h: 9;
1476+
}
1477+
`
1478+
1479+
expect.assertions(2)
1480+
1481+
return run(input).then((result) => {
1482+
expect(result.css).toMatchCss(expected)
1483+
expect(result.warnings().length).toBe(0)
1484+
})
1485+
})

0 commit comments

Comments
 (0)