Skip to content

Commit 60e5a1a

Browse files
committed
adjust test to cover consistent hash generation
1 parent e5fea3a commit 60e5a1a

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

lib/gen-id.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ var hash = require('hash-sum')
55
var cache = Object.create(null)
66

77
module.exports = function genId (file, context) {
8-
context = context || process.cwd()
98
var contextPath = context.split(path.sep)
109
var rootId = contextPath[contextPath.length - 1]
1110
file = rootId + '/' + path.relative(context, file)

test/test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var jsdom = require('jsdom')
55
var webpack = require('webpack')
66
var MemoryFS = require('memory-fs')
77
var expect = require('chai').expect
8-
var genId = require('../lib/gen-id')
8+
var hash = require('hash-sum')
99
var SSR = require('vue-server-renderer')
1010
var compiler = require('../lib/template-compiler')
1111
var normalizeNewline = require('normalize-newline')
@@ -163,7 +163,7 @@ describe('vue-loader', function () {
163163
test({
164164
entry: './test/fixtures/scoped-css.vue'
165165
}, function (window, module) {
166-
var id = 'data-v-' + genId(require.resolve('./fixtures/scoped-css.vue'))
166+
var id = 'data-v-' + hash('vue-loader/test/fixtures/scoped-css.vue')
167167
expect(module._scopeId).to.equal(id)
168168

169169
var vnode = mockRender(module, {
@@ -198,7 +198,7 @@ describe('vue-loader', function () {
198198
var styles = window.document.querySelectorAll('style')
199199
expect(styles[0].textContent).to.contain('h1 { color: red;\n}')
200200
// import with scoped
201-
var id = 'data-v-' + genId(require.resolve('./fixtures/style-import.vue'))
201+
var id = 'data-v-' + hash('vue-loader/test/fixtures/style-import.vue')
202202
expect(styles[1].textContent).to.contain('h1[' + id + '] { color: green;\n}')
203203
done()
204204
})
@@ -258,7 +258,7 @@ describe('vue-loader', function () {
258258
}, function (window) {
259259
var style = window.document.querySelector('style').textContent
260260
style = normalizeNewline(style)
261-
var id = 'data-v-' + genId(require.resolve('./fixtures/media-query.vue'))
261+
var id = 'data-v-' + hash('vue-loader/test/fixtures/media-query.vue')
262262
expect(style).to.contain('@media print {\n.foo[' + id + '] {\n color: #000;\n}\n}')
263263
done()
264264
})
@@ -465,7 +465,7 @@ describe('vue-loader', function () {
465465
// default module + pre-processor + scoped
466466
var anotherClassName = module.computed.$style().red
467467
expect(anotherClassName).to.match(regexToMatch).and.not.equal(className)
468-
var id = 'data-v-' + genId(require.resolve('./fixtures/css-modules.vue'))
468+
var id = 'data-v-' + hash('vue-loader/test/fixtures/css-modules.vue')
469469
expect(style).to.contain('.' + anotherClassName + '[' + id + ']')
470470

471471
cb()

0 commit comments

Comments
 (0)