-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfirebug.spec.js
28 lines (23 loc) · 890 Bytes
/
firebug.spec.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
const expect = require('chai').expect;
const jsdom = require('jsdom');
const generators = require('../src/generators');
function newDocument() {
const options = {};
const doc = jsdom.jsdom(null, options);
doc.parent = doc.defaultView;
return doc;
}
describe('Original Firebug tests', () => {
it('should be able to generate an XPath for a simple DOM structure', () => {
const document = newDocument();
const div = document.createElement('div');
const parentDiv = document.createElement('div');
const childDiv1 = document.createElement('div');
const childDiv2 = document.createElement('div');
parentDiv.appendChild(childDiv1);
parentDiv.appendChild(childDiv2);
document.body.appendChild(parentDiv);
const xpath = generators.getElementTreeXPath(childDiv1);
expect(xpath).to.be.equal('/html/body/div/div[1]', 'Incorrect XPath');
});
});