830f8a4011
Memind CI / Test, build, and release guards (push) Successful in 5m36s
Ship the 10-item numeric subscription loop on WeChat MP, wire schedule delivery for news/weather/quote/health/finance/tech/knowledge/night/surprise pushes, and extend news morning draft cover generation plus a one-shot draft push script. Co-authored-by: Cursor <cursoragent@cursor.com>
61 lines
2.4 KiB
JavaScript
61 lines
2.4 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import {
|
|
parsePushSubscriptionCancelRequest,
|
|
parsePushSubscriptionCityUpdate,
|
|
parsePushSubscriptionConfirmReply,
|
|
parsePushSubscriptionHelpRequest,
|
|
parsePushSubscriptionListRequest,
|
|
parsePushSubscriptionModifyRequest,
|
|
} from './push-subscription-parser.mjs';
|
|
|
|
test('parsePushSubscriptionConfirmReply accepts numeric ids and custom times', () => {
|
|
assert.equal(parsePushSubscriptionConfirmReply('11'), null);
|
|
const one = parsePushSubscriptionConfirmReply('1');
|
|
assert.equal(one.item.key, 'morning');
|
|
assert.equal(one.hour, null);
|
|
const news = parsePushSubscriptionConfirmReply('2 7点');
|
|
assert.equal(news.item.key, 'news');
|
|
assert.equal(news.hour, 7);
|
|
assert.equal(news.minute, 0);
|
|
assert.equal(parsePushSubscriptionConfirmReply('10').item.key, 'surprise');
|
|
assert.equal(parsePushSubscriptionConfirmReply('你好'), null);
|
|
});
|
|
|
|
test('parsePushSubscriptionCancelRequest detects id and alias cancel', () => {
|
|
assert.equal(parsePushSubscriptionCancelRequest('取消2').item.key, 'news');
|
|
assert.equal(parsePushSubscriptionCancelRequest('取消早安').item.key, 'morning');
|
|
assert.deepEqual(parsePushSubscriptionCancelRequest('全部取消'), { all: true });
|
|
});
|
|
|
|
test('parsePushSubscriptionModifyRequest parses id and alias modify', () => {
|
|
const news = parsePushSubscriptionModifyRequest('2改到7点');
|
|
assert.equal(news.item.key, 'news');
|
|
assert.equal(news.hour, 7);
|
|
const morning = parsePushSubscriptionModifyRequest('早安改到7点半');
|
|
assert.equal(morning.item.key, 'morning');
|
|
assert.equal(morning.minute, 30);
|
|
});
|
|
|
|
test('parsePushSubscriptionListRequest and help request', () => {
|
|
assert.equal(parsePushSubscriptionListRequest('我的订阅'), true);
|
|
assert.equal(parsePushSubscriptionHelpRequest('订阅帮助'), true);
|
|
});
|
|
|
|
test('parsePushSubscriptionConfirmReply parses weather city and time', () => {
|
|
const shanghai = parsePushSubscriptionConfirmReply('3 上海');
|
|
assert.equal(shanghai.item.key, 'weather');
|
|
assert.equal(shanghai.options.city, '上海');
|
|
|
|
const timed = parsePushSubscriptionConfirmReply('3 7点 北京');
|
|
assert.equal(timed.hour, 7);
|
|
assert.equal(timed.options.city, '北京');
|
|
});
|
|
|
|
test('parsePushSubscriptionCityUpdate parses weather city change', () => {
|
|
const updated = parsePushSubscriptionCityUpdate('3改城市杭州');
|
|
assert.equal(updated.item.key, 'weather');
|
|
assert.equal(updated.options.city, '杭州');
|
|
});
|