forked from substance/texture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbody.test.js
58 lines (53 loc) · 1.69 KB
/
body.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { module } from './test'
const test = module('jats/body')
// attributes should be preserved
var withAttributes =
'<body id="mybody" specific-use="test" xml:base="testbase">'+
'</body>';
test.attributesConversion(withAttributes, 'body');
var simple =
'<body>'+
'<p></p>'+
'</body>';
test.withFixture(simple, 'Im-/Exporting simple <body>', function(t) {
// import
var importer = t.fixture.createImporter('body');
var node = importer.convertElement(t.fixture.xmlElement);
t.equal(node.nodes.length, 1, 'node should have one content node after import');
// export
var exporter = t.fixture.createExporter();
var el = exporter.convertNode(node);
t.ok(el.is('body'), 'element should be a <body>');
t.ok(el.getChildAt(0).is('p'), '.. having one <p>');
t.end();
});
var sections =
'<body>'+
'<sec></sec>'+
'<sec></sec>'+
'<sec></sec>'+
'</body>';
test.withFixture(sections, 'Im-/Exporting <body> with sections', function(t) {
// import
var importer = t.fixture.createImporter('body');
var node = importer.convertElement(t.fixture.xmlElement);
t.equal(node.nodes.length, 3, 'node should have 3 content nodes after import');
// export
var exporter = t.fixture.createExporter();
var el = exporter.convertNode(node);
t.equal(el.findAll('sec').length, 3, 'there should be three sections after export');
t.end();
});
var paragraphAfterSection =
'<body>'+
'<sec></sec>'+
'<p></p>'+
'</body>';
test.withFixture(paragraphAfterSection, 'Invalid JATS: paragraphs are not allowed after a section', function(t) {
// import
var importer = t.fixture.createImporter('body');
t.throws(function() {
importer.convertElement(t.fixture.xmlElement);
});
t.end();
});