Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce
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
ecommerce
Commits
8a5d8b5c
Commit
8a5d8b5c
authored
Aug 10, 2015
by
Nickersoft
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test coverage to create/edit view
parent
b2d74f0d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
170 additions
and
4 deletions
+170
-4
ecommerce/static/js/test/spec-runner.js
+4
-1
ecommerce/static/js/test/specs/views/course_create_view_spec.js
+31
-0
ecommerce/static/js/test/specs/views/course_edit_view_spec.js
+131
-0
ecommerce/static/js/utils/utils.js
+1
-1
ecommerce/static/js/views/course_create_edit_view.js
+2
-1
ecommerce/static/templates/_course_type_radio_field.html
+1
-1
No files found.
ecommerce/static/js/test/spec-runner.js
View file @
8a5d8b5c
...
...
@@ -11,7 +11,10 @@ var isBrowser = window.__karma__ === undefined,
if
(
isBrowser
)
{
// The browser cannot read directories, so all files must be enumerated below.
specs
=
[
config
.
baseUrl
+
'js/test/specs/test_spec.js'
config
.
baseUrl
+
'js/test/specs/course_create_view_spec.js'
,
config
.
baseUrl
+
'js/test/specs/course_edit_view_spec.js'
,
config
.
baseUrl
+
'js/test/specs/course_detail_view_spec.js'
,
config
.
baseUrl
+
'js/test/specs/course_list_view_spec.js'
];
}
else
{
// the E-Commerce application loads gettext identity library via django, thus
...
...
ecommerce/static/js/test/specs/views/course_create_view_spec.js
0 → 100644
View file @
8a5d8b5c
define
([
'jquery'
,
'views/course_create_edit_view'
,
'views/alert_view'
,
'models/course_model'
],
function
(
$
,
CourseCreateEditView
,
AlertView
,
Course
)
{
'use strict'
;
describe
(
'course create view'
,
function
()
{
var
view
,
model
;
beforeEach
(
function
()
{
model
=
new
Course
();
view
=
new
CourseCreateEditView
({
model
:
model
,
editing
:
false
}).
render
();
});
it
(
'should throw an error if submitted with blank fields'
,
function
()
{
var
errorHTML
=
'<strong>Error!</strong> Please complete all required fields.'
;
view
.
formView
.
submit
(
$
.
Event
(
'click'
));
expect
(
view
.
$el
.
find
(
'.alert'
).
length
).
toBe
(
1
);
expect
(
view
.
$el
.
find
(
'.alert'
).
html
()).
toBe
(
errorHTML
);
});
});
}
);
ecommerce/static/js/test/specs/views/course_edit_view_spec.js
0 → 100644
View file @
8a5d8b5c
define
([
'underscore.string'
,
'moment'
,
'views/course_create_edit_view'
,
'views/course_seat_form_fields/honor_course_seat_form_field_view'
,
'views/course_seat_form_fields/verified_course_seat_form_field_view'
,
'models/course_model'
,
'utils/utils'
,
],
function
(
_s
,
moment
,
CourseCreateEditView
,
HonorCourseSeatFormFieldView
,
VerifiedCourseSeatFormFieldView
,
Course
,
Utils
)
{
'use strict'
;
describe
(
'course edit view'
,
function
()
{
var
view
,
model
,
data
=
{
id
:
'edX/DemoX/Demo_Course'
,
url
:
'http://ecommerce.local:8002/api/v2/courses/edX/DemoX/Demo_Course/'
,
name
:
'edX Demonstration Course'
,
verification_deadline
:
null
,
type
:
'verified'
,
products_url
:
'http://ecommerce.local:8002/api/v2/courses/edX/DemoX/Demo_Course/products/'
,
last_edited
:
'2015-07-27T00:27:23Z'
,
products
:
[
{
id
:
9
,
url
:
'http://ecommerce.local:8002/api/v2/products/9/'
,
structure
:
'child'
,
product_class
:
'Seat'
,
title
:
'Seat in edX Demonstration Course with honor certificate'
,
price
:
'0.00'
,
expires
:
null
,
attribute_values
:
[
{
name
:
'certificate_type'
,
value
:
'honor'
},
{
name
:
'course_key'
,
value
:
'edX/DemoX/Demo_Course'
},
{
name
:
'id_verification_required'
,
value
:
false
}
],
is_available_to_buy
:
true
},
{
id
:
8
,
url
:
'http://ecommerce.local:8002/api/v2/products/8/'
,
structure
:
'child'
,
product_class
:
'Seat'
,
title
:
'Seat in edX Demonstration Course with verified certificate (and ID verification)'
,
price
:
'15.00'
,
expires
:
'2020-01-01T00:00:00Z'
,
attribute_values
:
[
{
name
:
'certificate_type'
,
value
:
'verified'
},
{
name
:
'course_key'
,
value
:
'edX/DemoX/Demo_Course'
},
{
name
:
'id_verification_required'
,
value
:
true
}
],
is_available_to_buy
:
true
},
{
id
:
7
,
url
:
'http://ecommerce.local:8002/api/v2/products/7/'
,
structure
:
'parent'
,
product_class
:
'Seat'
,
title
:
'Seat in edX Demonstration Course'
,
price
:
null
,
expires
:
null
,
attribute_values
:
[
{
name
:
'course_key'
,
value
:
'edX/DemoX/Demo_Course'
}
],
is_available_to_buy
:
false
}
]
};
beforeEach
(
function
()
{
model
=
Course
.
findOrCreate
(
data
,
{
parse
:
true
});
view
=
new
CourseCreateEditView
({
model
:
model
,
editing
:
true
}).
render
();
});
it
(
'should display course details in form fields'
,
function
()
{
var
checked_radios
=
view
.
$el
.
find
(
'.course-types input[type=radio]:checked'
),
type_label
=
checked_radios
.
siblings
(
'.course-type-display-name'
);
expect
(
view
.
$el
.
find
(
'[name=id]'
).
val
()).
toEqual
(
model
.
get
(
'id'
));
expect
(
view
.
$el
.
find
(
'[name=name]'
).
val
()).
toEqual
(
model
.
get
(
'name'
));
expect
(
type_label
.
text
()).
toEqual
(
_s
.
capitalize
(
model
.
get
(
'type'
)));
});
it
(
'should display correct course seats given course type'
,
function
()
{
var
honorElement
=
view
.
$el
.
find
(
'.row.course-seat.honor'
),
verifiedElement
=
view
.
$el
.
find
(
'.row.course-seat.verified'
);
expect
(
honorElement
.
length
).
toBe
(
1
);
expect
(
honorElement
.
find
(
'.seat-price'
).
text
()).
toBe
(
'$0.00'
);
expect
(
verifiedElement
.
length
).
toBe
(
1
);
expect
(
verifiedElement
.
find
(
'[name=price]'
).
val
()).
toBe
(
'15.00'
);
expect
(
verifiedElement
.
find
(
'[name=expires]'
).
val
()).
toBe
(
Utils
.
stripTimezone
(
'2020-01-01T00:00:00Z'
));
});
it
(
'should remove the edit form if the view is removed'
,
function
()
{
view
.
remove
();
expect
(
view
.
$el
.
find
(
'.course-form-view'
).
length
).
toEqual
(
0
);
});
});
}
);
ecommerce/static/js/utils/utils.js
View file @
8a5d8b5c
...
...
@@ -48,7 +48,7 @@ define([
*/
stripTimezone
:
function
(
datetime
)
{
if
(
datetime
)
{
datetime
=
moment
.
utc
(
datetime
).
format
(
'YYYY-MM-DDTHH:mm:ss'
);
datetime
=
moment
.
utc
(
new
Date
(
datetime
)
).
format
(
'YYYY-MM-DDTHH:mm:ss'
);
}
return
datetime
;
...
...
ecommerce/static/js/views/course_create_edit_view.js
View file @
8a5d8b5c
...
...
@@ -4,7 +4,8 @@ define([
'backbone.super'
,
'underscore'
,
'views/course_form_view'
,
'text!templates/course_create_edit.html'
'text!templates/course_create_edit.html'
,
'bootstrap'
],
function
(
$
,
Backbone
,
...
...
ecommerce/static/templates/_course_type_radio_field.html
View file @
8a5d8b5c
...
...
@@ -4,7 +4,7 @@
aria-describedby=
"courseType<%= type %>HelpBlock"
<%
if
(
disabled
)
{
print
('
disabled=
"disabled"
');
}
%
>
<
%
if
(
checked
)
{
print
('
checked
');
}
%
>
>
<
%=
displayName
%
>
<
div
class=
"course-type-display-name"
><
%=
displayName
%
></div
>
<span
id=
"courseType<%= type %>HelpBlock"
class=
"help-block"
>
<
%=
helpText
%
>
</span>
...
...
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