Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
c0fcb529
Commit
c0fcb529
authored
Oct 19, 2016
by
Syed Hassan Raza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix checking empty array
parent
eb6bb036
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
common/static/common/js/discussion/views/discussion_topic_menu_view.js
+2
-2
common/static/common/js/spec/discussion/view/discussion_topic_menu_view_spec.js
+8
-1
No files found.
common/static/common/js/discussion/views/discussion_topic_menu_view.js
View file @
c0fcb529
...
...
@@ -28,13 +28,13 @@
context
.
topics_html
=
this
.
renderCategoryMap
(
this
.
course_settings
.
get
(
'category_map'
));
edx
.
HtmlUtils
.
setHtml
(
this
.
$el
,
edx
.
HtmlUtils
.
template
(
$
(
'#topic-template'
).
html
())(
context
));
$general
=
this
.
$
(
'.post-topic option:contains(General)'
);
$general
=
this
.
$
(
'.post-topic option:contains(General)'
);
// always return array.
if
(
this
.
getCurrentTopicId
())
{
this
.
setTopic
(
this
.
$
(
'.post-topic option'
).
filter
(
'[data-discussion-id="'
+
this
.
getCurrentTopicId
()
+
'"]'
));
}
else
if
(
$general
)
{
}
else
if
(
$general
.
length
>
0
)
{
this
.
setTopic
(
$general
);
}
else
{
this
.
setTopic
(
this
.
$
(
'.post-topic option'
).
first
());
...
...
common/static/common/js/spec/discussion/view/discussion_topic_menu_view_spec.js
View file @
c0fcb529
...
...
@@ -2,6 +2,7 @@
(
function
()
{
'use strict'
;
describe
(
'DiscussionTopicMenuView'
,
function
()
{
var
ExpectedDiscussionId
;
beforeEach
(
function
()
{
this
.
createTopicView
=
function
(
options
)
{
options
=
_
.
extend
({
...
...
@@ -87,12 +88,18 @@
expect
(
this
.
view
.
$el
.
find
(
'option.topic-title:selected'
).
text
()).
toContain
(
'<em>'
);
});
it
(
'appropriate topic is selected if
`topicId`
is passed'
,
function
()
{
it
(
'appropriate topic is selected if
topicId
is passed'
,
function
()
{
this
.
createTopicView
({
topicId
:
'c49f0dfb8fc94c9c8d9999cc95190c56'
});
this
.
view
.
render
();
expect
(
this
.
view
.
$el
.
find
(
'option.topic-title:selected'
).
text
()).
toEqual
(
'Numerical Input'
);
});
it
(
'if general topic is not present then topiId is set to first discussion topicId'
,
function
()
{
this
.
createTopicView
({});
this
.
view
.
render
();
ExpectedDiscussionId
=
this
.
view
.
$
(
'.post-topic option'
).
first
().
data
(
'discussion-id'
);
expect
(
this
.
view
.
getCurrentTopicId
()).
toEqual
(
ExpectedDiscussionId
);
});
});
}).
call
(
this
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment