diff options
| author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-10-16 14:23:36 -0300 | 
|---|---|---|
| committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-10-16 14:23:36 -0300 | 
| commit | 388e75e4b0f602ac5dd70e1ceeb1d1a18a37c51e (patch) | |
| tree | 8ae4c703deff5a369cd35c7580351e320faa6d93 /test/functional/api/server_notifications_spec.lua | |
| parent | 0a2d9fa8c88b6e263b9baa9b639c23321272f9bf (diff) | |
| parent | 0c2ec77ae0c0bde70b168313f89fa3259682a056 (diff) | |
| download | rneovim-388e75e4b0f602ac5dd70e1ceeb1d1a18a37c51e.tar.gz rneovim-388e75e4b0f602ac5dd70e1ceeb1d1a18a37c51e.tar.bz2 rneovim-388e75e4b0f602ac5dd70e1ceeb1d1a18a37c51e.zip | |
Merge PR #1296 'Use the lua client to run functional tests'
Diffstat (limited to 'test/functional/api/server_notifications_spec.lua')
| -rw-r--r-- | test/functional/api/server_notifications_spec.lua | 40 | 
1 files changed, 40 insertions, 0 deletions
| diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua new file mode 100644 index 0000000000..6791fbb4ba --- /dev/null +++ b/test/functional/api/server_notifications_spec.lua @@ -0,0 +1,40 @@ +-- Tests for nvim notifications +local helpers = require('test.functional.helpers') +local eq, clear, eval, execute, nvim, next_message = +  helpers.eq, helpers.clear, helpers.eval, helpers.execute, helpers.nvim, +  helpers.next_message + +describe('notify', function() +  local channel + +  before_each(function() +    clear() +    channel = nvim('get_api_info')[1] +  end) + +  describe('passing a valid channel id', function() +    it('sends the notification/args to the corresponding channel', function() +      eval('rpcnotify('..channel..', "test-event", 1, 2, 3)') +      eq({'notification', 'test-event', {1, 2, 3}}, next_message()) +      execute('au FileType lua call rpcnotify('..channel..', "lua!")') +      execute('set filetype=lua') +      eq({'notification', 'lua!', {}}, next_message()) +    end) +  end) + +  describe('passing 0 as the channel id', function() +    it('sends the notification/args to all subscribed channels', function() +      nvim('subscribe', 'event2') +      eval('rpcnotify(0, "event1", 1, 2, 3)') +      eval('rpcnotify(0, "event2", 4, 5, 6)') +      eval('rpcnotify(0, "event2", 7, 8, 9)') +      eq({'notification', 'event2', {4, 5, 6}}, next_message()) +      eq({'notification', 'event2', {7, 8, 9}}, next_message()) +      nvim('unsubscribe', 'event2') +      nvim('subscribe', 'event1') +      eval('rpcnotify(0, "event2", 10, 11, 12)') +      eval('rpcnotify(0, "event1", 13, 14, 15)') +      eq({'notification', 'event1', {13, 14, 15}}, next_message()) +    end) +  end) +end) | 
