1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-03 14:59:18 +02:00

Allow location to use XMLDom, add locations tests

This commit is contained in:
Fred Chasen 2016-11-21 14:36:17 +01:00
parent 662a3e1079
commit db798e7934
9 changed files with 254 additions and 100 deletions

35
test/locations.js Normal file
View file

@ -0,0 +1,35 @@
var assert = require('assert');
describe('Locations', function() {
var Locations = require('../src/locations');
var core = require('../src/core');
var chapter = require('raw-loader!./fixtures/locations.xhtml');
describe('#parse', function() {
var Locations = require('../src/locations');
var core = require('../src/core');
var chapter = require('raw-loader!./fixtures/locations.xhtml');
it('parse locations from a document', function() {
var doc = core.parse(chapter, "application/xhtml+xml");
var contents = doc.documentElement;
var locations = new Locations();
var result = locations.parse(contents, "/6/4[chap01ref]", 100);
assert.equal(result.length, 15);
});
it('parse locations from xmldom', function() {
var doc = core.parse(chapter, "application/xhtml+xml", true);
var contents = doc.documentElement;
var locations = new Locations();
var result = locations.parse(contents, "/6/4[chap01ref]", 100);
console.log(result);
assert.equal(result.length, 15);
});
});
});