Sha256: 7978f9354676d32af6f28d8e65a01ee0a6040474c1ab7be96afcfee8cfd32b48

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

#= require ultimate/underscore/underscore
#= require ultimate/underscore/underscore.outcasts

# Include Underscore.outcasts methods to Underscore namespace
_.mixin(_.outcasts.exports())

module('Underscore.outcasts')

test "delete", ->
  obj = a: 'Apple', b: 'Banana'
  equal _.delete(obj, 'a'), 'Apple'
  deepEqual obj, {b: 'Banana'}

test "blockGiven", ->
  do (v1 = 111, v2 = 222, v3 = 333) ->
    strictEqual _.blockGiven(arguments), null
    strictEqual _.blockGiven([]), null
  do (v1 = 111, v2 = 222, block = (_v) -> "block #{_v}") ->
    ok _.isFunction(_.blockGiven(arguments))
    equal _.blockGiven(arguments)('given'), "block given"

test "sortHash", ->
  deepEqual _.sortHash({}), []
  deepEqual _.sortHash(title: 'cadabra', alt: 'bubble', href: 'abra'), [['alt', 'bubble'], ['href', 'abra'], ['title', 'cadabra']]
  deepEqual _.sortHash(title: 'cadabra', alt: 'bubble', href: 'abra', true), [['href', 'abra'], ['alt', 'bubble'], ['title', 'cadabra']]

test "invert", ->
  deepEqual _.invert(a: 1, b: 2, c: 0), {1: 'a', 2: 'b', 0: 'c'}
  obj =
    a: 1
    b: 2
    c: 0
    d: 1
    2: 'e-1'
    f: -> 'func'
  deepEqual _.invert(obj), {1: ['a', 'd'], 2: 'b', 0: 'c', 'e-1': '2'}
  deepEqual _.invert(_.invert(obj)), {a: '1', b: '2', c: '0', d: '1', 2: 'e-1'}
  deepEqual _.invert(), {}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ultimate-base-0.3.1.1 test/javascripts/tests/underscore/underscore.outcasts.test.js.coffee
ultimate-base-0.3.1 test/javascripts/tests/underscore/underscore.outcasts.test.js.coffee
ultimate-base-0.3.0 test/javascripts/tests/underscore/underscore.outcasts.test.js.coffee
ultimate-base-0.3.0.alpha test/javascripts/tests/underscore/underscore.outcasts.test.js.coffee