@@ -1051,136 +1051,4 @@ describe('xpath', () => {
10511051 assert . strictEqual ( xpath . select1 ( 'local-name(/book/characters)' , doc ) , 'characters' ) ;
10521052 } ) ;
10531053 } ) ;
1054-
1055- describe ( 'Node type tests' , ( ) => {
1056- it ( 'should correctly identify a Node of type Element' , ( ) => {
1057- var doc = parseXml ( '<book />' ) ;
1058- var element = doc . createElement ( 'characters' ) ;
1059-
1060- assert . ok ( xpath . isNodeLike ( element ) ) ;
1061- assert . ok ( xpath . isElement ( element ) ) ;
1062- assert . ok ( ! xpath . isAttribute ( doc ) ) ;
1063- } ) ;
1064-
1065- it ( 'should correctly identify a Node of type Attribute' , ( ) => {
1066- var doc = parseXml ( '<book />' ) ;
1067- var attribute = doc . createAttribute ( 'name' ) ;
1068-
1069- assert . ok ( xpath . isNodeLike ( attribute ) ) ;
1070- assert . ok ( xpath . isAttribute ( attribute ) ) ;
1071- assert . ok ( ! xpath . isTextNode ( attribute ) ) ;
1072- } ) ;
1073-
1074- it ( 'should correctly identify a Node of type Text' , ( ) => {
1075- var doc = parseXml ( '<book />' ) ;
1076- var text = doc . createTextNode ( 'Harry Potter' ) ;
1077-
1078- assert . ok ( xpath . isNodeLike ( text ) ) ;
1079- assert . ok ( xpath . isTextNode ( text ) ) ;
1080- assert . ok ( ! xpath . isCDATASection ( text ) ) ;
1081- } ) ;
1082-
1083- it ( 'should correctly identify a Node of type CDATASection' , ( ) => {
1084- var doc = parseXml ( '<book />' ) ;
1085- var cdata = doc . createCDATASection ( 'Harry Potter' ) ;
1086-
1087- assert . ok ( xpath . isNodeLike ( cdata ) ) ;
1088- assert . ok ( xpath . isCDATASection ( cdata ) ) ;
1089- assert . ok ( ! xpath . isProcessingInstruction ( cdata ) ) ;
1090- } ) ;
1091-
1092- it ( 'should correctly identify a Node of type ProcessingInstruction' , ( ) => {
1093- var doc = parseXml ( '<book />' ) ;
1094- var pi = doc . createProcessingInstruction ( 'xml-stylesheet' , 'href="mycss.css" type="text/css"' ) ;
1095-
1096- // This test fails due to a bug in @xmldom /[email protected] 1097- // assert.ok(xpath.isNodeLike(pi));
1098- assert . ok ( xpath . isProcessingInstruction ( pi ) ) ;
1099- assert . ok ( ! xpath . isComment ( pi ) ) ;
1100- } ) ;
1101-
1102- it ( 'should correctly identify a Node of type Comment' , ( ) => {
1103- var doc = parseXml ( '<book />' ) ;
1104- var comment = doc . createComment ( 'Harry Potter' ) ;
1105-
1106- assert . ok ( xpath . isNodeLike ( comment ) ) ;
1107- assert . ok ( xpath . isComment ( comment ) ) ;
1108- assert . ok ( ! xpath . isDocumentNode ( comment ) ) ;
1109- } ) ;
1110-
1111- it ( 'should correctly identify a Node of type Document' , ( ) => {
1112- var doc = parseXml ( '<book />' ) ;
1113-
1114- assert . ok ( xpath . isNodeLike ( doc ) ) ;
1115- assert . ok ( xpath . isDocumentNode ( doc ) ) ;
1116- assert . ok ( ! xpath . isDocumentTypeNode ( doc ) ) ;
1117- } ) ;
1118-
1119- it ( 'should correctly identify a Node of type DocumentType' , ( ) => {
1120- var doc = parseXml ( '<book />' ) ;
1121- var doctype = doc . implementation . createDocumentType ( 'book' , null , null ) ;
1122-
1123- assert . ok ( xpath . isNodeLike ( doctype ) ) ;
1124- assert . ok ( xpath . isDocumentTypeNode ( doctype ) ) ;
1125- assert . ok ( ! xpath . isDocumentFragment ( doctype ) ) ;
1126- } ) ;
1127-
1128- it ( 'should correctly identify a Node of type DocumentFragment' , ( ) => {
1129- var doc = parseXml ( '<book />' ) ;
1130- var fragment = doc . createDocumentFragment ( ) ;
1131-
1132- assert . ok ( xpath . isNodeLike ( fragment ) ) ;
1133- assert . ok ( xpath . isDocumentFragment ( fragment ) ) ;
1134- assert . ok ( ! xpath . isElement ( fragment ) ) ;
1135- } ) ;
1136-
1137- it ( 'should not identify a string as a Node' , ( ) => {
1138- assert . ok ( ! xpath . isNodeLike ( 'Harry Potter' ) ) ;
1139- } ) ;
1140-
1141- it ( 'should not identify a number as a Node' , ( ) => {
1142- assert . ok ( ! xpath . isNodeLike ( 45 ) ) ;
1143- } ) ;
1144-
1145- it ( 'should not identify a boolean as a Node' , ( ) => {
1146- assert . ok ( ! xpath . isNodeLike ( true ) ) ;
1147- } ) ;
1148-
1149- it ( 'should not identify null as a Node' , ( ) => {
1150- assert . ok ( ! xpath . isNodeLike ( null ) ) ;
1151- } ) ;
1152-
1153- it ( 'should not identify undefined as a Node' , ( ) => {
1154- assert . ok ( ! xpath . isNodeLike ( undefined ) ) ;
1155- } ) ;
1156-
1157- it ( 'should not identify an array as a Node' , ( ) => {
1158- assert . ok ( ! xpath . isNodeLike ( [ ] ) ) ;
1159- } ) ;
1160-
1161- it ( 'should identify an array of Nodes as such' , ( ) => {
1162- var doc = parseXml ( '<book />' ) ;
1163- var fragment = doc . createDocumentFragment ( ) ;
1164- var nodes = [ doc , fragment ] ;
1165-
1166- assert . ok ( xpath . isArrayOfNodes ( nodes ) ) ;
1167- assert . ok ( ! xpath . isNodeLike ( nodes ) ) ;
1168- } ) ;
1169-
1170- it ( 'should not identify an array of non-Nodes as an array of Nodes' , ( ) => {
1171- var nodes = [ 'Harry Potter' , 45 ] ;
1172-
1173- assert . ok ( ! xpath . isArrayOfNodes ( nodes ) ) ;
1174- assert . ok ( ! xpath . isNodeLike ( nodes ) ) ;
1175- } ) ;
1176-
1177- it ( 'should not identify an array of mixed Nodes and non-Nodes as an array of Nodes' , ( ) => {
1178- var doc = parseXml ( '<book />' ) ;
1179- var fragment = doc . createDocumentFragment ( ) ;
1180- var nodes = [ doc , fragment , 'Harry Potter' ] ;
1181-
1182- assert . ok ( ! xpath . isArrayOfNodes ( nodes ) ) ;
1183- assert . ok ( ! xpath . isNodeLike ( nodes ) ) ;
1184- } ) ;
1185- } ) ;
11861054} ) ;
0 commit comments