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
18f7315a
Commit
18f7315a
authored
Aug 18, 2015
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #285 from edx/clintonb/test-wrap
Properly wrapping tests
parents
1096ba34
1cd050f9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
262 additions
and
243 deletions
+262
-243
ecommerce/static/js/test/specs/collections/course_collection_spec.js
+12
-10
ecommerce/static/js/test/specs/models/course_model_spec.js
+89
-87
ecommerce/static/js/test/specs/models/course_seats/course_seat_spec.js
+58
-56
ecommerce/static/js/test/specs/models/product_model_spec.js
+28
-26
ecommerce/static/js/test/specs/utils/course_utils_spec.js
+20
-18
ecommerce/static/js/test/specs/utils/utils_spec.js
+21
-19
ecommerce/static/js/test/specs/views/course_seat_form_fields/course_seat_form_field_view_spec.js
+6
-4
ecommerce/static/js/test/specs/views/course_seat_form_fields/professional_course_seat_form_field_view_spec.js
+17
-14
ecommerce/static/js/test/specs/views/course_seat_form_fields/verified_seat_form_field_view_spec.js
+11
-9
No files found.
ecommerce/static/js/test/specs/collections/course_collection_spec.js
View file @
18f7315a
...
@@ -25,18 +25,20 @@ define([
...
@@ -25,18 +25,20 @@ define([
collection
=
new
CourseCollection
();
collection
=
new
CourseCollection
();
});
});
describe
(
'parse'
,
function
()
{
describe
(
'Course collection'
,
function
()
{
it
(
'should return the results list in the response'
,
function
()
{
describe
(
'parse'
,
function
()
{
expect
(
collection
.
parse
(
response
)).
toEqual
(
response
.
results
);
it
(
'should return the results list in the response'
,
function
()
{
});
expect
(
collection
.
parse
(
response
)).
toEqual
(
response
.
results
);
});
it
(
'should fetch the next page of results'
,
function
()
{
it
(
'should fetch the next page of results'
,
function
()
{
spyOn
(
collection
,
'fetch'
).
and
.
returnValue
(
null
);
spyOn
(
collection
,
'fetch'
).
and
.
returnValue
(
null
);
response
.
next
=
'/api/v2/courses/?page=2'
;
response
.
next
=
'/api/v2/courses/?page=2'
;
collection
.
parse
(
response
);
collection
.
parse
(
response
);
expect
(
collection
.
url
).
toEqual
(
response
.
next
);
expect
(
collection
.
url
).
toEqual
(
response
.
next
);
expect
(
collection
.
fetch
).
toHaveBeenCalledWith
({
remove
:
false
});
expect
(
collection
.
fetch
).
toHaveBeenCalledWith
({
remove
:
false
});
});
});
});
});
});
}
}
...
...
ecommerce/static/js/test/specs/models/course_model_spec.js
View file @
18f7315a
...
@@ -98,123 +98,125 @@ define([
...
@@ -98,123 +98,125 @@ define([
model
=
Course
.
findOrCreate
(
data
,
{
parse
:
true
});
model
=
Course
.
findOrCreate
(
data
,
{
parse
:
true
});
});
});
describe
(
'removeParentProducts'
,
function
()
{
describe
(
'Course model'
,
function
()
{
it
(
'should remove all parent products from the products collection'
,
function
()
{
describe
(
'removeParentProducts'
,
function
()
{
var
products
=
model
.
get
(
'products'
);
it
(
'should remove all parent products from the products collection'
,
function
()
{
var
products
=
model
.
get
(
'products'
);
// Sanity check to ensure the products were properly parsed
// Sanity check to ensure the products were properly parsed
expect
(
products
.
length
).
toEqual
(
3
);
expect
(
products
.
length
).
toEqual
(
3
);
// Remove the parent products
// Remove the parent products
model
.
removeParentProducts
();
model
.
removeParentProducts
();
// Only the children survived...
// Only the children survived...
expect
(
products
.
length
).
toEqual
(
2
);
expect
(
products
.
length
).
toEqual
(
2
);
expect
(
products
.
where
({
structure
:
'child'
}).
length
).
toEqual
(
2
);
expect
(
products
.
where
({
structure
:
'child'
}).
length
).
toEqual
(
2
);
});
});
});
});
// NOTE (CCB): There is a bug preventing this from being called 'toJSON'.
// See https://github.com/karma-runner/karma/issues/1534.
describe
(
'#toJSON'
,
function
()
{
it
(
'should not modify verification_deadline if verification_deadline is empty'
,
function
()
{
var
json
,
values
=
[
null
,
''
];
_
.
each
(
values
,
function
(
value
)
{
// NOTE (CCB): There is a bug preventing this from being called 'toJSON'.
model
.
set
(
'verification_deadline'
,
value
);
// See https://github.com/karma-runner/karma/issues/1534.
json
=
model
.
toJSON
();
describe
(
'#toJSON'
,
function
()
{
expect
(
json
.
verification_deadline
).
toEqual
(
value
);
it
(
'should not modify verification_deadline if verification_deadline is empty'
,
function
()
{
var
json
,
values
=
[
null
,
''
];
_
.
each
(
values
,
function
(
value
)
{
model
.
set
(
'verification_deadline'
,
value
);
json
=
model
.
toJSON
();
expect
(
json
.
verification_deadline
).
toEqual
(
value
);
});
});
});
});
it
(
'should add a timezone to verification_deadline if verification_deadline is not empty'
,
function
()
{
it
(
'should add a timezone to verification_deadline if verification_deadline is not empty'
,
function
()
{
var
json
,
var
json
,
deadline
=
'2015-01-01T00:00:00'
;
deadline
=
'2015-01-01T00:00:00'
;
model
.
set
(
'verification_deadline'
,
deadline
);
model
.
set
(
'verification_deadline'
,
deadline
);
json
=
model
.
toJSON
();
json
=
model
.
toJSON
();
expect
(
json
.
verification_deadline
).
toEqual
(
deadline
+
'+00:00'
);
expect
(
json
.
verification_deadline
).
toEqual
(
deadline
+
'+00:00'
);
});
});
});
});
describe
(
'save'
,
function
()
{
describe
(
'save'
,
function
()
{
var
expectedAjaxData
=
function
(
data
)
{
var
expectedAjaxData
=
function
(
data
)
{
var
products
,
var
products
,
expected
=
{
expected
=
{
id
:
data
.
id
,
id
:
data
.
id
,
name
:
data
.
name
,
name
:
data
.
name
,
verification_deadline
:
moment
.
utc
(
data
.
verification_deadline
).
format
()
verification_deadline
:
moment
.
utc
(
data
.
verification_deadline
).
format
()
};
};
products
=
_
.
filter
(
data
.
products
,
function
(
product
)
{
products
=
_
.
filter
(
data
.
products
,
function
(
product
)
{
return
product
.
structure
===
'child'
;
return
product
.
structure
===
'child'
;
});
});
expected
.
products
=
_
.
map
(
products
,
function
(
product
)
{
expected
.
products
=
_
.
map
(
products
,
function
(
product
)
{
return
product
;
return
product
;
});
});
return
expected
;
return
expected
;
};
};
it
(
'should POST to the publication endpoint'
,
function
()
{
it
(
'should POST to the publication endpoint'
,
function
()
{
var
args
,
var
args
,
cookie
=
'save-test'
;
cookie
=
'save-test'
;
spyOn
(
$
,
'ajax'
);
spyOn
(
$
,
'ajax'
);
$
.
cookie
(
'ecommerce_csrftoken'
,
cookie
);
$
.
cookie
(
'ecommerce_csrftoken'
,
cookie
);
model
.
save
();
model
.
save
();
// $.ajax should have been called
// $.ajax should have been called
expect
(
$
.
ajax
).
toHaveBeenCalled
();
expect
(
$
.
ajax
).
toHaveBeenCalled
();
// Ensure the data was POSTed to the correct endpoint
// Ensure the data was POSTed to the correct endpoint
args
=
$
.
ajax
.
calls
.
argsFor
(
0
)[
0
];
args
=
$
.
ajax
.
calls
.
argsFor
(
0
)[
0
];
expect
(
args
.
type
).
toEqual
(
'POST'
);
expect
(
args
.
type
).
toEqual
(
'POST'
);
expect
(
args
.
url
).
toEqual
(
'/api/v2/publication/'
);
expect
(
args
.
url
).
toEqual
(
'/api/v2/publication/'
);
expect
(
args
.
contentType
).
toEqual
(
'application/json'
);
expect
(
args
.
contentType
).
toEqual
(
'application/json'
);
expect
(
args
.
headers
).
toEqual
({
'X-CSRFToken'
:
cookie
});
expect
(
args
.
headers
).
toEqual
({
'X-CSRFToken'
:
cookie
});
expect
(
JSON
.
parse
(
args
.
data
)).
toEqual
(
expectedAjaxData
(
data
));
expect
(
JSON
.
parse
(
args
.
data
)).
toEqual
(
expectedAjaxData
(
data
));
});
});
});
});
describe
(
'getOrCreateSeat'
,
function
()
{
describe
(
'getOrCreateSeat'
,
function
()
{
it
(
'should return existing seats'
,
function
()
{
it
(
'should return existing seats'
,
function
()
{
var
mapping
=
{
var
mapping
=
{
'honor'
:
honorSeat
,
'honor'
:
honorSeat
,
'verified'
:
verifiedSeat
'verified'
:
verifiedSeat
};
};
_
.
each
(
mapping
,
function
(
expected
,
seatType
)
{
_
.
each
(
mapping
,
function
(
expected
,
seatType
)
{
expect
(
model
.
getOrCreateSeat
(
seatType
).
toJSON
()).
toEqual
(
expected
);
expect
(
model
.
getOrCreateSeat
(
seatType
).
toJSON
()).
toEqual
(
expected
);
});
});
});
});
it
(
'should return null if an audit seat does not already exist'
,
function
()
{
it
(
'should return null if an audit seat does not already exist'
,
function
()
{
expect
(
model
.
getOrCreateSeat
(
'audit'
)).
toBeUndefined
();
expect
(
model
.
getOrCreateSeat
(
'audit'
)).
toBeUndefined
();
});
});
it
(
'should create a new CourseSeat if one does not exist'
,
function
()
{
it
(
'should create a new CourseSeat if one does not exist'
,
function
()
{
var
seat
;
var
seat
;
// Sanity check to confirm a new seat is created later
// Sanity check to confirm a new seat is created later
expect
(
model
.
seats
().
length
).
toEqual
(
2
);
expect
(
model
.
seats
().
length
).
toEqual
(
2
);
// A new seat should be created
// A new seat should be created
seat
=
model
.
getOrCreateSeat
(
'professional'
);
seat
=
model
.
getOrCreateSeat
(
'professional'
);
expect
(
model
.
seats
().
length
).
toEqual
(
3
);
expect
(
model
.
seats
().
length
).
toEqual
(
3
);
// The new seat's class/type should correspond to the passed in seat type
// The new seat's class/type should correspond to the passed in seat type
expect
(
seat
).
toEqual
(
jasmine
.
any
(
ProfessionalSeat
));
expect
(
seat
).
toEqual
(
jasmine
.
any
(
ProfessionalSeat
));
});
});
});
});
describe
(
'products'
,
function
()
{
describe
(
'products'
,
function
()
{
it
(
'is a ProductCollection'
,
function
()
{
it
(
'is a ProductCollection'
,
function
()
{
expect
(
model
.
get
(
'products'
)).
toEqual
(
jasmine
.
any
(
ProductCollection
));
expect
(
model
.
get
(
'products'
)).
toEqual
(
jasmine
.
any
(
ProductCollection
));
});
});
});
});
});
}
}
...
...
ecommerce/static/js/test/specs/models/course_seats/course_seat_spec.js
View file @
18f7315a
...
@@ -36,80 +36,82 @@ define([
...
@@ -36,80 +36,82 @@ define([
model
=
CourseSeat
.
findOrCreate
(
data
,
{
parse
:
true
});
model
=
CourseSeat
.
findOrCreate
(
data
,
{
parse
:
true
});
});
});
describe
(
'getSeatType'
,
function
()
{
describe
(
'Course seat model'
,
function
()
{
it
(
'should return a seat type corresponding to the certificate type'
,
function
()
{
describe
(
'getSeatType'
,
function
()
{
var
mappings
=
{
it
(
'should return a seat type corresponding to the certificate type'
,
function
()
{
'credit'
:
'credit'
,
var
mappings
=
{
'honor'
:
'honor'
,
'credit'
:
'credit'
,
'no-id-professional'
:
'professional'
,
'honor'
:
'honor'
,
'professional'
:
'professional'
,
'no-id-professional'
:
'professional'
,
'verified'
:
'verified'
'professional'
:
'professional'
,
};
'verified'
:
'verified'
};
_
.
each
(
mappings
,
function
(
seatType
,
certificateType
)
{
_
.
each
(
mappings
,
function
(
seatType
,
certificateType
)
{
model
.
set
(
'certificate_type'
,
certificateType
);
model
.
set
(
'certificate_type'
,
certificateType
);
expect
(
model
.
getSeatType
()).
toEqual
(
seatType
);
expect
(
model
.
getSeatType
()).
toEqual
(
seatType
);
});
});
});
});
it
(
'should return audit for empty certificate types'
,
function
()
{
it
(
'should return audit for empty certificate types'
,
function
()
{
var
certificate_types
=
[
''
,
null
];
var
certificate_types
=
[
''
,
null
];
_
.
each
(
certificate_types
,
function
(
certificateType
)
{
_
.
each
(
certificate_types
,
function
(
certificateType
)
{
model
.
set
(
'certificate_type'
,
certificateType
);
model
.
set
(
'certificate_type'
,
certificateType
);
expect
(
model
.
getSeatType
()).
toEqual
(
'audit'
);
expect
(
model
.
getSeatType
()).
toEqual
(
'audit'
);
});
});
});
});
});
});
describe
(
'getSeatTypeDisplayName'
,
function
()
{
describe
(
'getSeatTypeDisplayName'
,
function
()
{
it
(
'should return a value corresponding to the certificate type'
,
function
()
{
it
(
'should return a value corresponding to the certificate type'
,
function
()
{
var
mappings
=
{
var
mappings
=
{
'credit'
:
'Credit'
,
'credit'
:
'Credit'
,
'honor'
:
'Honor'
,
'honor'
:
'Honor'
,
'no-id-professional'
:
'Professional'
,
'no-id-professional'
:
'Professional'
,
'professional'
:
'Professional'
,
'professional'
:
'Professional'
,
'verified'
:
'Verified'
'verified'
:
'Verified'
};
};
_
.
each
(
mappings
,
function
(
seatType
,
certificateType
)
{
_
.
each
(
mappings
,
function
(
seatType
,
certificateType
)
{
model
.
set
(
'certificate_type'
,
certificateType
);
model
.
set
(
'certificate_type'
,
certificateType
);
expect
(
model
.
getSeatTypeDisplayName
()).
toEqual
(
seatType
);
expect
(
model
.
getSeatTypeDisplayName
()).
toEqual
(
seatType
);
});
});
});
});
it
(
'should return Audit for empty certificate types'
,
function
()
{
it
(
'should return Audit for empty certificate types'
,
function
()
{
var
certificate_types
=
[
''
,
null
];
var
certificate_types
=
[
''
,
null
];
_
.
each
(
certificate_types
,
function
(
certificateType
)
{
_
.
each
(
certificate_types
,
function
(
certificateType
)
{
model
.
set
(
'certificate_type'
,
certificateType
);
model
.
set
(
'certificate_type'
,
certificateType
);
expect
(
model
.
getSeatTypeDisplayName
()).
toEqual
(
'Audit'
);
expect
(
model
.
getSeatTypeDisplayName
()).
toEqual
(
'Audit'
);
});
});
});
});
});
});
describe
(
'getCertificateDisplayName'
,
function
()
{
describe
(
'getCertificateDisplayName'
,
function
()
{
it
(
'should return a value corresponding to the certificate type'
,
function
()
{
it
(
'should return a value corresponding to the certificate type'
,
function
()
{
var
mappings
=
{
var
mappings
=
{
'credit'
:
'Verified Certificate'
,
'credit'
:
'Verified Certificate'
,
'honor'
:
'Honor Certificate'
,
'honor'
:
'Honor Certificate'
,
'no-id-professional'
:
'Professional Certificate'
,
'no-id-professional'
:
'Professional Certificate'
,
'professional'
:
'Professional Certificate'
,
'professional'
:
'Professional Certificate'
,
'verified'
:
'Verified Certificate'
'verified'
:
'Verified Certificate'
};
};
_
.
each
(
mappings
,
function
(
seatType
,
certificateType
)
{
_
.
each
(
mappings
,
function
(
seatType
,
certificateType
)
{
model
.
set
(
'certificate_type'
,
certificateType
);
model
.
set
(
'certificate_type'
,
certificateType
);
expect
(
model
.
getCertificateDisplayName
()).
toEqual
(
seatType
);
expect
(
model
.
getCertificateDisplayName
()).
toEqual
(
seatType
);
});
});
});
});
it
(
'should return (No Certificate) for empty certificate types'
,
function
()
{
it
(
'should return (No Certificate) for empty certificate types'
,
function
()
{
var
certificate_types
=
[
''
,
null
];
var
certificate_types
=
[
''
,
null
];
_
.
each
(
certificate_types
,
function
(
certificateType
)
{
_
.
each
(
certificate_types
,
function
(
certificateType
)
{
model
.
set
(
'certificate_type'
,
certificateType
);
model
.
set
(
'certificate_type'
,
certificateType
);
expect
(
model
.
getCertificateDisplayName
()).
toEqual
(
'(No Certificate)'
);
expect
(
model
.
getCertificateDisplayName
()).
toEqual
(
'(No Certificate)'
);
});
});
});
});
});
});
});
...
...
ecommerce/static/js/test/specs/models/product_model_spec.js
View file @
18f7315a
...
@@ -36,40 +36,42 @@ define([
...
@@ -36,40 +36,42 @@ define([
model
=
Product
.
findOrCreate
(
data
,
{
parse
:
true
});
model
=
Product
.
findOrCreate
(
data
,
{
parse
:
true
});
});
});
// NOTE (CCB): There is a bug preventing this from being called 'toJSON'.
describe
(
'Product model'
,
function
()
{
// See https://github.com/karma-runner/karma/issues/1534.
// NOTE (CCB): There is a bug preventing this from being called 'toJSON'.
describe
(
'#toJSON'
,
function
()
{
// See https://github.com/karma-runner/karma/issues/1534.
it
(
'should not modify expires if expires is empty'
,
function
()
{
describe
(
'#toJSON'
,
function
()
{
var
json
,
it
(
'should not modify expires if expires is empty'
,
function
()
{
values
=
[
null
,
''
];
var
json
,
values
=
[
null
,
''
];
_
.
each
(
values
,
function
(
value
)
{
_
.
each
(
values
,
function
(
value
)
{
model
.
set
(
'expires'
,
value
);
model
.
set
(
'expires'
,
value
);
json
=
model
.
toJSON
();
json
=
model
.
toJSON
();
expect
(
json
.
expires
).
toEqual
(
value
);
expect
(
json
.
expires
).
toEqual
(
value
);
});
});
});
});
it
(
'should add a timezone to expires if expires is not empty'
,
function
()
{
it
(
'should add a timezone to expires if expires is not empty'
,
function
()
{
var
json
,
var
json
,
deadline
=
'2015-01-01T00:00:00'
;
deadline
=
'2015-01-01T00:00:00'
;
model
.
set
(
'expires'
,
deadline
);
model
.
set
(
'expires'
,
deadline
);
json
=
model
.
toJSON
();
json
=
model
.
toJSON
();
expect
(
json
.
expires
).
toEqual
(
deadline
+
'+00:00'
);
expect
(
json
.
expires
).
toEqual
(
deadline
+
'+00:00'
);
});
});
it
(
'should re-nest the un-nested attributes'
,
function
()
{
it
(
'should re-nest the un-nested attributes'
,
function
()
{
var
json
=
model
.
toJSON
();
var
json
=
model
.
toJSON
();
// Sanity check
// Sanity check
expect
(
model
.
get
(
'certificate_type'
)).
toEqual
(
'verified'
);
expect
(
model
.
get
(
'certificate_type'
)).
toEqual
(
'verified'
);
expect
(
model
.
get
(
'course_key'
)).
toEqual
(
'edX/DemoX/Demo_Course'
);
expect
(
model
.
get
(
'course_key'
)).
toEqual
(
'edX/DemoX/Demo_Course'
);
expect
(
model
.
get
(
'id_verification_required'
)).
toEqual
(
true
);
expect
(
model
.
get
(
'id_verification_required'
)).
toEqual
(
true
);
// Very the attributes have been re-nested
// Very the attributes have been re-nested
expect
(
json
.
attribute_values
).
toEqual
(
data
.
attribute_values
);
expect
(
json
.
attribute_values
).
toEqual
(
data
.
attribute_values
);
});
});
});
});
});
}
}
...
...
ecommerce/static/js/test/specs/utils/course_utils_spec.js
View file @
18f7315a
...
@@ -16,28 +16,30 @@ define([
...
@@ -16,28 +16,30 @@ define([
VerifiedSeat
)
{
VerifiedSeat
)
{
'use strict'
;
'use strict'
;
describe
(
'getCourseSeatModel'
,
function
()
{
describe
(
'CourseUtils'
,
function
()
{
it
(
'should return the CourseSeat child class corresponding to a seat type'
,
function
()
{
describe
(
'getCourseSeatModel'
,
function
()
{
expect
(
CourseUtils
.
getCourseSeatModel
(
'audit'
)).
toEqual
(
AuditSeat
);
it
(
'should return the CourseSeat child class corresponding to a seat type'
,
function
()
{
expect
(
CourseUtils
.
getCourseSeatModel
(
'honor'
)).
toEqual
(
HonorSeat
);
expect
(
CourseUtils
.
getCourseSeatModel
(
'audit'
)).
toEqual
(
AuditSeat
);
expect
(
CourseUtils
.
getCourseSeatModel
(
'professional'
)).
toEqual
(
ProfessionalSeat
);
expect
(
CourseUtils
.
getCourseSeatModel
(
'honor'
)).
toEqual
(
HonorSeat
);
expect
(
CourseUtils
.
getCourseSeatModel
(
'verified'
)).
toEqual
(
VerifiedSeat
);
expect
(
CourseUtils
.
getCourseSeatModel
(
'professional'
)).
toEqual
(
ProfessionalSeat
);
});
expect
(
CourseUtils
.
getCourseSeatModel
(
'verified'
)).
toEqual
(
VerifiedSeat
);
});
it
(
'should return CourseSeat if the seat type is unknown'
,
function
()
{
it
(
'should return CourseSeat if the seat type is unknown'
,
function
()
{
expect
(
CourseUtils
.
getCourseSeatModel
(
null
)).
toEqual
(
CourseSeat
);
expect
(
CourseUtils
.
getCourseSeatModel
(
null
)).
toEqual
(
CourseSeat
);
});
});
});
});
describe
(
'orderSeatTypesForDisplay'
,
function
()
{
describe
(
'orderSeatTypesForDisplay'
,
function
()
{
it
(
'should return a list ordered seat types'
,
function
()
{
it
(
'should return a list ordered seat types'
,
function
()
{
var
data
=
[
var
data
=
[
[
'audit'
,
'professional'
,
'credit'
],
[
'audit'
,
'professional'
,
'credit'
],
[
'audit'
,
'honor'
,
'verified'
,
'professional'
,
'credit'
]
[
'audit'
,
'honor'
,
'verified'
,
'professional'
,
'credit'
]
];
];
_
.
each
(
data
,
function
(
expected
)
{
_
.
each
(
data
,
function
(
expected
)
{
expect
(
CourseUtils
.
orderSeatTypesForDisplay
(
_
.
shuffle
(
expected
))).
toEqual
(
expected
);
expect
(
CourseUtils
.
orderSeatTypesForDisplay
(
_
.
shuffle
(
expected
))).
toEqual
(
expected
);
});
});
});
});
});
});
});
...
...
ecommerce/static/js/test/specs/utils/utils_spec.js
View file @
18f7315a
...
@@ -4,29 +4,31 @@ define([
...
@@ -4,29 +4,31 @@ define([
function
(
Utils
)
{
function
(
Utils
)
{
'use strict'
;
'use strict'
;
describe
(
'stripTimezone'
,
function
()
{
describe
(
'Utils'
,
function
()
{
it
(
'should return the input value if the input is empty'
,
function
()
{
describe
(
'stripTimezone'
,
function
()
{
expect
(
Utils
.
stripTimezone
(
''
)).
toEqual
(
''
);
it
(
'should return the input value if the input is empty'
,
function
()
{
expect
(
Utils
.
stripTimezone
(
null
)).
toBeNull
();
expect
(
Utils
.
stripTimezone
(
''
)).
toEqual
(
''
);
expect
(
Utils
.
stripTimezone
(
undefined
)).
toBeUndefined
();
expect
(
Utils
.
stripTimezone
(
null
)).
toBeNull
();
});
expect
(
Utils
.
stripTimezone
(
undefined
)).
toBeUndefined
();
});
it
(
'should return the datetime without the timezone component'
,
function
()
{
it
(
'should return the datetime without the timezone component'
,
function
()
{
var
dt
=
'2015-01-01T00:00:00'
;
var
dt
=
'2015-01-01T00:00:00'
;
expect
(
Utils
.
stripTimezone
(
dt
+
'Z'
)).
toEqual
(
dt
);
expect
(
Utils
.
stripTimezone
(
dt
+
'Z'
)).
toEqual
(
dt
);
});
});
});
});
describe
(
'restoreTimezone'
,
function
()
{
describe
(
'restoreTimezone'
,
function
()
{
it
(
'should return the input value if the input is empty'
,
function
()
{
it
(
'should return the input value if the input is empty'
,
function
()
{
expect
(
Utils
.
restoreTimezone
(
''
)).
toEqual
(
''
);
expect
(
Utils
.
restoreTimezone
(
''
)).
toEqual
(
''
);
expect
(
Utils
.
restoreTimezone
(
null
)).
toBeNull
();
expect
(
Utils
.
restoreTimezone
(
null
)).
toBeNull
();
expect
(
Utils
.
restoreTimezone
(
undefined
)).
toBeUndefined
();
expect
(
Utils
.
restoreTimezone
(
undefined
)).
toBeUndefined
();
});
});
it
(
'should return the datetime with the timezone component'
,
function
()
{
it
(
'should return the datetime with the timezone component'
,
function
()
{
var
dt
=
'2015-01-01T00:00:00'
;
var
dt
=
'2015-01-01T00:00:00'
;
expect
(
Utils
.
restoreTimezone
(
dt
)).
toEqual
(
dt
+
'+00:00'
);
expect
(
Utils
.
restoreTimezone
(
dt
)).
toEqual
(
dt
+
'+00:00'
);
});
});
});
});
});
}
}
...
...
ecommerce/static/js/test/specs/views/course_seat_form_fields/course_seat_form_field_view_spec.js
View file @
18f7315a
...
@@ -13,10 +13,12 @@ define([
...
@@ -13,10 +13,12 @@ define([
view
=
new
CourseSeatFormFieldView
({
model
:
model
});
view
=
new
CourseSeatFormFieldView
({
model
:
model
});
});
});
describe
(
'cleanIdVerificationRequired'
,
function
()
{
describe
(
'course seat form field view'
,
function
()
{
it
(
'should always return a boolean'
,
function
()
{
describe
(
'cleanIdVerificationRequired'
,
function
()
{
expect
(
view
.
cleanIdVerificationRequired
(
'false'
)).
toEqual
(
false
);
it
(
'should always return a boolean'
,
function
()
{
expect
(
view
.
cleanIdVerificationRequired
(
'true'
)).
toEqual
(
true
);
expect
(
view
.
cleanIdVerificationRequired
(
'false'
)).
toEqual
(
false
);
expect
(
view
.
cleanIdVerificationRequired
(
'true'
)).
toEqual
(
true
);
});
});
});
});
});
}
}
...
...
ecommerce/static/js/test/specs/views/course_seat_form_fields/professional_course_seat_form_field_view_spec.js
View file @
18f7315a
...
@@ -13,22 +13,25 @@ define([
...
@@ -13,22 +13,25 @@ define([
view
=
new
CourseSeatFormFieldView
({
model
:
model
}).
render
();
view
=
new
CourseSeatFormFieldView
({
model
:
model
}).
render
();
});
});
describe
(
'getFieldValue'
,
function
()
{
describe
(
'professional course seat form field view'
,
function
()
{
it
(
'should return a boolean if the name is id_verification_required'
,
function
()
{
describe
(
'getFieldValue'
,
function
()
{
// NOTE (CCB): Ideally _.each should be used here to loop over an array of Boolean values.
it
(
'should return a boolean if the name is id_verification_required'
,
function
()
{
// However, the tests fail when that implementation is used, hence the repeated code.
// NOTE (CCB): Ideally _.each should be used here to loop over an array of Boolean values.
model
.
set
(
'id_verification_required'
,
false
);
// However, the tests fail when that implementation is used, hence the repeated code.
expect
(
model
.
get
(
'id_verification_required'
)).
toEqual
(
false
);
model
.
set
(
'id_verification_required'
,
false
);
expect
(
view
.
getFieldValue
(
'id_verification_required'
)).
toEqual
(
false
);
expect
(
model
.
get
(
'id_verification_required'
)).
toEqual
(
false
);
expect
(
view
.
getFieldValue
(
'id_verification_required'
)).
toEqual
(
false
);
model
.
set
(
'id_verification_required'
,
true
);
model
.
set
(
'id_verification_required'
,
true
);
expect
(
model
.
get
(
'id_verification_required'
)).
toEqual
(
true
);
expect
(
model
.
get
(
'id_verification_required'
)).
toEqual
(
true
);
expect
(
view
.
getFieldValue
(
'id_verification_required'
)).
toEqual
(
true
);
expect
(
view
.
getFieldValue
(
'id_verification_required'
)).
toEqual
(
true
);
});
});
// NOTE (CCB): This test is flaky (hence it being skipped). Occasionally, calls to the parent class fail.
// NOTE (CCB): This test is flaky (hence it being skipped).
xit
(
'should always return professional if the name is certificate_type'
,
function
()
{
// Occasionally, calls to the parent class fail.
expect
(
view
.
getFieldValue
(
'certificate_type'
)).
toEqual
(
'professional'
);
xit
(
'should always return professional if the name is certificate_type'
,
function
()
{
expect
(
view
.
getFieldValue
(
'certificate_type'
)).
toEqual
(
'professional'
);
});
});
});
});
});
}
}
...
...
ecommerce/static/js/test/specs/views/course_seat_form_fields/verified_seat_form_field_view_spec.js
View file @
18f7315a
...
@@ -13,16 +13,18 @@ define([
...
@@ -13,16 +13,18 @@ define([
view
=
new
VerifiedCourseSeatFormFieldView
({
model
:
model
}).
render
();
view
=
new
VerifiedCourseSeatFormFieldView
({
model
:
model
}).
render
();
});
});
describe
(
'getData'
,
function
()
{
describe
(
'verified course seat form field view'
,
function
()
{
it
(
'should return the data from the DOM/model'
,
function
()
{
describe
(
'getData'
,
function
()
{
var
data
=
{
it
(
'should return the data from the DOM/model'
,
function
()
{
certificate_type
:
'verified'
,
var
data
=
{
id_verification_required
:
'true'
,
certificate_type
:
'verified'
,
price
:
'100'
,
id_verification_required
:
'true'
,
expires
:
''
price
:
'100'
,
};
expires
:
''
};
expect
(
view
.
getData
()).
toEqual
(
data
);
expect
(
view
.
getData
()).
toEqual
(
data
);
});
});
});
});
});
}
}
...
...
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