what i like about my approach is that it is slightly better encapsulated,
since the test does not depend on any behavior outside of the object under
test.  what i like about your approach is that it tests the object in
exactly the way it is being used in the app (via binding).  i think your
approach is a hair less brittle, so i'll just switch to that.


On Thu, Feb 20, 2014 at 11:56 AM, Greg Price <notifications@github.com>wrote:

> In
> common/static/coffee/spec/discussion/view/response_comment_show_view_spec.coffee:
>
> > -            @response.set("abuse_flaggers",temp_array)
> > -            @response.unflagAbuse()
> > -            expect(@response.get 'abuse_flaggers').toEqual []
> > +            @comment.set("abuse_flaggers",temp_array)
> > +            @comment.unflagAbuse()
> > +            expect(@comment.get 'abuse_flaggers').toEqual []
> > +
> > +    describe 'comment deletion', ->
> > +
> > +        it 'calls _delete on the view when the delete icon is clicked', ->
> > +            DiscussionUtil.loadRoles []
> > +            @comment.updateInfo {ability: {'can_delete': true}}
> > +            spyOn(@view, "trigger")
> > +            @view.render()
> > +            @view.$el.find('.action-delete').click()
> > +            expect(@view.trigger).toHaveBeenCalledWith("comment:_delete", jasmine.any(Object))
>
> I was doing something similar but with a slightly different approach:
>
> triggerTarget = jasmine.createSpy()
> @view.bind "comment:_delete", triggerTarget
> ...
> expect(triggerTarget).toHaveBeenCalled()
>
> I'm not sure which I like better. Thoughts?
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/edx/edx-platform/pull/2646/files#r9913784>
> .
>