Files
order-notification-automation/tests/app/restored-output.test.cjs
T

6 lines
993 B
JavaScript

'use strict';
const test=require('node:test'),assert=require('node:assert/strict'),fs=require('node:fs/promises'),os=require('node:os'),path=require('node:path');const {resolveOutputDir}=require('../../src/app/application.cjs');
test('restored state selects its own output without overwriting an explicit deployment choice',async t=>{
const dir=await fs.mkdtemp(path.join(os.tmpdir(),'restored-output-'));t.after(()=>fs.rm(dir,{recursive:true,force:true}));await fs.mkdir(path.join(dir,'restored-pdf'));await fs.writeFile(path.join(dir,'restore-config.json'),JSON.stringify({outputDir:'restored-pdf'}));assert.equal(await resolveOutputDir('C:/example',dir,{}),path.join(dir,'restored-pdf'));assert.equal(await resolveOutputDir('C:/example',dir,{outputDir:'explicit'}),path.resolve('C:/example','explicit'));await fs.writeFile(path.join(dir,'restore-config.json'),JSON.stringify({outputDir:'../original'}));await assert.rejects(resolveOutputDir('C:/example',dir,{}),/恢复输出目录/);
});