Skip to content

Commit

Permalink
Basic, basic tests. But really they need more detail before merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
mixonic committed Mar 5, 2012
1 parent 0dfa591 commit 11cac50
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 0 deletions.
Empty file.
5 changes: 5 additions & 0 deletions features/regions/simple/basic_editing.feature
@@ -0,0 +1,5 @@
@javascript
Feature:
As a content editor type person
In order to manage content
I should be able to manipulate text
34 changes: 34 additions & 0 deletions spec/javascripts/mercury/regions/image_spec.js.coffee
@@ -0,0 +1,34 @@
describe "Mercury.Regions.Image", ->

template 'mercury/regions/image.html'

beforeEach ->
@regionElement = $('#editable_region1')

describe "constructor", ->

beforeEach ->
@buildSpy = spyOn(Mercury.Regions.Image.prototype, 'build').andCallFake(=>)
@bindEventsSpy = spyOn(Mercury.Regions.Image.prototype, 'bindEvents').andCallFake(=>)

it "expects an element and window", ->
@region = new Mercury.Regions.Image(@regionElement, window)
expect(@region.element.get(0)).toEqual($('#editable_region1').get(0))
expect(@region.window).toEqual(window)

it "accepts options", ->
@region = new Mercury.Regions.Image(@regionElement, window, {foo: 'something'})
expect(@region.options).toEqual({foo: 'something'})

it "sets it's type", ->
@region = new Mercury.Regions.Image(@regionElement, window)
expect(@region.type).toEqual('image')

it "calls build", ->
@region = new Mercury.Regions.Image(@regionElement, window)
expect(@buildSpy.callCount).toEqual(1)

it "calls bindEvents", ->
@region = new Mercury.Regions.Image(@regionElement, window)
expect(@bindEventsSpy.callCount).toEqual(1)

33 changes: 33 additions & 0 deletions spec/javascripts/mercury/regions/simple_spec.js.coffee
@@ -0,0 +1,33 @@
describe "Mercury.Regions.Simple", ->

template 'mercury/regions/simple.html'

beforeEach ->
@regionElement = $('#editable_region1')

describe "constructor", ->

beforeEach ->
@buildSpy = spyOn(Mercury.Regions.Simple.prototype, 'build').andCallFake(=>)
@bindEventsSpy = spyOn(Mercury.Regions.Simple.prototype, 'bindEvents').andCallFake(=>)

it "expects an element and window", ->
@region = new Mercury.Regions.Simple(@regionElement, window)
expect(@region.element.get(0)).toEqual($('#editable_region1').get(0))
expect(@region.window).toEqual(window)

it "accepts options", ->
@region = new Mercury.Regions.Simple(@regionElement, window, {foo: 'something'})
expect(@region.options).toEqual({foo: 'something'})

it "sets it's type", ->
@region = new Mercury.Regions.Simple(@regionElement, window)
expect(@region.type).toEqual('simple')

it "calls build", ->
@region = new Mercury.Regions.Simple(@regionElement, window)
expect(@buildSpy.callCount).toEqual(1)

it "calls bindEvents", ->
@region = new Mercury.Regions.Simple(@regionElement, window)
expect(@bindEventsSpy.callCount).toEqual(1)
1 change: 1 addition & 0 deletions spec/javascripts/templates/mercury/regions/image.html
@@ -0,0 +1 @@
<img id="editable_region1" src="foo.jpg" />
3 changes: 3 additions & 0 deletions spec/javascripts/templates/mercury/regions/simple.html
@@ -0,0 +1,3 @@
<div id="editable_region1">

</div>

0 comments on commit 11cac50

Please sign in to comment.