Skip to content

Commit

Permalink
restructured configuration, added specs for some pulled functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
jejacks0n committed Dec 31, 2011
1 parent ea94b3c commit 2ec75a9
Show file tree
Hide file tree
Showing 10 changed files with 493 additions and 350 deletions.
284 changes: 161 additions & 123 deletions public/mercury/javascripts/mercury.js

Large diffs are not rendered by default.

241 changes: 136 additions & 105 deletions public/mercury/javascripts/mercury.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions spec/javascripts/mercury/modals/insertmedia_spec.js.coffee
Expand Up @@ -20,6 +20,7 @@ describe "Mercury.modalHandlers.insertMedia", ->
jasmine.simulate.click($('#checkbox1').get(0))
expect(spy.callCount).toEqual(1)


describe "focusing an input", ->

beforeEach ->
Expand Down
18 changes: 14 additions & 4 deletions spec/javascripts/mercury/page_editor_spec.js.coffee
Expand Up @@ -3,7 +3,7 @@ describe "Mercury.PageEditor", ->
template 'mercury/page_editor.html'

beforeEach ->
Mercury.config.regionClass = 'custom-region-class'
Mercury.config.regions.className = 'custom-region-class'

afterEach ->
@pageEditor = null
Expand Down Expand Up @@ -423,8 +423,18 @@ describe "Mercury.PageEditor", ->
spec.toolbarHideCallCount = 0
spec.statusbarShowCallCount = 0
spec.statusbarHideCallCount = 0
Mercury.Toolbar = -> {toolbar: true, height: (-> 100), show: (=> spec.toolbarShowCallCount += 1), hide: (=> spec.toolbarHideCallCount += 1)}
Mercury.Statusbar = -> {statusbar: true, top: (-> 500), show: (=> spec.statusbarShowCallCount += 1), hide: (=> spec.statusbarHideCallCount += 1)}
Mercury.Toolbar = -> {
toolbar: true,
height: (-> 100),
show: (=> spec.toolbarShowCallCount += 1),
hide: (=> spec.toolbarHideCallCount += 1)
}
Mercury.Statusbar = -> {
statusbar: true,
top: (-> 500),
show: (=> spec.statusbarShowCallCount += 1),
hide: (=> spec.statusbarHideCallCount += 1)
}
Mercury.PageEditor.prototype.initializeFrame = ->
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})

Expand Down Expand Up @@ -722,4 +732,4 @@ describe "Mercury.PageEditor", ->

it "returns an object with the region name, and it's serialized value", ->
ret = @pageEditor.serialize()
expect(ret).toEqual({region1: 'region1', region2: 'region2'})
expect(ret).toEqual({region1: 'region1', region2: 'region2'})
44 changes: 38 additions & 6 deletions spec/javascripts/mercury/region_spec.js.coffee
Expand Up @@ -3,7 +3,8 @@ describe "Mercury.Region", ->
template 'mercury/region.html'

beforeEach ->
Mercury.config.regionClass = 'custom-region-class'
Mercury.config.regions.className = 'custom-region-class'
Mercury.config.regions.dataAttributes = []

afterEach ->
@region = null
Expand Down Expand Up @@ -32,6 +33,11 @@ describe "Mercury.Region", ->
expect(@region.name).toEqual('region')
expect(@region.history).toBeDefined()

it "sets name based on configuration", ->
Mercury.config.regions.identifier = 'data-scope'
@region = new Mercury.Region($('#region'), window, {foo: 'bar'})
expect(@region.name).toEqual('scope')

it "calls build", ->
@region = new Mercury.Region($('#region'), window, {foo: 'bar'})
expect(@buildSpy.callCount).toEqual(1)
Expand Down Expand Up @@ -254,13 +260,39 @@ describe "Mercury.Region", ->
it "does nothing and is there as an interface", ->


describe "#dataAttributes", ->

beforeEach ->
Mercury.config.regions.dataAttributes = ['scope', 'version']
@region = new Mercury.Region($('#region'), window)

it "returns an object of data attributes based on configuration", ->
@region.element.attr('data-version', 2)
expect(@region.dataAttributes()).toEqual({scope: 'scope', version: '2'})


describe "#serialize", ->

beforeEach ->
@region = new Mercury.Region($('#region'), window)

it "returns an object with it's type, value, and snippets", ->
serialized = @region.serialize()
expect(serialized.type).toEqual('region')
expect(serialized.value).toEqual('contents')
expect(serialized.snippets).toEqual({})
describe "without data attributes configured", ->

it "returns an object with it's type, value, and snippets", ->
serialized = @region.serialize()
expect(serialized.type).toEqual('region')
expect(serialized.value).toEqual('contents')
expect(serialized.snippets).toEqual({})
expect(serialized.data).toEqual({})

describe "with data attributes configured", ->

beforeEach ->
Mercury.config.regions.dataAttributes = ['scope', 'version']

it "returns an object with it's type, value, data and snippets", ->
serialized = @region.serialize()
expect(serialized.type).toEqual('region')
expect(serialized.value).toEqual('contents')
expect(serialized.snippets).toEqual({})
expect(serialized.data).toEqual({scope: 'scope', version: '1'})
4 changes: 2 additions & 2 deletions spec/javascripts/templates/mercury/region.html
@@ -1,2 +1,2 @@
<div id="region">contents</div>
<div id="region_with_snippet">contents<div class="mercury-snippet" data-snippet="snippet_1" data-version="1">snippet</div></div>
<div id="region" data-scope="scope" data-version="1">contents</div>
<div id="region_with_snippet">contents<div class="mercury-snippet" data-snippet="snippet_1" data-version="1">snippet</div></div>

0 comments on commit 2ec75a9

Please sign in to comment.