summaryrefslogtreecommitdiff
path: root/test/html-paths.tests.js
blob: 8d75b7cf7b50245d634018c536dfc76a9ad87001 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var assert = require("assert");

var test = require("./test")(module);
var htmlPaths = require("../lib/html-paths");


test("element can match multiple tag names", function() {
    var pathPart = htmlPaths.element(["ul", "ol"]);
    assert.ok(pathPart.matchesElement({tagName: "ul"}));
    assert.ok(pathPart.matchesElement({tagName: "ol"}));
    assert.ok(!pathPart.matchesElement({tagName: "p"}));
});

test("element matches if attributes are the same", function() {
    var pathPart = htmlPaths.element(["p"], {"class": "tip"});
    assert.ok(!pathPart.matchesElement({tagName: "p"}));
    assert.ok(!pathPart.matchesElement({tagName: "p", attributes: {"class": "tip help"}}));
    assert.ok(pathPart.matchesElement({tagName: "p", attributes: {"class": "tip"}}));
});