-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathisHMRUpdate.test.js
More file actions
39 lines (34 loc) · 1000 Bytes
/
isHMRUpdate.test.js
File metadata and controls
39 lines (34 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* eslint-env mocha */
const chai = require('chai')
const expect = chai.expect
const isHMRUpdate = require('../lib/isHMRUpdate.js')
describe('isHMRUpdate', function () {
it('detects HMR updates', function () {
const config = {
output: {
hotUpdateChunkFilename: 'hmr-yo[id].[hash].js[query]'
}
}
const input = 'hmr-yo42.b4d455.js?f00b43'
const res = isHMRUpdate(config, input)
expect(res).to.eq(true)
})
it('detects HMR updates with tricky templates', function () {
const config = {
output: {
hotUpdateChunkFilename: '[id][hash][name]hmr.js[query]'
}
}
const input = '42940455foo-hmr.js?f00b43'
const res = isHMRUpdate(config, input)
expect(res).to.eq(true)
})
it('doesn\'t yield false positives', function () {
const config = {
output: {
hotUpdateChunkFilename: '[id][hash][name]hmr.js[query]'
}
}
expect(isHMRUpdate(config, '42940455foo-hmr?f00b43')).to.eq(false)
})
})