mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Merge pull request #24468 from overleaf/mj-client-side-references
[web] Perform ARS on client-side GitOrigin-RevId: 19703c82758cae450fe52463ad9612d3a2383ba0
This commit is contained in:
committed by
Copybot
parent
f6820ed794
commit
ed0c4c447e
@@ -0,0 +1,83 @@
|
||||
import { expect } from 'chai'
|
||||
import { ReferenceIndex } from '@/features/ide-react/references/reference-index'
|
||||
|
||||
class TestedReferenceIndex extends ReferenceIndex {
|
||||
updateIndex(): void {
|
||||
throw new Error('This is a test implementation')
|
||||
}
|
||||
}
|
||||
describe('ReferenceIndex', function () {
|
||||
beforeEach(function () {
|
||||
this.index = new TestedReferenceIndex()
|
||||
})
|
||||
|
||||
describe('parseEntries', function () {
|
||||
it('should parse bib entry', function () {
|
||||
const content = `
|
||||
@article{sample2023,
|
||||
author = {John Doe},
|
||||
title = {Sample Title},
|
||||
journal = {Sample Journal},
|
||||
year = {2023},
|
||||
date = {2023-01-01}
|
||||
}
|
||||
`
|
||||
const entries = this.index.parseEntries(content)
|
||||
expect(entries).to.have.lengthOf(1)
|
||||
expect(entries[0]).to.deep.equal({
|
||||
EntryKey: 'sample2023',
|
||||
EntryType: 'article',
|
||||
Fields: {
|
||||
author: 'John Doe',
|
||||
title: 'Sample Title',
|
||||
journal: 'Sample Journal',
|
||||
year: '2023',
|
||||
date: '2023-01-01',
|
||||
},
|
||||
ObjectType: 'entry',
|
||||
})
|
||||
})
|
||||
|
||||
it('should default missing fields to empty strings', function () {
|
||||
const content = `@article{sample2023,
|
||||
author = {John Doe},
|
||||
title = {Sample Title}
|
||||
}`
|
||||
const entries = this.index.parseEntries(content)
|
||||
expect(entries).to.have.lengthOf(1)
|
||||
expect(entries[0]).to.deep.equal({
|
||||
EntryKey: 'sample2023',
|
||||
EntryType: 'article',
|
||||
Fields: {
|
||||
author: 'John Doe',
|
||||
title: 'Sample Title',
|
||||
journal: '',
|
||||
year: '',
|
||||
date: '',
|
||||
},
|
||||
ObjectType: 'entry',
|
||||
})
|
||||
})
|
||||
|
||||
it('should handle multiple entries', function () {
|
||||
const content = `@article{sample2023,
|
||||
author = {John Doe},
|
||||
title = {Sample Title},
|
||||
journal = {Sample Journal},
|
||||
year = {2023},
|
||||
date = {2023-01-01}
|
||||
}
|
||||
@book{example2022,
|
||||
author = {Jane Smith},
|
||||
title = {Example Book},
|
||||
journal = {Example Journal},
|
||||
year = {2022},
|
||||
date = {2022-05-15}
|
||||
}`
|
||||
const entries = this.index.parseEntries(content)
|
||||
expect(entries).to.have.lengthOf(2)
|
||||
expect(entries[0].EntryKey).to.equal('sample2023')
|
||||
expect(entries[1].EntryKey).to.equal('example2022')
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user