Files
ihaleist/tests/bid-print-window.test.mjs
T

20 lines
1013 B
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.
import {test} from 'node:test';
import assert from 'node:assert/strict';
import {belgeYazdir} from '../src/services/bidDocs.js';
test('validation window has no print action until replaced by the prepared document',()=>{
let html='',focused=0;
const popup={closed:false,document:{open(){html='';},write(value){html+=value;},close(){}},focus(){focused++;}};
assert.equal(belgeYazdir('Dosya kontrolü','<p role="status">Belgeler kontrol ediliyor…</p>',popup,{pending:true}),popup);
assert.match(html,/Belgeler kontrol ediliyor/);
assert.doesNotMatch(html,/<button|window\.print\(/);
assert.equal(belgeYazdir('Teklif <Cetveli>','<h1>Hazır cetvel</h1>',popup),popup);
assert.match(html,/<title>Teklif &lt;Cetveli&gt;<\/title>/);
assert.match(html,/Hazır cetvel/);
assert.match(html,/<button onclick="window\.print\(\)"/);
assert.doesNotMatch(html,/Belgeler kontrol ediliyor/);
assert.equal(focused,2);
popup.closed=true;
assert.throws(()=>belgeYazdir('Teklif','',popup),/penceresi kapatıldı/);
});