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.5.3 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.2 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.1 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.5.0 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.4.6 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.4.5 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.4.4 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.4.3 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.4.2 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.4.1 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.4.0 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.3.30 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.3.29 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.3.28 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.3.27 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.3.26 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.3.25 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.3.24 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.3.23 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js
trusty-festivity-extension-2.3.22 node_modules/bower/node_modules/cardinal/node_modules/redeyed/test/redeyed-before-after-config.js