mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Merge pull request #30232 from overleaf/ar/convert-clsi-to-es-modules
[clsi] convert to ES modules GitOrigin-RevId: fb7fa52cc8f678ee31be352e62a5dff95e88008b
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
import sinon from 'sinon'
|
||||
import { expect, describe, beforeEach, afterEach, it } from 'vitest'
|
||||
import mockFs from 'mock-fs'
|
||||
import path from 'node:path'
|
||||
|
||||
const modulePath = path.join(
|
||||
import.meta.dirname,
|
||||
'../../../app/js/OutputFileFinder'
|
||||
)
|
||||
|
||||
describe('OutputFileFinder', function () {
|
||||
beforeEach(async function (ctx) {
|
||||
ctx.OutputFileFinder = (await import(modulePath)).default
|
||||
ctx.directory = '/test/dir'
|
||||
ctx.callback = sinon.stub()
|
||||
|
||||
mockFs({
|
||||
[ctx.directory]: {
|
||||
resource: {
|
||||
'path.tex': 'a source file',
|
||||
},
|
||||
'output.pdf': 'a generated pdf file',
|
||||
extra: {
|
||||
'file.tex': 'a generated tex file',
|
||||
},
|
||||
'sneaky-file': mockFs.symlink({
|
||||
path: '../foo',
|
||||
}),
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
mockFs.restore()
|
||||
})
|
||||
|
||||
describe('findOutputFiles', function () {
|
||||
beforeEach(async function (ctx) {
|
||||
ctx.resource_path = 'resource/path.tex'
|
||||
ctx.output_paths = ['output.pdf', 'extra/file.tex']
|
||||
ctx.all_paths = ctx.output_paths.concat([ctx.resource_path])
|
||||
ctx.resources = [{ path: (ctx.resource_path = 'resource/path.tex') }]
|
||||
const { outputFiles, allEntries } =
|
||||
await ctx.OutputFileFinder.promises.findOutputFiles(
|
||||
ctx.resources,
|
||||
ctx.directory
|
||||
)
|
||||
ctx.outputFiles = outputFiles
|
||||
ctx.allEntries = allEntries
|
||||
})
|
||||
|
||||
it('should only return the output files, not directories or resource paths', function (ctx) {
|
||||
expect(ctx.outputFiles).to.have.deep.members([
|
||||
{
|
||||
path: 'output.pdf',
|
||||
type: 'pdf',
|
||||
},
|
||||
{
|
||||
path: 'extra/file.tex',
|
||||
type: 'tex',
|
||||
},
|
||||
])
|
||||
expect(ctx.allEntries).to.deep.equal([
|
||||
'extra/file.tex',
|
||||
'extra/',
|
||||
'output.pdf',
|
||||
'resource/path.tex',
|
||||
'resource/',
|
||||
'sneaky-file',
|
||||
])
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user