From f2f7b567a597d152504001c59f7ace1c8669ee36 Mon Sep 17 00:00:00 2001 From: James Yu Date: Sat, 23 Nov 2024 19:53:13 +0800 Subject: [PATCH] Add tests to `latex.extraExts` config item --- test/units/01_core_file.test.ts | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/test/units/01_core_file.test.ts b/test/units/01_core_file.test.ts index 95f9662dd..bb336ea5b 100644 --- a/test/units/01_core_file.test.ts +++ b/test/units/01_core_file.test.ts @@ -395,6 +395,28 @@ describe(path.basename(__filename).split('.')[0] + ':', () => { assert.ok(!lw.file.hasTeXExt('.sty')) assert.ok(!lw.file.hasTeXExt('.txt')) }) + + it('should return true for extensions defined in `latex.extraExts`', async () => { + await set.codeConfig('latex.extraExts', ['.txt']) + assert.ok(lw.file.hasTeXExt('.txt')) + }) + + it('should respond to changes to `latex.extraExts` on-the-fly', async () => { + assert.ok(!lw.file.hasTeXExt('.txt')) + assert.ok(!lw.file.hasTeXExt('.md')) + + await set.codeConfig('latex.extraExts', ['.txt']) + assert.ok(lw.file.hasTeXExt('.txt')) + assert.ok(!lw.file.hasTeXExt('.md')) + + await set.codeConfig('latex.extraExts', ['.txt', '.md']) + assert.ok(lw.file.hasTeXExt('.txt')) + assert.ok(lw.file.hasTeXExt('.md')) + + await set.codeConfig('latex.extraExts', []) + assert.ok(!lw.file.hasTeXExt('.txt')) + assert.ok(!lw.file.hasTeXExt('.md')) + }) }) describe('lw.file.hasBinaryExt', () => { @@ -411,6 +433,28 @@ describe(path.basename(__filename).split('.')[0] + ':', () => { assert.ok(!lw.file.hasBinaryExt('.jnw')) assert.ok(!lw.file.hasBinaryExt('.pnw')) }) + + it('should return false for extensions defined in `latex.extraExts`', async () => { + await set.codeConfig('latex.extraExts', ['.txt']) + assert.ok(!lw.file.hasBinaryExt('.txt')) + }) + + it('should respond to changes to `latex.extraExts` on-the-fly', async () => { + assert.ok(lw.file.hasBinaryExt('.txt')) + assert.ok(lw.file.hasBinaryExt('.md')) + + await set.codeConfig('latex.extraExts', ['.txt']) + assert.ok(!lw.file.hasBinaryExt('.txt')) + assert.ok(lw.file.hasBinaryExt('.md')) + + await set.codeConfig('latex.extraExts', ['.txt', '.md']) + assert.ok(!lw.file.hasBinaryExt('.txt')) + assert.ok(!lw.file.hasBinaryExt('.md')) + + await set.codeConfig('latex.extraExts', []) + assert.ok(lw.file.hasBinaryExt('.txt')) + assert.ok(lw.file.hasBinaryExt('.md')) + }) }) describe('lw.file.hasTeXLangId', () => {