Prototyped unit test for rpc

This commit is contained in:
Chris Troutner
2021-03-30 20:13:28 -07:00
parent 8fb9dc62df
commit bf99825812
3 changed files with 63 additions and 1 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ class JSONRPC {
console.log('router str: ', str)
const parsedData = _this.jsonrpc.parse(str)
// console.log('parsedData: ', parsedData)
console.log('parsedData: ', parsedData)
// console.log('parsedData.type: ', parsedData.type)
// Exit quietly if the incoming string is invalid
+31
View File
@@ -0,0 +1,31 @@
/*
Unit tests for the rpc/index.js library.
*/
// Public npm libraries
const jsonrpc = require('jsonrpc-lite')
const JSONRPC = require('../../../src/rpc')
describe('#JSON RPC', () => {
let uut
beforeEach(() => {
uut = new JSONRPC()
})
describe('#router', () => {
it('should do something', async () => {
// const request = {
// 'users', // id
// 'getAll', // method
// {}
// }
const json = jsonrpc.request('users', 'getAll', {})
const str = JSON.stringify(json)
await uut.router(str)
})
})
})
+31
View File
@@ -0,0 +1,31 @@
/*
Unit tests for the rpc/index.js library.
*/
// Public npm libraries
const jsonrpc = require('jsonrpc-lite')
const JSONRPC = require('../../../src/rpc')
describe('#JSON RPC', () => {
let uut
beforeEach(() => {
uut = new JSONRPC()
})
describe('#router', () => {
it('should do something', async () => {
// const request = {
// 'users', // id
// 'getAll', // method
// {}
// }
const json = jsonrpc.request('users', 'getAll', {})
const str = JSON.stringify(json)
await uut.router(str)
})
})
})