Skip to content

Commit

Permalink
Add tests to latex.extraExts config item
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Nov 23, 2024
1 parent b06e909 commit f2f7b56
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/units/01_core_file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand Down

0 comments on commit f2f7b56

Please sign in to comment.