app_auto_all/hongguo_auto/tests/drama-choice.test.js
2026-10-26 16:09:54 +08:00

7 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const test=require('node:test'),assert=require('node:assert/strict'),fs=require('node:fs'),vm=require('node:vm'),path=require('node:path');
const source=fs.readFileSync(path.join(__dirname,'../hongguo-daily.auto.js'),'utf8');
function setup(){const c=vm.createContext({});vm.runInContext(source.slice(0,source.lastIndexOf('\ntry {')),c);c.device={width:1080,height:2400};return {c,p:JSON.parse(fs.readFileSync(path.join(__dirname,'fixtures/oppo-drama-choice.json'),'utf8'))};}
test('OPPO上下排列追剧奖励选3220而非939,并触发通用处理',()=>{const {c,p}=setup();assert.equal(c.findCoinChoiceClaim(p).text,'看视频领3220金币');assert.equal(c.needsCommonHandling(p),true);});
test('缺少追剧弹窗标题或成对按钮不混入背景任务',()=>{const {c,p}=setup();for(const pattern of [/恭喜[获荻]得追剧奖励/,/^直接领取939金币$/,/^看视频领3220金币$/])assert.equal(c.findCoinChoiceClaim(p.filter(x=>!pattern.test(x.text))),null);});
test('保留500金币阈值规则,两选项都低于阈值选较小',()=>{const {c,p}=setup();p.forEach(x=>{x.text=x.text.replace('3220金币','320金币').replace('939金币','99金币');});assert.equal(c.findCoinChoiceClaim(p).text,'直接领取99金币');});