Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions packages/jats-xml/tests/baseprint.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { describe, expect, test } from 'vitest';
import fs from 'fs';
import { select } from 'unist-util-select';
import { toText } from 'myst-common';
import { Jats } from '../src';
import { Tags } from 'jats-tags';

describe('Baseprint JATS read', () => {

test('read minimal', async () => {
const file = 'tests/minimal_baseprint.xml';
const data = fs.readFileSync(file).toString();
const jats = new Jats(data);

expect(toText(jats.articleTitle)).toBe('Some title');
expect(toText(jats.abstract)).toBe('Some abstract.');
expect(toText(jats.body)).toBe('Some text.');
expect(jats.articleAuthors.length).toBe(1);
const author = jats.articleAuthors[0];
expect(toText(select(Tags.surname, author))).toBe('Wang');
});

});
22 changes: 22 additions & 0 deletions packages/jats-xml/tests/minimal_baseprint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<article>
<front>
<article-meta>
<title-group>
<article-title>Some title</article-title>
</title-group>
<contrib-group>
<contrib contrib-type="author">
<name>
<surname>Wang</surname>
</name>
</contrib>
</contrib-group>
<abstract>
<p>Some abstract.</p>
</abstract>
</article-meta>
</front>
<body>
<p>Some text.</p>
</body>
</article>