UNPKG

wechaty-puppet-service

Version:
18 lines 1.08 kB
#!/usr/bin/env -S node --no-warnings --loader ts-node/esm "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tstest_1 = require("tstest"); const file_box_1 = require("file-box"); const wechaty_grpc_1 = require("wechaty-grpc"); const file_box_pb_js_1 = require("./file-box-pb.js"); (0, tstest_1.test)('packFileBoxToPb()', async (t) => { const FILE_BOX_DATA = 'test'; const FILE_BOX_NAME = 'test.dat'; const fileBox = file_box_1.FileBox.fromBuffer(Buffer.from(FILE_BOX_DATA), FILE_BOX_NAME); const pb = await (0, file_box_pb_js_1.packFileBoxToPb)(wechaty_grpc_1.puppet.MessageFileStreamResponse)(fileBox); const restoredFileBox = await (0, file_box_pb_js_1.unpackFileBoxFromPb)(pb); t.ok(restoredFileBox instanceof file_box_1.FileBox, 'should get an instance of FileBOX'); t.equal(restoredFileBox.name, fileBox.name, 'should get the right file box name'); t.equal(await restoredFileBox.toBase64(), await fileBox.toBase64(), 'should get the right file box content'); }); //# sourceMappingURL=file-box-pb.spec.js.map