diff options
Diffstat (limited to 'addons/web/static/test/core/rpc_tests.js')
| -rw-r--r-- | addons/web/static/test/core/rpc_tests.js | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/addons/web/static/test/core/rpc_tests.js b/addons/web/static/test/core/rpc_tests.js index beec3fce831..7c196a1155d 100644 --- a/addons/web/static/test/core/rpc_tests.js +++ b/addons/web/static/test/core/rpc_tests.js @@ -30,33 +30,51 @@ QUnit.module('core', {}, function () { QUnit.module('RPC Builder'); QUnit.test('basic rpc (route)', function (assert) { - assert.expect(1); + assert.expect(3); var query = createQuery({ route: '/my/route', - mockRPC: function (route) { + mockRPC: function (route, params) { assert.strictEqual(route, '/my/route', "should call the proper route"); - } + assert.notOk('args' in params, + "rpc on routes should not have any args by default"); + assert.notOk('kwargs' in params, + "rpc on routes should not have any kwargs by default"); + }, }); query.exec(); }); - QUnit.test('basic rpc, with no context', function (assert) { + QUnit.test('rpc on route with parameters', function (assert) { assert.expect(1); var query = createQuery({ route: '/my/route', - mockRPC: function (route, args) { - assert.notOk('context' in args.kwargs, + mockRPC: function (route, params) { + assert.deepEqual(params, {hey: 'there'}, + "should transfer the proper parameters"); + }, + }); + query.params({hey: 'there'}).exec(); + }); + + QUnit.test('basic rpc, with no context', function (assert) { + assert.expect(1); + var query = createQuery({ + model: 'partner', + method: 'test', + mockRPC: function (route, params) { + assert.notOk('context' in params.kwargs, "does not automatically add a context"); } }); - query.exec(); + query.kwargs({}).exec(); }); QUnit.test('basic rpc, with context', function (assert) { assert.expect(1); var query = createQuery({ - route: '/my/route', + model: 'partner', + method: 'test', mockRPC: function (route, args) { assert.deepEqual(args.kwargs.context, {a: 1}, "properly transfer the context"); @@ -68,7 +86,8 @@ QUnit.module('core', {}, function () { QUnit.test('basic rpc, with context, part 2', function (assert) { assert.expect(1); var query = createQuery({ - route: '/my/route', + model: 'partner', + method: 'test', mockRPC: function (route, args) { assert.deepEqual(args.kwargs.context, {a: 1}, "properly transfer the context"); |
