UNPKG

wechaty-weixin-openai

Version:
36 lines 2.33 kB
#!/usr/bin/env ts-node "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const tstest_1 = __importDefault(require("tstest")); const index_1 = require("./index"); const sentiment_1 = require("./schema/sentiment"); const TEST_TOKEN = process.env.WECHATY_WEIXIN_OPENAI_TOKEN; const TEST_ENCODING_AES_KEY = process.env.WECHATY_WEIXIN_OPENAI_ENCODING_AES_KEY; tstest_1.default('It should call the endpoint and get the response correctly', (t) => __awaiter(void 0, void 0, void 0, function* () { index_1.WeixinOpenAI.init(TEST_TOKEN, TEST_ENCODING_AES_KEY); const result = yield index_1.WeixinOpenAI.Instance.aiBot('句子不动', 'test-user'); t.assert(result.msg.length > 0); })); tstest_1.default('It should call the sentiment api and get the response correctly', (t) => __awaiter(void 0, void 0, void 0, function* () { index_1.WeixinOpenAI.init(TEST_TOKEN, TEST_ENCODING_AES_KEY); const result = yield index_1.WeixinOpenAI.Instance.sentiment('你有病吧', 'test-user'); t.assert(Object.keys(result).length === 6); })); tstest_1.default('It should call the sentiment api with six class and get the right response', (t) => __awaiter(void 0, void 0, void 0, function* () { index_1.WeixinOpenAI.init(TEST_TOKEN, TEST_ENCODING_AES_KEY); const result = yield index_1.WeixinOpenAI.Instance.sentiment('你有病吧', 'test-user', sentiment_1.SENTIMENT_MODE.THREE_CLASS); t.assert(Object.keys(result).length === 3); })); //# sourceMappingURL=index.spec.js.map