【发布时间】:2013-05-17 18:07:06
【问题描述】:
我有很多类似以下的测试:
it "Should call togglePadding if df-padding is checked", ->
spyOn(App.columnsSetupBuildingBlockController.content, 'togglePadding')
App.view.set("paddingChecked", null)
Em.run ->
App.view.set("paddingChecked", true)
expect(App.columnsSetupBuildingBlockController.content.togglePadding).toHaveBeenCalledWith(true)
it "Should call togglePadding if df-padding is unchecked", ->
spyOn(App.columnsSetupBuildingBlockController.content, 'togglePadding')
App.view.set("paddingChecked", true)
Em.run ->
App.view.set("paddingChecked", null)
expect(App.columnsSetupBuildingBlockController.content.togglePadding).toHaveBeenCalledWith(null)
每个测试中只有几个不同的值是不同的。我如何编写一个共享函数来干燥重复的位并使其看起来更干净?
我也有相同的测试来测试边距、边框等
请帮忙。
谢谢 瑞克
【问题讨论】:
标签: javascript unit-testing coffeescript jasmine