File: instructions.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 (34 lines) | stat: -rw-r--r-- 1,053 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
suite 'Processing Instructions:', ->
  test 'Simple', ->
    eq(
      xml('test17', { headless: true }).ins('pi', 'mypi').end()
      '<test17><?pi mypi?></test17>'
    )

  test 'From object', ->
    eq(
      xml('test17', { headless: true }).ins({'pi': 'mypi', 'pi2': 'mypi2', 'pi3': null}).end()
      '<test17><?pi mypi?><?pi2 mypi2?><?pi3?></test17>'
    )

  test 'From array', ->
    eq(
      xml('test17', { headless: true }).ins(['pi', 'pi2']).end()
      '<test17><?pi?><?pi2?></test17>'
    )

  test 'Complex', ->
    eq(
      xml('test18', { headless: true })
        .ins('renderCache.subset', '"Verdana" 0 0 ISO-8859-1 4 268 67 "#(),-./')
        .ins('pitarget', () -> 'pivalue')
        .end()
      '<test18><?renderCache.subset "Verdana" 0 0 ISO-8859-1 4 268 67 "#(),-./?><?pitarget pivalue?></test18>'
    )

  test 'Instructions before and after root', ->
    eq(
      xml('ins', { headless: true })
        .instructionBefore('pre' ,'val1').instructionAfter('post', 'val2').end()
      '<?pre val1?><ins/><?post val2?>'
    )