File: 208.coffee

package info (click to toggle)
node-xml2js 0.6.2%2B~cs15.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,312 kB
  • sloc: xml: 119; javascript: 7; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 750 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
path = require('path')
fs = require('fs')

suite 'Tests specific to issues:', ->
  test 'Writer events not triggered: Issue 208', ->

    errorReportObj = error:
      code: 500
      message: "failed"
    xmlPath = path.join __dirname, '208.xml'
    stream = fs.createWriteStream(xmlPath, { flags : 'w' })
    writer = builder.streamWriter(stream, { pretty: true, allowEmpty: false})
    builder.create(errorReportObj, {
      encoding: 'utf-8',
    }).end(writer)
    stream.end()
      
    stream.on('end', () ->
      eq(
        fs.readFileSync(xmlPath, 'utf8')

        """
        <?xml version="1.0" encoding="utf-8"?>
        <error>
          <code>500</code>
          <message>failed</message>
        <error>
        """
      )
    )