UNPKG

@whisklabs/grpc

Version:

gRPC generator and http library for typescript

50 lines 1.7 kB
"use strict"; /** * @jest-environment jsdom */ Object.defineProperty(exports, "__esModule", { value: true }); /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */ var typeguards_1 = require("@whisklabs/typeguards"); var devtool_1 = require("./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 ((0, typeguards_1.isString)(el) && (0, typeguards_1.isNumber)(val)) { obj[el] = val > 0 ? val : 0; return true; } else { return false; } }, }); prox.b = 5; prox.c = -5; (0, devtool_1.send)({ method: 'set', methodType: 'unary', request: { prox: prox } }); }); }); //# sourceMappingURL=devtool.spec.js.map