Commit 6e4ccfb7 by Jonathan Piacenti

Added Jasmine tests for always_cohort_inline_discussions.

parent 68fcdcc0
......@@ -321,7 +321,7 @@ browser and pasting the output. When that file changes, this one should be rege
<label class="field-label">
<span class="field-label-text">
Visible To:
</span><select class="field-input js-group-select" name="group_id">
</span><select class="field-input js-group-select" name="group_id" <% if (!is_commentable_cohorted) { %>disabled<% } %>>
<option value="">All Groups</option>
<% _.each(cohort_options, function(opt) { %>
<option value="<%= opt.value %>" <% if (opt.selected) { %>selected<% } %>><%- opt.text %></option>
......
......@@ -10,6 +10,15 @@ describe "NewPostView", ->
)
@discussion = new Discussion([], {pages: 1})
checkVisibility = (view, expectedVisible, expectedDisabled) =>
view.render()
expect(view.$(".js-group-select").is(":visible")).toEqual(expectedVisible)
disabled = view.$(".js-group-select").prop("disabled")
if expectedVisible and ! expectedDisabled
expect(disabled).toEqual(false)
else if expectedDisabled
expect(disabled).toEqual(true)
describe "cohort selector", ->
beforeEach ->
@course_settings = new DiscussionCourseSettings({
......@@ -32,12 +41,6 @@ describe "NewPostView", ->
mode: "tab"
)
checkVisibility = (view, expectedVisible) =>
view.render()
expect(view.$(".js-group-select").is(":visible")).toEqual(expectedVisible)
if expectedVisible
expect(view.$(".js-group-select").prop("disabled")).toEqual(false)
it "is not visible to students", ->
checkVisibility(@view, false)
......@@ -69,6 +72,46 @@ describe "NewPostView", ->
$.ajax.reset()
)
describe "always cohort inline discussions ", ->
beforeEach ->
@course_settings = new DiscussionCourseSettings({
"category_map": {
"children": [],
"entries": {}
},
"allow_anonymous": false,
"allow_anonymous_to_peers": false,
"is_cohorted": true,
"cohorts": [
{"id": 1, "name": "Cohort1"},
{"id": 2, "name": "Cohort2"}
]
})
@view = new NewPostView(
el: $("#fixture-element"),
collection: @discussion,
course_settings: @course_settings,
mode: "tab"
)
it "disables the cohort menu if it is set false", ->
DiscussionSpecHelper.makeModerator()
@view.is_commentable_cohorted = false
checkVisibility(@view, true, true)
it "enables the cohort menu if it is set true", ->
DiscussionSpecHelper.makeModerator()
@view.is_commentable_cohorted = true
checkVisibility(@view, true)
it "is not visible to students when set false", ->
@view.is_commentable_cohorted = false
checkVisibility(@view, false)
it "is not visible to students when set true", ->
@view.is_commentable_cohorted = true
checkVisibility(@view, false)
describe "cancel post resets form ", ->
beforeEach ->
@course_settings = new DiscussionCourseSettings({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment