File: nodetype.coffee

package info (click to toggle)
node-xml2js 0.4.23%2B~cs15.4.0%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,380 kB
  • sloc: xml: 117; javascript: 7; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 1,431 bytes parent folder | download | duplicates (2)
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
29
30
31
32
33
34
35
36
37
38
suite 'Check node type:', ->
  test 'Document node types', ->
    obj =
        root:
            '@age': 35
            '#raw': ''
            '#text': ''
            '#cdata': ''
            '#comment': ''
            '?pi': ''

    doc = xml(obj, { sysID: 'hello.dtd' }).doc()
    root = doc.root()

    eq(doc.type, builder.nodeType.Document)
    eq(doc.children[0].type, builder.nodeType.Declaration)
    eq(doc.children[1].type, builder.nodeType.DocType)
    eq(root.type, builder.nodeType.Element)
    eq(root.children[0].type, builder.nodeType.Raw)
    eq(root.children[1].type, builder.nodeType.Text)
    eq(root.children[2].type, builder.nodeType.CData)
    eq(root.children[3].type, builder.nodeType.Comment)
    eq(root.children[4].type, builder.nodeType.ProcessingInstruction)

  test 'DTD node types', ->
    dtd = xml('root', { headless: true }).dtd()
      .att('img', 'height', 'CDATA', '#REQUIRED')
      .ele('img', 'EMPTY')
      .ent('ent', 'my val')
      .pent('ent', 'my val')
      .not('fs', { sysID: 'http://my.fs.com/reader' })

    eq(dtd.type, builder.nodeType.DocType)
    eq(dtd.children[0].type, builder.nodeType.AttributeDeclaration)
    eq(dtd.children[1].type, builder.nodeType.ElementDeclaration)
    eq(dtd.children[2].type, builder.nodeType.EntityDeclaration)
    eq(dtd.children[3].type, builder.nodeType.EntityDeclaration)
    eq(dtd.children[4].type, builder.nodeType.NotationDeclaration)