start to get the jasmine tests working for comment service
This commit is contained in:
43
common/static/coffee/spec/discussion/content_spec.coffee
Normal file
43
common/static/coffee/spec/discussion/content_spec.coffee
Normal file
@@ -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']
|
||||
@@ -1,26 +1,7 @@
|
||||
describe "ResponseCommentShowView", ->
|
||||
beforeEach ->
|
||||
setFixtures """
|
||||
<li>
|
||||
<div id="comment_518910eab02379ff16000001">
|
||||
<div class="response-body"><p>This is a comment</p></div>
|
||||
<div data-tooltip="report misuse" data-role="thread-flag" class="discussion-flag-abuse notflagged">
|
||||
<i class="icon"></i>
|
||||
<span class="flag-label"></span>
|
||||
</div>
|
||||
<p class="posted-details">–posted
|
||||
<span title="2013-05-07T14:34:18Z" class="timeago">about a minute ago</span> by
|
||||
<a class="profile-link" href="/courses/MITx/999/Robot_Super_Course/discussion/forum/users/3">student</a>
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
"""
|
||||
# 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()
|
||||
|
||||
Reference in New Issue
Block a user