d688af662e271e63d49860a7f9c11b3a21f8cde3.svn-base
936 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
34
35
36
37
38
39
'use strict'
/* eslint-disable no-template-curly-in-string */
var test = require('tape')
var util = require('util')
var redeyed = require('..')
function inspect(obj) {
return util.inspect(obj, false, 5, true)
}
test('adding custom asserts ... ', function(t) {
t.constructor.prototype.assertSurrounds = function(code, opts, expected) {
var result = redeyed(code, opts, { jsx: true }).code
if (expected == null) console.log(result)
else this.equals(result, expected, inspect(code) + ' => ' + inspect(expected))
return this
}
t.end()
})
test('\njsx support', function(t) {
var config = {
'JSXIdentifier': {
className: '$xc:cx%'
, _default: '$x:x%'
}
, 'Punctuator': { _default: '$:%'
}
}
t.assertSurrounds(
'<Component start={1} className="hello" />'
, config
, '$<%$xComponentx% $xstartx%$=%${%1$}% $xcclassNamecx%$=%"hello" $/%$>%'
)
t.end()
})