--
This commit is contained in:
parent
24f3d27984
commit
6b60015c02
9588 changed files with 1149251 additions and 49 deletions
48
node_modules/redeyed/test/redeyed-mixed.js
generated
vendored
Normal file
48
node_modules/redeyed/test/redeyed-mixed.js
generated
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
'use strict';
|
||||
/*jshint asi: true*/
|
||||
|
||||
var test = require('tap').test
|
||||
, util = require('util')
|
||||
, 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).code
|
||||
this.equals(result, expected, inspect(code) + ' => ' + inspect(expected))
|
||||
return this;
|
||||
}
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('\nmixed config, keywords', function (t) {
|
||||
var opts001 = {
|
||||
Keyword: {
|
||||
'this': function (s) { return '_' + s; }
|
||||
, 'if': { _before: '^' }
|
||||
, _default: '*:&'
|
||||
}
|
||||
};
|
||||
t.test('\n# ' + inspect(opts001), function (t) {
|
||||
t.assertSurrounds('if (this.hello) return "world";', opts001, '^if& (_this.hello) *return& "world";').end()
|
||||
})
|
||||
|
||||
var opts002 = {
|
||||
Keyword: {
|
||||
'this': function (s) { return '_' + s; }
|
||||
, 'if': { _before: '^' }
|
||||
, 'return': ':)'
|
||||
, _default: ':&'
|
||||
}
|
||||
, _default: '*:&'
|
||||
};
|
||||
t.test('\n# ' + inspect(opts002), function (t) {
|
||||
t.assertSurrounds('if (this.hello) return "world";', opts002, '^if& (_this.hello) *return) "world";').end()
|
||||
})
|
||||
|
||||
t.end()
|
||||
})
|
||||
Loading…
Reference in a new issue