22 lines
1.8 KiB
JavaScript
22 lines
1.8 KiB
JavaScript
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const root = path.resolve(__dirname, '..');
|
|
const moduleSource = fs.readFileSync(path.join(root, 'prototype-src/modules/06-containers.html'), 'utf8');
|
|
const appSource = fs.readFileSync(path.join(root, 'prototype-src/app.js'), 'utf8');
|
|
|
|
assert.match(moduleSource, /<label>船名\(Vessel\)<\/label><input placeholder="船名"\/>/, '新增订舱页船名仍标记为必填');
|
|
assert.match(moduleSource, /<label>航次\(Voyage\)<\/label><input placeholder="航次"\/>/, '新增订舱页航次仍标记为必填');
|
|
assert.match(moduleSource, /id="release-vessel"/, '放舱弹框缺少船名字段');
|
|
assert.match(moduleSource, /id="release-vessel"[^>]*placeholder="请输入船名/, '放舱弹框船名缺少输入提示');
|
|
assert.match(appSource, /getElementById\('release-vessel'\)\.value='';/, '打开放舱弹框时未重置船名');
|
|
assert.match(appSource, /const vessel=document\.getElementById\('release-vessel'\)\.value\.trim\(\);/, '确认放舱时未读取船名');
|
|
assert.match(appSource, /if\(!vessel\|\|!v\|\|!bl\)\{showToast\('请填写船名、航次和提单号','error'\);return;\}/, '放舱必填校验未覆盖船名');
|
|
assert.match(appSource, /船名:'\+vessel\+'\\n航次:'\+v\+'\\n提单号:'\+bl/, '确认提示未展示船名');
|
|
assert.match(appSource, /船名:'\+vessel\+'<br>航次:'\+v\+'<br>提单号:'\+bl/, '放舱结果未展示船名');
|
|
assert.match(appSource, /td\.dataset\.vessel=vessel; td\.dataset\.v=v; td\.dataset\.bl=bl;/, '放舱结果未保存船名');
|
|
assert.match(appSource, /document\.getElementById\('release-vessel'\)\.value=td\.dataset\.vessel\|\|'';/, '编辑放舱信息时未回填船名');
|
|
|
|
console.log('订舱放舱船名字段验证通过。');
|