Skip to content

Commit b50e001

Browse files
committed
Merge branch 'master' of github.com:surmon-china/vue-codemirror
2 parents d4cb2ff + d3b0d13 commit b50e001

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

package.json

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
"vue-template-compiler": "^2.5.2",
123123
"vue-template-es2015-compiler": "^1.6.0",
124124
"webpack": "^2.2.1",
125-
"webpack-bundle-analyzer": "^2.2.1",
125+
"webpack-bundle-analyzer": "^3.6.1",
126126
"webpack-dev-middleware": "^1.10.0",
127127
"webpack-hot-middleware": "^2.16.1",
128128
"webpack-merge": "^2.6.1"

test/unit/specs/VueCodemirror.spec.js

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import 'codemirror/mode/javascript/javascript.js'
2+
import 'codemirror/mode/xml/xml.js'
13

24
import Codemirror from 'codemirror'
5+
36
import Vue from 'vue/dist/vue.js'
4-
import VueCodemirror, { codemirror, install } from '../../../src/index.js'
57

6-
// language
7-
import 'codemirror/mode/javascript/javascript.js'
8-
import 'codemirror/mode/xml/xml.js'
8+
import VueCodemirror, { CodeMirror, codemirror, install } from '../../../src/index.js'
99

1010
window.Vue = Vue
1111

@@ -197,6 +197,45 @@ describe('vue-codemirror', () => {
197197
})
198198
})
199199

200+
describe('Emit custom event on codemirror object', () => {
201+
it(' - should capture custom event', done => {
202+
const eventLogs = []
203+
const vm = new Vue({
204+
template: `
205+
<div>
206+
<codemirror ref="cm"
207+
v-model="code"
208+
:events="events"
209+
@custom="onCustom">
210+
</codemirror>
211+
</div>
212+
`,
213+
data: {
214+
code: '<p>test content</p>',
215+
events: ['custom']
216+
},
217+
computed: {
218+
cm() {
219+
return this.$refs.cm
220+
},
221+
codemirror() {
222+
return this.cm.codemirror
223+
}
224+
},
225+
methods: {
226+
onCustom(codemirror) {
227+
eventLogs.push('onCustom')
228+
}
229+
}
230+
}).$mount()
231+
CodeMirror.signal(vm.codemirror, 'custom', vm.codemirror)
232+
vm.$nextTick(() => {
233+
expect(eventLogs[0]).to.deep.equal('onCustom')
234+
done()
235+
})
236+
})
237+
})
238+
200239
// 局部安装
201240
describe('Local install component', () => {
202241
it(' - should work', done => {

0 commit comments

Comments
 (0)