-
-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathcommon.coffee
More file actions
33 lines (27 loc) · 760 Bytes
/
common.coffee
File metadata and controls
33 lines (27 loc) · 760 Bytes
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
global.builder = require('../src/index')
global.assert = require('assert')
global.xml = builder.create
global.doc = builder.begin
global.writer = builder.stringWriter
global.xpath = require('xpath')
global.ok = assert.ok
global.eq = assert.strictEqual
global.err = assert.throws
global.noterr = assert.doesNotThrow
global.isan = (obj, type) ->
clas = obj.constructor.name
eq(clas, type)
global.captureStream = (stream) ->
oldWrite = stream.write
buf = ''
stream.write = (chunk, encoding, callback) ->
buf += chunk.toString()
# oldWrite.apply(stream, arguments)
return {
unhook: ->
stream.write = oldWrite
captured: ->
buf
}
global.xmleleend = (arg) ->
builder.create('root', { headless: true }).ele(arg).end()