Sha256: b1f8f057346164d4aed6010ca1e0602dbc9bcdb2b773f2201f7f9876c5f78893

Contents?: true

Size: 1.4 KB

Versions: 69

Compression:

Stored size: 1.4 KB

Contents

'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('\nbefore/after config, keywords', function (t) {

  var opts001 = { Keyword: { _default: { _before: '*', _after: '&' } } };  
  t.test('\n# ' + inspect(opts001), function (t) {
    t.assertSurrounds('this', opts001, '*this&')
    t.assertSurrounds('if (a == 1) return', opts001, '*if& (a == 1) *return&')
    t.assertSurrounds('var n = new Test();', opts001, '*var& n = *new& Test();')
    t.end()
  })
  
  var opts002 = { 
    Keyword: { 
        'function': { _before: '^' }
      , 'return': { _before: '(', _after: ')' }
      , _default: { _before: '*' , _after: '&' }
    } 
  };  

  t.test('\n# ' + inspect(opts002), function (t) {
    t.assertSurrounds(
        [ 'function foo (bar) {'
        , ' var a = 3;'
        , ' return bar + a;'
        , '}'
        ].join('\n')
      , opts002
      , [ '^function& foo (bar) {'
        , ' *var& a = 3;'
        , ' (return) bar + a;'
        , '}'
        ].join('\n'))
    t.end()
  })
})

Version data entries

69 entries across 69 versions & 2 rubygems

Version Path
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.18 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.17 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.16 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.15 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.14 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.13 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.12 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.11 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.10 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.9 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.8 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.7 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.6 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.5 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.4 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js