10000 fix tests · rspack-contrib/rspack-vue-loader@c37f374 · GitHub
[go: up one dir, main page]

Skip to content

Commit c37f374

Browse files
committed
fix tests
1 parent 0993d7c commit c37f374

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

lib/parser.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
var parse5 = require('parse5')
22
var parser = new parse5.Parser(null, { locationInfo: true })
33
var cache = require('lru-cache')(100)
4-
var SourceNode = require('source-map').SourceNode
54
var SourceMapGenerator = require('source-map').SourceMapGenerator
65
var splitRE = /\n\r|\n|\r/g
76
var hash = require('hash-sum')

lib/style-rewriter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module.exports = function (css, map) {
8080
postcss(plugins)
8181
.process(css, opts)
8282
.then(function (result) {
83-
var map = JSON.parse(result.map.toString())
83+
var map = result.map.toJSON()
8484
// ensure we give the style source a unique name
8585
// so that Webpack doesn't get confused
8686
map.sources[0] = query.file + '.style'

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
"mocha": "^2.2.5",
6868
"node-libs-browser": "^0.5.3",
6969
"rimraf": "^2.4.0",
70-
"source-map": "^0.5.1",
7170
"style-loader": "^0.13.0",
7271
"stylus-loader": "^1.4.0",
7372
"template-html-loader": "^0.0.3",

test/test.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,20 @@ describe('vue-loader', function () {
151151
var smc = new SourceMapConsumer(JSON.parse(map))
152152
getFile('test.build.js', function (code) {
153153
var line
154-
code.split('\n').some(function (l, i) {
154+
var col
155+
var lines = code.split('\n')
156+
lines.some( D5B0 function (l, i) {
155157
if (l.indexOf('Hello from Component A') > -1) {
156-
line = i + 1
158+
line = i
159+
col = lines[i - 1].length
157160
return true
158161
}
159162
})
160163
var pos = smc.originalPositionFor({
161164
line: line,
162-
column: 0
165+
column: col
163166
})
164-
expect(pos.source.indexOf('webpack:///test/fixtures/basic.vue') > -1)
167+
expect(pos.source.indexOf('basic.vue') > -1)
165168
expect(pos.line).to.equal(15)
166169
done()
167170
})
@@ -205,7 +208,7 @@ describe('vue-loader', function () {
205208
}), function (err) {
206209
expect(err).to.be.null
207210
getFile('test.output.css', function (data) {
208-
expect(data).to.contain('h1 {\n color: #f00;\n}\nh2 {\n color: green;\n}')
211+
expect(data).to.contain('h1 {\n color: #f00;\n}\n\nh2 {\n color: green;\n}')
209212
done()
210213
})
211214
})

0 commit comments

Comments
 (0)
0