Skip to content

Commit 7c37a71

Browse files
committed
test: duplicate css modules test
1 parent 230abd4 commit 7c37a71

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

Diff for: test/edgeCases.spec.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,18 @@ test('should not duplicate css modules value imports', done => {
113113
]
114114
}
115115
}
116-
}, ({ window, module, code }) => {
116+
}, ({ window, exports, code }) => {
117117
const localsRE = /exports.locals = {\s+"color": "red"\s+};/
118118
const matches = code.match(localsRE)
119119
expect(matches.length).toBe(1)
120120

121-
const styles = window.getComputedStyle(window.document.querySelector('h1'))
122-
console.log(styles)
121+
const styles = window.document.querySelectorAll('style')
122+
expect(styles.length).toBe(2) // one for values, one for the component
123+
const style = normalizeNewline(styles[1].textContent)
124+
// value should be injected
125+
expect(style).toMatch('color: red;')
126+
// exports is set as the locals imported from values.css
127+
expect(exports.color).toBe('red')
123128
done()
124129
})
125130
})

Diff for: test/fixtures/duplicate-cssm.css

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@value color: red;

Diff for: test/fixtures/duplicate-cssm.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import values from './duplicate-cssm.css'
2+
import Comp from './duplicate-cssm.vue'
3+
4+
export { values }
5+
export default Comp
6+
7+
window.exports = values

Diff for: test/fixtures/duplicate-cssm.vue

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<template>
2+
<h1 :class="$style.red">hi</h1>
3+
</template>
4+
5+
<style module>
6+
@value color from './duplicate-cssm.css';
7+
8+
.red {
9+
color: color;
10+
}
11+
</style>

0 commit comments

Comments
 (0)