forked from yaronn/xpath.js
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove all the code associated with type checking
- Loading branch information
Showing
3 changed files
with
0 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1337,136 +1337,4 @@ describe('xpath', () => { | |
}); | ||
}) | ||
}); | ||
|
||
describe('Node type tests', () => { | ||
it('should correctly identify a Node of type Element', () => { | ||
var doc = parseXml('<book />'); | ||
var element = doc.createElement('characters'); | ||
|
||
assert.ok(xpath.isNodeLike(element)); | ||
assert.ok(xpath.isElement(element)); | ||
assert.ok(!xpath.isAttribute(doc)); | ||
}); | ||
|
||
it('should correctly identify a Node of type Attribute', () => { | ||
var doc = parseXml('<book />'); | ||
var attribute = doc.createAttribute('name'); | ||
|
||
assert.ok(xpath.isNodeLike(attribute)); | ||
assert.ok(xpath.isAttribute(attribute)); | ||
assert.ok(!xpath.isTextNode(attribute)); | ||
}); | ||
|
||
it('should correctly identify a Node of type Text', () => { | ||
var doc = parseXml('<book />'); | ||
var text = doc.createTextNode('Harry Potter'); | ||
|
||
assert.ok(xpath.isNodeLike(text)); | ||
assert.ok(xpath.isTextNode(text)); | ||
assert.ok(!xpath.isCDATASection(text)); | ||
}); | ||
|
||
it('should correctly identify a Node of type CDATASection', () => { | ||
var doc = parseXml('<book />'); | ||
var cdata = doc.createCDATASection('Harry Potter'); | ||
|
||
assert.ok(xpath.isNodeLike(cdata)); | ||
assert.ok(xpath.isCDATASection(cdata)); | ||
assert.ok(!xpath.isProcessingInstruction(cdata)); | ||
}); | ||
|
||
it('should correctly identify a Node of type ProcessingInstruction', () => { | ||
var doc = parseXml('<book />'); | ||
var pi = doc.createProcessingInstruction('xml-stylesheet', 'href="mycss.css" type="text/css"'); | ||
|
||
// This test fails due to a bug in @xmldom/[email protected] | ||
// assert.ok(xpath.isNodeLike(pi)); | ||
assert.ok(xpath.isProcessingInstruction(pi)); | ||
assert.ok(!xpath.isComment(pi)); | ||
}); | ||
|
||
it('should correctly identify a Node of type Comment', () => { | ||
var doc = parseXml('<book />'); | ||
var comment = doc.createComment('Harry Potter'); | ||
|
||
assert.ok(xpath.isNodeLike(comment)); | ||
assert.ok(xpath.isComment(comment)); | ||
assert.ok(!xpath.isDocumentNode(comment)); | ||
}); | ||
|
||
it('should correctly identify a Node of type Document', () => { | ||
var doc = parseXml('<book />'); | ||
|
||
assert.ok(xpath.isNodeLike(doc)); | ||
assert.ok(xpath.isDocumentNode(doc)); | ||
assert.ok(!xpath.isDocumentTypeNode(doc)); | ||
}); | ||
|
||
it('should correctly identify a Node of type DocumentType', () => { | ||
var doc = parseXml('<book />'); | ||
var doctype = doc.implementation.createDocumentType('book', null, null); | ||
|
||
assert.ok(xpath.isNodeLike(doctype)); | ||
assert.ok(xpath.isDocumentTypeNode(doctype)); | ||
assert.ok(!xpath.isDocumentFragment(doctype)); | ||
}); | ||
|
||
it('should correctly identify a Node of type DocumentFragment', () => { | ||
var doc = parseXml('<book />'); | ||
var fragment = doc.createDocumentFragment(); | ||
|
||
assert.ok(xpath.isNodeLike(fragment)); | ||
assert.ok(xpath.isDocumentFragment(fragment)); | ||
assert.ok(!xpath.isElement(fragment)); | ||
}); | ||
|
||
it('should not identify a string as a Node', () => { | ||
assert.ok(!xpath.isNodeLike('Harry Potter')); | ||
}); | ||
|
||
it('should not identify a number as a Node', () => { | ||
assert.ok(!xpath.isNodeLike(45)); | ||
}); | ||
|
||
it('should not identify a boolean as a Node', () => { | ||
assert.ok(!xpath.isNodeLike(true)); | ||
}); | ||
|
||
it('should not identify null as a Node', () => { | ||
assert.ok(!xpath.isNodeLike(null)); | ||
}); | ||
|
||
it('should not identify undefined as a Node', () => { | ||
assert.ok(!xpath.isNodeLike(undefined)); | ||
}); | ||
|
||
it('should not identify an array as a Node', () => { | ||
assert.ok(!xpath.isNodeLike([])); | ||
}); | ||
|
||
it('should identify an array of Nodes as such', () => { | ||
var doc = parseXml('<book />'); | ||
var fragment = doc.createDocumentFragment(); | ||
var nodes = [doc, fragment]; | ||
|
||
assert.ok(xpath.isArrayOfNodes(nodes)); | ||
assert.ok(!xpath.isNodeLike(nodes)); | ||
}); | ||
|
||
it('should not identify an array of non-Nodes as an array of Nodes', () => { | ||
var nodes = ['Harry Potter', 45]; | ||
|
||
assert.ok(!xpath.isArrayOfNodes(nodes)); | ||
assert.ok(!xpath.isNodeLike(nodes)); | ||
}); | ||
|
||
it('should not identify an array of mixed Nodes and non-Nodes as an array of Nodes', () => { | ||
var doc = parseXml('<book />'); | ||
var fragment = doc.createDocumentFragment(); | ||
var nodes = [doc, fragment, 'Harry Potter']; | ||
|
||
assert.ok(!xpath.isArrayOfNodes(nodes)); | ||
assert.ok(!xpath.isNodeLike(nodes)); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters