【发布时间】:2012-06-24 08:08:02
【问题描述】:
只是在做一些js测试,一直在尝试使用sinon。我有以下测试,我想在其中存根 draw 和 draw_association 函数。 jasmine 的 spyOn 似乎可以工作,但是当我使用 sinon.spy 时,它不起作用。关于为什么的任何想法?
describe "#draw", ->
text = fixture_text()
editor = null
draw_spy = null
draw_associations_spy = null
beforeEach ->
#draw_spy = sinon.spy AwesomeModel.Table.prototype, "draw"
#draw_associations_spy = sinon.spy AwesomeModel.Table.prototype, "draw_associations"
spyOn AwesomeModel.Table.prototype, "draw"
spyOn AwesomeModel.Table.prototype, "draw_associations"
editor = new AwesomeModel.Editor text
editor.parse_table_names()
afterEach ->
#draw_spy.restore()
#draw_associations_spy.restore()
it "unacceptable_coordinates should be the size of the number of tables", ->
editor.draw()
expect(editor.unacceptable_coordinates.length).toEqual editor.tables.length
【问题讨论】:
标签: coffeescript jasmine sinon