UNPKG

@juzi/wechaty-puppet-whatsapp

Version:
86 lines 3.73 kB
"use strict"; /* eslint-disable sort-keys */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const tstest_1 = require("tstest"); const contact_raw_payload_parser_js_1 = require("./contact-raw-payload-parser.js"); const PUPPET = __importStar(require("@juzi/wechaty-puppet")); (0, tstest_1.test)('parse self contact info', async (t) => { const selfContactInfo = { id: { server: 'c.us', user: '8613812345678', _serialized: '8613812345678@c.us', }, number: '8613812345678', type: 'in', isMe: true, isUser: true, isGroup: false, isWAContact: true, isMyContact: false, isBlocked: false, avatar: 'https://pps.whatsapp.net/v/t61.24694-24/260815595_1420796841651457_5795692773524767952_n.jpg?ccb=11-4&oh=01_AVzaQSF48-MYxwWUL9qX9i4f1tBjIvIX1h5xnwS3THYPkA&oe=6222761E', }; const result = (0, contact_raw_payload_parser_js_1.parserContactRawPayload)(selfContactInfo, 'testUserName'); console.info(result); t.ok(result.name === 'testUserName', 'should get correct contact name'); t.ok(result.type === PUPPET.types.Contact.Individual, 'should get correct contact type'); t.ok(result.phone[0] === '8613812345678', 'should get correct phone number'); t.ok(result.id === '8613812345678@c.us', 'should get correct user id'); t.ok(result.friend, 'should get correct friendship status'); t.pass('parse self contact info pass'); }); (0, tstest_1.test)('parse individual contact info', async (t) => { const contactInfo = { id: { server: 'c.us', user: '918879481247', _serialized: '918879481247@c.us', }, number: '918879481247', isBusiness: false, isEnterprise: false, labels: [], pushname: 'Prince Arora', statusMute: false, type: 'in', isMe: false, isUser: true, isGroup: false, isWAContact: true, isMyContact: true, isBlocked: false, }; const result = (0, contact_raw_payload_parser_js_1.parserContactRawPayload)(contactInfo, 'testUserName'); console.info(result); t.ok(result.name === 'Prince Arora', 'should get correct contact name'); t.ok(result.type === PUPPET.types.Contact.Individual, 'should get correct contact type'); t.ok(result.phone[0] === '918879481247', 'should get correct phone number'); t.ok(result.id === '918879481247@c.us', 'should get correct user id'); t.ok(result.friend, 'should get correct friendship status'); t.pass('parse individual contact info pass'); }); //# sourceMappingURL=contact-raw-payload-parser.spec.js.map