|
| 1 | +import { assert } from '@std/assert' |
| 2 | +import { pathsToTree } from '../files/filetree.ts' |
| 3 | +import { BIDSFileDeno } from '../files/deno.ts' |
| 4 | +import { citationValidate } from './citation.ts' |
| 5 | +import { BIDSContextDataset } from '../schema/context.ts' |
| 6 | +import { GenericSchema } from '../types/schema.ts' |
| 7 | +import { loadSchema } from '../setup/loadSchema.ts' |
| 8 | + |
| 9 | +Deno.test('citation validation', async (t) => { |
| 10 | + const schema = await loadSchema() |
| 11 | + await t.step('no errors on the good citation.cff', async () => { |
| 12 | + const tree = pathsToTree(['CITATION.cff']) |
| 13 | + const dsContext = new BIDSContextDataset({ tree }) |
| 14 | + const file = new BIDSFileDeno('tests/data/citation', 'good.cff') |
| 15 | + tree.files[0].text = () => file.text() |
| 16 | + await citationValidate({} as GenericSchema, dsContext) |
| 17 | + assert(dsContext.issues.size === 0) |
| 18 | + }) |
| 19 | + await t.step('An error on the bad citation.cff', async () => { |
| 20 | + const tree = pathsToTree(['CITATION.cff']) |
| 21 | + const dsContext = new BIDSContextDataset({ tree }) |
| 22 | + const file = new BIDSFileDeno('tests/data/citation', 'bad.cff') |
| 23 | + tree.files[0].text = () => file.text() |
| 24 | + await citationValidate({} as GenericSchema, dsContext) |
| 25 | + assert(dsContext.issues.get({ code: 'CITATION_CFF_VALIDATION_ERROR' }).length === 1) |
| 26 | + }) |
| 27 | +}) |
0 commit comments