From cbdf93473b15744e4c7130bc72159319c90bf194 Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Tue, 7 May 2013 16:21:37 -0400 Subject: [PATCH] start to get the jasmine tests working for comment service --- .../spec/discussion/content_spec.coffee | 43 +++++++++++++++++++ .../response_comment_show_view_spec.coffee | 31 +++---------- common/templates/jasmine/base.html | 5 --- .../jasmine/jasmine_test_runner.html.erb | 11 +++-- 4 files changed, 57 insertions(+), 33 deletions(-) create mode 100644 common/static/coffee/spec/discussion/content_spec.coffee diff --git a/common/static/coffee/spec/discussion/content_spec.coffee b/common/static/coffee/spec/discussion/content_spec.coffee new file mode 100644 index 0000000000..6b6188ad19 --- /dev/null +++ b/common/static/coffee/spec/discussion/content_spec.coffee @@ -0,0 +1,43 @@ +describe 'Content', -> + beforeEach -> + # TODO: figure out a better way of handling this + # It is set up in main.coffee DiscussionApp.start + window.$$course_id = 'mitX/999/test' + window.user = new DiscussionUser {id: '567'} + + @content = new Content { + id: '01234567', + user_id: '567', + course_id: 'mitX/999/test', + body: 'this is some content', + abuse_flaggers: ['123'] + } + + it 'should exist', -> + expect(Content).toBeDefined() + + it 'is initialized correctly', -> + @content.initialize + expect(Content.contents['01234567']).toEqual @content + expect(@content.get 'id').toEqual '01234567' + expect(@content.get 'user_url').toEqual '/courses/mitX/999/test/discussion/forum/users/567' + expect(@content.get 'children').toEqual [] + expect(@content.get 'comments').toEqual(jasmine.any(Comments)) + + it 'can update info', -> + @content.updateInfo { + ability: 'can_endorse', + voted: true, + subscribed: true + } + expect(@content.get 'ability').toEqual 'can_endorse' + expect(@content.get 'voted').toEqual true + expect(@content.get 'subscribed').toEqual true + + describe 'can be flagged and unflagged', -> + beforeEach -> + spyOn @content, 'trigger' + + it 'can be flagged for abuse', -> + @content.flagAbuse + expect(@content.get 'abuse_flaggers').toEqual ['123', '567'] diff --git a/common/static/coffee/spec/discussion/view/response_comment_show_view_spec.coffee b/common/static/coffee/spec/discussion/view/response_comment_show_view_spec.coffee index a4168edb3c..814a428c70 100644 --- a/common/static/coffee/spec/discussion/view/response_comment_show_view_spec.coffee +++ b/common/static/coffee/spec/discussion/view/response_comment_show_view_spec.coffee @@ -1,26 +1,7 @@ -describe "ResponseCommentShowView", -> - beforeEach -> - setFixtures """ -
  • -
    -

    This is a comment

    -
    - - -
    -

    –posted - about a minute ago by - student -

    -
    -
  • - """ - # spyOn($.fn, 'load').andReturn(@moduleData) +xdescribe "ResponseCommentShowView", -> - @showView = new ResponseCommentShowView( - el: $("li") - ) - - describe "class definition", -> - it "sets the correct tagName", -> - expect(@showView.tagName).toEqual("li") + it "defines the class", -> + spyOn myComment, 'initialize' + myComment = new Comment() + myView = new ResponseCommentShowView(myComment) + expect(myView.tagName).toBeDefined() diff --git a/common/templates/jasmine/base.html b/common/templates/jasmine/base.html index c9a32f4005..3b8013a282 100644 --- a/common/templates/jasmine/base.html +++ b/common/templates/jasmine/base.html @@ -37,22 +37,17 @@ - + + + + + + + + - -