Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

tests for KDButtonBar component #10

Merged
merged 4 commits into from
Mar 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion gulpfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ version = if argv.buildVersion then "#{argv.buildVersion}." else ''
useLiveReload = !!argv.liveReload
useUglify = !!argv.uglify
useMinify = !!(argv.minify ? yes)
karmaAction = 'watch'


# Build Tasks
Expand Down Expand Up @@ -103,7 +104,7 @@ gulp.task 'karma', ['coffee-test'], ->
gulp.src ['./test/kd.*']
.pipe karma
configFile : 'karma.conf.js'
action : 'watch'
action : karmaAction


gulp.task 'play', ->
Expand Down Expand Up @@ -134,6 +135,8 @@ gulp.task 'sauce', ->

gulp.task 'live', -> useLiveReload = yes

gulp.task 'run', -> karmaAction = 'run'

# Watch Tasks

watchLogger = (color, watcher) ->
Expand Down
6 changes: 5 additions & 1 deletion src/components/buttons/buttonbar.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
KDView = require './../../core/view.coffee'
KDButtonView = require './buttonview'

module.exports = class KDButtonBar extends KDView
constructor: (options = {}, data) ->
Expand All @@ -15,8 +16,11 @@ module.exports = class KDButtonBar extends KDView
@addSubView button
@buttons[buttonOptions.key] = button

_itemClass: KDButtonView

createButton:(options)->
options.itemClass or= KDButtonView
options or= {}
options.itemClass or= @_itemClass
o = $.extend {}, options
delete o.itemClass
button = new options.itemClass o
32 changes: 32 additions & 0 deletions src/components/buttons/test/buttonbar.test.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{assert} = require 'chai'
sinon = require 'sinon'
KDButtonBar = require '../buttonbar'

describe 'KDButtonBar', ->
beforeEach ->
@sinon = sinon.sandbox.create()

afterEach ->
@sinon.restore()

describe 'constructor', ->
it 'should instantiate without error', ->
buttonBar = new KDButtonBar
assert.ok buttonBar

describe 'createButton', ->
beforeEach ->
@buttonBar = new KDButtonBar

it 'should create a new instance of the default button class', ->
spy = sinon.spy()
@buttonBar._itemClass = -> spy()
@buttonBar.createButton()
assert.ok spy.called

it 'should create a new instance of a passed button class', ->
stub = @sinon.stub()
buttonView = -> stub()
@buttonBar.createButton itemClass: buttonView
assert.ok stub.called

2 changes: 2 additions & 0 deletions src/components/buttons/test/index.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
describe 'Buttons', ->
require('./buttonbar.test')
11 changes: 0 additions & 11 deletions src/core/test/kd.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,3 @@ describe 'KD core', ->

assert.ok(stub.called)

xdescribe 'registerInstance', ->

xdescribe 'unregisterInstance', ->

xdescribe 'deleteInstance', ->

xdescribe 'extend', ->

xdescribe 'registerSingleton', ->

xdescribe 'getSingleton', ->
1 change: 1 addition & 0 deletions test/test.coffee
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
require('../src/core/test')
require('../src/components/buttons/test')