server.revoke.js
958 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
40
41
42
43
44
45
46
'use strict';
var test = require('tape');
var Server = require('../').Server;
test('Server.revoke', function (t) {
t.test('unregisters named JSON RPC methods', function (t) {
var server = new Server();
var called = {};
server.provide(function foo() { called.foo = true; });
server.provide(function fiz() { called.fiz = true; });
server.revoke('foo');
server.respond(JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'foo'
}));
t.equal(called.foo, void undefined);
t.equal(server.provides('foo'), false);
t.equal(server.provides('fiz'), true);
t.end();
});
t.test('ignores non-existent methods', function (t) {
var server = new Server();
t.doesNotThrow(function () {
server.revoke('foo');
});
server.provide(function fiz() { called.fiz = true; });
t.doesNotThrow(function () {
server.revoke('foo', 'foo');
});
t.end();
});
t.end();
});