31 lines
1.4 KiB
Python
31 lines
1.4 KiB
Python
from test_est_rea_parity import run
|
|
|
|
|
|
def test_quantity_apply_requires_one_detail_row_per_code():
|
|
result = run(
|
|
"math",
|
|
"""(()=>{
|
|
function apply(rows,items=[{Code:'r1',GN:7,TargetCode:'X'}]){
|
|
const handlers={};
|
|
globalThis.document={addEventListener:(name,fn)=>handlers[name]=fn};
|
|
const sheet={Code:'Q',rows:[],items,options:{}};
|
|
const state={quantitySheet:'Q',project:{quantitySheets:[sheet],tables:{EstMainDat:rows}}};
|
|
globalThis.EstApp={state,change:fn=>fn(),render:()=>{}};
|
|
EstQuantity.install();handlers.click({target:{closest:()=>true}});
|
|
return {rows,notice:state.notice||''};
|
|
}
|
|
return {duplicate:apply([{Code:'X',Level:0,GN:1},{Code:'X',Level:0,GN:2}]),
|
|
heading:apply([{Code:'X',Level:1,GN:1}]),
|
|
valid:apply([{Code:'X',Level:1,GN:1},{Code:'X',Level:0,GN:2}]),
|
|
partial:apply([{Code:'X',Level:0,GN:1}],[{Code:'r1',GN:7,TargetCode:'X'},{Code:'r2',GN:4,TargetCode:'missing'}])};
|
|
})()""",
|
|
)
|
|
assert [r["GN"] for r in result["duplicate"]["rows"]] == [1, 2]
|
|
assert result["duplicate"]["notice"]
|
|
assert result["heading"]["rows"][0]["GN"] == 1
|
|
assert result["heading"]["notice"]
|
|
assert [r["GN"] for r in result["valid"]["rows"]] == [1, 7]
|
|
assert result["valid"]["notice"] == ""
|
|
assert result["partial"]["rows"][0]["GN"] == 1
|
|
assert result["partial"]["notice"]
|