UNPKG

@whisklabs/grpc

Version:

gRPC generator and http library for typescript

48 lines 1.57 kB
/** * @jest-environment jsdom */ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */ import { isNumber, isString } from '@whisklabs/typeguards'; import { send } from './devtool'; describe('gRPC devtools', function () { test('postMessage', function (cb) { // Circular structure var testA = {}; var testB = {}; testA.a = testB; testB.a = testA; window.addEventListener('message', function (event) { expect(event.data).toEqual({ method: 'set', methodType: 'unary', request: { prox: { a: 1, b: 5, c: 0, testA: testA, testB: testB, }, }, type: '__GRPCWEB_DEVTOOLS__', }); cb(); }, false); var prox = new Proxy({ a: 1, testA: testA, testB: testB }, { set: function (obj, el, val) { if (isString(el) && isNumber(val)) { obj[el] = val > 0 ? val : 0; return true; } else { return false; } }, }); prox.b = 5; prox.c = -5; send({ method: 'set', methodType: 'unary', request: { prox: prox } }); }); }); //# sourceMappingURL=devtool.spec.js.map