]> git.gir.st - VimFx.git/blob - extension/test/utils.coffee
Fix the `yy` command in Reader View
[VimFx.git] / extension / test / utils.coffee
1 ###
2 # Copyright Simon Lydell 2015, 2016.
3 #
4 # This file is part of VimFx.
5 #
6 # VimFx is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # VimFx is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with VimFx. If not, see <http://www.gnu.org/licenses/>.
18 ###
19
20 # This file provides some handy helpers for testing.
21
22 Vim = require('../lib/vim')
23
24 stub = (obj, method, fn) ->
25 originalFn = obj[method]
26 obj[method] = fn
27 return -> obj[method] = originalFn
28
29 class MockMessageManager
30 constructor: ->
31 @sendAsyncMessageCalls = 0
32 @addMessageListenerCalls = 0
33 @removeMessageListenerCalls = 0
34
35 sendAsyncMessage: -> @sendAsyncMessageCalls += 1
36 addMessageListener: -> @addMessageListenerCalls += 1
37 removeMessageListener: -> @removeMessageListenerCalls += 1
38
39 class MockVim extends Vim
40 constructor: (@_messageManager = null) ->
41
42 module.exports = {
43 stub
44 MockMessageManager
45 MockVim
46 }
Imprint / Impressum