From 19aa34ae0da7d6927085f80765997d823f0c7891 Mon Sep 17 00:00:00 2001 From: James Yu Date: Tue, 24 Sep 2024 16:31:13 +0800 Subject: [PATCH] Add auto-build onFileChange unit tests --- test/units/08_compile_build.test.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/units/08_compile_build.test.ts b/test/units/08_compile_build.test.ts index adf1e2e58..7e5c63c9b 100644 --- a/test/units/08_compile_build.test.ts +++ b/test/units/08_compile_build.test.ts @@ -512,5 +512,33 @@ describe(path.basename(__filename).split('.')[0] + ':', () => { assert.hasLog(`Building root file: ${get.path('main.tex')}`) assert.notHasLog(`Building root file: ${get.path('subfile.tex')}`) }) + + it.only('should auto-build when watched source is changed', () => { + set.config('latex.autoBuild.run', 'onFileChange') + + log.start() + for (const handler of lw.watcher.src['onChangeHandlers']) { + try { + handler(vscode.Uri.file(get.path('main.tex'))) + } catch (_) { } + } + log.stop() + + assert.hasLog(`Auto build started detecting the change of a file: ${get.path('main.tex')}`) + }) + + it.only('should auto-build when watched bib file is changed', () => { + set.config('latex.autoBuild.run', 'onFileChange') + + log.start() + for (const handler of lw.watcher.bib['onChangeHandlers']) { + try { + handler(vscode.Uri.file(get.path('main.bib'))) + } catch (_) { } + } + log.stop() + + assert.hasLog(`Auto build started detecting the change of a file: ${get.path('main.bib')}`) + }) }) })