Skip to content

Commit cccfda9

Browse files
committed
test for config.optionMergeStrategies
1 parent 34bcc02 commit cccfda9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/unit/features/global-api/config.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,26 @@ describe('Global config', () => {
2727
Vue.config.errorHandler = null
2828
})
2929
})
30+
31+
describe('optionMergeStrategies', () => {
32+
it('should allow defining custom option merging strategies', () => {
33+
const spy = jasmine.createSpy('option merging')
34+
Vue.config.optionMergeStrategies.__test__ = (parent, child, vm) => {
35+
spy(parent, child, vm)
36+
return child + 1
37+
}
38+
const Test = Vue.extend({
39+
__test__: 1
40+
})
41+
expect(spy.calls.count()).toBe(1)
42+
expect(spy).toHaveBeenCalledWith(undefined, 1, undefined)
43+
expect(Test.options.__test__).toBe(2)
44+
const test = new Test({
45+
__test__: 2
46+
})
47+
expect(spy.calls.count()).toBe(2)
48+
expect(spy).toHaveBeenCalledWith(2, 2, test)
49+
expect(test.$options.__test__).toBe(3)
50+
})
51+
})
3052
})

0 commit comments

Comments
 (0)