Sha256: b3eae1d563fe7551a295e78d83563198774c718892ec4142378d62cfedfc649e

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require '/assets/mercury.js'

describe "Mercury", ->

  describe "supported:", ->

    # this is here for documentation -- unable to test, because this is evaluated on script load
    it "checks document.getElementById", ->
    it "checks document.designMode", ->
    it "disallows konqueror and msie", ->


  describe "#bind", ->

    it "binds an event prefixed with 'mercury:' to the top window", ->
      callCount = 0
      Mercury.bind('test', -> callCount += 1)
      $(top).trigger("mercury:test")
      expect(callCount).toEqual(1)


  describe "#trigger", ->

    it "triggers an event prefixed with 'mercury:' on the top window", ->
      argsForCall = []
      callCount = 0
      Mercury.bind('test', -> argsForCall[callCount] = arguments; callCount += 1)
      Mercury.trigger("test", {foo: 'bar'})
      expect(callCount).toEqual(1)
      expect(argsForCall[0][1]).toEqual({foo: 'bar'})


  describe "#log", ->

    beforeEach ->
      window.console = {debug: -> ''}
      @debugSpy = spyOn(window.console, 'debug').andCallFake(=>)
      Mercury.debug = true

    it "calls console.debug", ->
      Mercury.log(1, 2)
      expect(@debugSpy.callCount).toEqual(1)

    it "does nothing if debug mode isn't on", ->
      Mercury.debug = false
      Mercury.log(1, 2)
      expect(@debugSpy.callCount).toEqual(0)

    it "does nothing if there's no console", ->
      window.console = null
      Mercury.log(1, 2)
      expect(@debugSpy.callCount).toEqual(0)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mercury-rails-0.2.3 spec/javascripts/mercury/mercury_spec.js.coffee