Commit 94614db4 by David Ormsbee Committed by Calen Pennington

CoffeeScript tests migration: Remove implicit returns

parent 0880502f
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
define(["js/models/course"], Course => define(["js/models/course"], Course =>
describe("Course", () => describe("Course", () =>
describe("basic", function() { describe("basic", function() {
beforeEach(function() { beforeEach(function() {
return this.model = new Course({ this.model = new Course({
name: "Greek Hero" name: "Greek Hero"
}); });
}); });
return it("should take a name argument", function() { it("should take a name argument", function() {
return expect(this.model.get("name")).toEqual("Greek Hero"); expect(this.model.get("name")).toEqual("Greek Hero");
}); });
}) })
) )
......
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
define(["js/models/metadata"], Metadata => define(["js/models/metadata"], Metadata =>
describe("Metadata", function() { describe("Metadata", function() {
it("knows when the value has not been modified", function() { it("knows when the value has not been modified", function() {
...@@ -13,7 +8,7 @@ define(["js/models/metadata"], Metadata => ...@@ -13,7 +8,7 @@ define(["js/models/metadata"], Metadata =>
model = new Metadata( model = new Metadata(
{'value': 'original', 'explicitly_set': true}); {'value': 'original', 'explicitly_set': true});
model.setValue('original'); model.setValue('original');
return expect(model.isModified()).toBeFalsy(); expect(model.isModified()).toBeFalsy();
}); });
it("knows when the value has been modified", function() { it("knows when the value has been modified", function() {
...@@ -25,7 +20,7 @@ define(["js/models/metadata"], Metadata => ...@@ -25,7 +20,7 @@ define(["js/models/metadata"], Metadata =>
model = new Metadata( model = new Metadata(
{'value': 'original', 'explicitly_set': true}); {'value': 'original', 'explicitly_set': true});
model.setValue('modified'); model.setValue('modified');
return expect(model.isModified()).toBeTruthy(); expect(model.isModified()).toBeTruthy();
}); });
it("tracks when values have been explicitly set", function() { it("tracks when values have been explicitly set", function() {
...@@ -33,7 +28,7 @@ define(["js/models/metadata"], Metadata => ...@@ -33,7 +28,7 @@ define(["js/models/metadata"], Metadata =>
{'value': 'original', 'explicitly_set': false}); {'value': 'original', 'explicitly_set': false});
expect(model.isExplicitlySet()).toBeFalsy(); expect(model.isExplicitlySet()).toBeFalsy();
model.setValue('original'); model.setValue('original');
return expect(model.isExplicitlySet()).toBeTruthy(); expect(model.isExplicitlySet()).toBeTruthy();
}); });
it("has both 'display value' and a 'value' methods", function() { it("has both 'display value' and a 'value' methods", function() {
...@@ -43,7 +38,7 @@ define(["js/models/metadata"], Metadata => ...@@ -43,7 +38,7 @@ define(["js/models/metadata"], Metadata =>
expect(model.getDisplayValue()).toBe('default'); expect(model.getDisplayValue()).toBe('default');
model.setValue('modified'); model.setValue('modified');
expect(model.getValue()).toBe('modified'); expect(model.getValue()).toBe('modified');
return expect(model.getDisplayValue()).toBe('modified'); expect(model.getDisplayValue()).toBe('modified');
}); });
it("has a clear method for reverting to the default", function() { it("has a clear method for reverting to the default", function() {
...@@ -52,22 +47,22 @@ define(["js/models/metadata"], Metadata => ...@@ -52,22 +47,22 @@ define(["js/models/metadata"], Metadata =>
model.clear(); model.clear();
expect(model.getValue()).toBeNull; expect(model.getValue()).toBeNull;
expect(model.getDisplayValue()).toBe('default'); expect(model.getDisplayValue()).toBe('default');
return expect(model.isExplicitlySet()).toBeFalsy(); expect(model.isExplicitlySet()).toBeFalsy();
}); });
it("has a getter for field name", function() { it("has a getter for field name", function() {
const model = new Metadata({'field_name': 'foo'}); const model = new Metadata({'field_name': 'foo'});
return expect(model.getFieldName()).toBe('foo'); expect(model.getFieldName()).toBe('foo');
}); });
it("has a getter for options", function() { it("has a getter for options", function() {
const model = new Metadata({'options': ['foo', 'bar']}); const model = new Metadata({'options': ['foo', 'bar']});
return expect(model.getOptions()).toEqual(['foo', 'bar']); expect(model.getOptions()).toEqual(['foo', 'bar']);
}); });
return it("has a getter for type", function() { it("has a getter for type", function() {
const model = new Metadata({'type': 'Integer'}); const model = new Metadata({'type': 'Integer'});
return expect(model.getType()).toBe(Metadata.INTEGER_TYPE); expect(model.getType()).toBe(Metadata.INTEGER_TYPE);
}); });
}) })
); );
......
...@@ -7,26 +7,26 @@ define(["js/models/section", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers" ...@@ -7,26 +7,26 @@ define(["js/models/section", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers"
describe("Section", function() { describe("Section", function() {
describe("basic", function() { describe("basic", function() {
beforeEach(function() { beforeEach(function() {
return this.model = new Section({ this.model = new Section({
id: 42, id: 42,
name: "Life, the Universe, and Everything" name: "Life, the Universe, and Everything"
}); });
}); });
it("should take an id argument", function() { it("should take an id argument", function() {
return expect(this.model.get("id")).toEqual(42); expect(this.model.get("id")).toEqual(42);
}); });
it("should take a name argument", function() { it("should take a name argument", function() {
return expect(this.model.get("name")).toEqual("Life, the Universe, and Everything"); expect(this.model.get("name")).toEqual("Life, the Universe, and Everything");
}); });
it("should have a URL set", function() { it("should have a URL set", function() {
return expect(this.model.url()).toEqual(ModuleUtils.getUpdateUrl(42)); expect(this.model.url()).toEqual(ModuleUtils.getUpdateUrl(42));
}); });
return it("should serialize to JSON correctly", function() { it("should serialize to JSON correctly", function() {
return expect(this.model.toJSON()).toEqual({ expect(this.model.toJSON()).toEqual({
metadata: metadata:
{ {
display_name: "Life, the Universe, and Everything" display_name: "Life, the Universe, and Everything"
...@@ -35,11 +35,11 @@ define(["js/models/section", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers" ...@@ -35,11 +35,11 @@ define(["js/models/section", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers"
}); });
}); });
return describe("XHR", function() { describe("XHR", function() {
beforeEach(function() { beforeEach(function() {
spyOn(Section.prototype, 'showNotification'); spyOn(Section.prototype, 'showNotification');
spyOn(Section.prototype, 'hideNotification'); spyOn(Section.prototype, 'hideNotification');
return this.model = new Section({ this.model = new Section({
id: 42, id: 42,
name: "Life, the Universe, and Everything" name: "Life, the Universe, and Everything"
}); });
...@@ -51,16 +51,16 @@ define(["js/models/section", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers" ...@@ -51,16 +51,16 @@ define(["js/models/section", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers"
this.model.save(); this.model.save();
expect(Section.prototype.showNotification).toHaveBeenCalled(); expect(Section.prototype.showNotification).toHaveBeenCalled();
server.respond(); server.respond();
return expect(Section.prototype.hideNotification).toHaveBeenCalled(); expect(Section.prototype.hideNotification).toHaveBeenCalled();
}); });
return it("don't hide notification when saving fails", function() { it("don't hide notification when saving fails", function() {
// this is handled by the global AJAX error handler // this is handled by the global AJAX error handler
const server = AjaxHelpers.server([500, {"Content-Type": "application/json"}, "{}"]); const server = AjaxHelpers.server([500, {"Content-Type": "application/json"}, "{}"]);
this.model.save(); this.model.save();
server.respond(); server.respond();
return expect(Section.prototype.hideNotification).not.toHaveBeenCalled(); expect(Section.prototype.hideNotification).not.toHaveBeenCalled();
}); });
}); });
}) })
......
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
define(["js/models/settings/course_grader"], CourseGrader => define(["js/models/settings/course_grader"], CourseGrader =>
describe("CourseGraderModel", () => describe("CourseGraderModel", () =>
describe("parseWeight", function() { describe("parseWeight", function() {
...@@ -10,29 +5,29 @@ define(["js/models/settings/course_grader"], CourseGrader => ...@@ -10,29 +5,29 @@ define(["js/models/settings/course_grader"], CourseGrader =>
const model = new CourseGrader({weight: 7.0001, min_count: 3.67, drop_count: 1.88}, {parse:true}); const model = new CourseGrader({weight: 7.0001, min_count: 3.67, drop_count: 1.88}, {parse:true});
expect(model.get('weight')).toBe(7); expect(model.get('weight')).toBe(7);
expect(model.get('min_count')).toBe(4); expect(model.get('min_count')).toBe(4);
return expect(model.get('drop_count')).toBe(2); expect(model.get('drop_count')).toBe(2);
}); });
it("converts float value of weight to an integer with rounding", function() { it("converts float value of weight to an integer with rounding", function() {
const model = new CourseGrader({weight: 28.999999999999996}, {parse:true}); const model = new CourseGrader({weight: 28.999999999999996}, {parse:true});
return expect(model.get('weight')).toBe(29); expect(model.get('weight')).toBe(29);
}); });
it("converts a string to an integer", function() { it("converts a string to an integer", function() {
const model = new CourseGrader({weight: '7.0001', min_count: '3.67', drop_count: '1.88'}, {parse:true}); const model = new CourseGrader({weight: '7.0001', min_count: '3.67', drop_count: '1.88'}, {parse:true});
expect(model.get('weight')).toBe(7); expect(model.get('weight')).toBe(7);
expect(model.get('min_count')).toBe(4); expect(model.get('min_count')).toBe(4);
return expect(model.get('drop_count')).toBe(2); expect(model.get('drop_count')).toBe(2);
}); });
it("does a no-op for integers", function() { it("does a no-op for integers", function() {
const model = new CourseGrader({weight: 7, min_count: 3, drop_count: 1}, {parse:true}); const model = new CourseGrader({weight: 7, min_count: 3, drop_count: 1}, {parse:true});
expect(model.get('weight')).toBe(7); expect(model.get('weight')).toBe(7);
expect(model.get('min_count')).toBe(3); expect(model.get('min_count')).toBe(3);
return expect(model.get('drop_count')).toBe(1); expect(model.get('drop_count')).toBe(1);
}); });
return it("gives validation error if min_count is less than 1 or drop_count is NaN", function() { it("gives validation error if min_count is less than 1 or drop_count is NaN", function() {
const model = new CourseGrader(); const model = new CourseGrader();
let errors = model.validate({min_count: 0, drop_count: ''}, {validate:true}); let errors = model.validate({min_count: 0, drop_count: ''}, {validate:true});
expect(errors.min_count).toBe('Please enter an integer greater than 0.'); expect(errors.min_count).toBe('Please enter an integer greater than 0.');
...@@ -44,7 +39,7 @@ define(["js/models/settings/course_grader"], CourseGrader => ...@@ -44,7 +39,7 @@ define(["js/models/settings/course_grader"], CourseGrader =>
// don't allow floats // don't allow floats
errors = model.validate({min_count: 12.2, drop_count: 1.5}, {validate:true}); errors = model.validate({min_count: 12.2, drop_count: 1.5}, {validate:true});
expect(errors.min_count).toBe('Please enter an integer greater than 0.'); expect(errors.min_count).toBe('Please enter an integer greater than 0.');
return expect(errors.drop_count).toBe('Please enter non-negative integer.'); expect(errors.drop_count).toBe('Please enter non-negative integer.');
}); });
}) })
) )
......
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
define(["underscore", "js/models/settings/course_grading_policy"], (_, CourseGradingPolicy) => define(["underscore", "js/models/settings/course_grading_policy"], (_, CourseGradingPolicy) =>
describe("CourseGradingPolicy", function() { describe("CourseGradingPolicy", function() {
beforeEach(function() { beforeEach(function() {
...@@ -12,7 +7,7 @@ define(["underscore", "js/models/settings/course_grading_policy"], (_, CourseGra ...@@ -12,7 +7,7 @@ define(["underscore", "js/models/settings/course_grading_policy"], (_, CourseGra
describe("parse", () => describe("parse", () =>
it("sets a null grace period to 00:00", function() { it("sets a null grace period to 00:00", function() {
const attrs = this.model.parse({grace_period: null}); const attrs = this.model.parse({grace_period: null});
return expect(attrs.grace_period).toEqual({ expect(attrs.grace_period).toEqual({
hours: 0, hours: 0,
minutes: 0 minutes: 0
}); });
...@@ -22,30 +17,30 @@ define(["underscore", "js/models/settings/course_grading_policy"], (_, CourseGra ...@@ -22,30 +17,30 @@ define(["underscore", "js/models/settings/course_grading_policy"], (_, CourseGra
describe("parseGracePeriod", function() { describe("parseGracePeriod", function() {
it("parses a time in HH:MM format", function() { it("parses a time in HH:MM format", function() {
const time = this.model.parseGracePeriod("07:19"); const time = this.model.parseGracePeriod("07:19");
return expect(time).toEqual({ expect(time).toEqual({
hours: 7, hours: 7,
minutes: 19 minutes: 19
}); });
}); });
return it("returns null on an incorrectly formatted string", function() { it("returns null on an incorrectly formatted string", function() {
expect(this.model.parseGracePeriod("asdf")).toBe(null); expect(this.model.parseGracePeriod("asdf")).toBe(null);
expect(this.model.parseGracePeriod("7:19")).toBe(null); expect(this.model.parseGracePeriod("7:19")).toBe(null);
return expect(this.model.parseGracePeriod("1000:00")).toBe(null); expect(this.model.parseGracePeriod("1000:00")).toBe(null);
}); });
}); });
return describe("validate", function() { describe("validate", function() {
it("enforces that the passing grade is <= the minimum grade to receive credit if credit is enabled", function() { it("enforces that the passing grade is <= the minimum grade to receive credit if credit is enabled", function() {
this.model.set({minimum_grade_credit: 0.8, grace_period: '01:00', is_credit_course: true}); this.model.set({minimum_grade_credit: 0.8, grace_period: '01:00', is_credit_course: true});
this.model.set('grade_cutoffs', [0.9], {validate: true}); this.model.set('grade_cutoffs', [0.9], {validate: true});
return expect(_.keys(this.model.validationError)).toContain('minimum_grade_credit'); expect(_.keys(this.model.validationError)).toContain('minimum_grade_credit');
}); });
return it("does not enforce the passing grade limit in non-credit courses", function() { it("does not enforce the passing grade limit in non-credit courses", function() {
this.model.set({minimum_grade_credit: 0.8, grace_period: '01:00', is_credit_course: false}); this.model.set({minimum_grade_credit: 0.8, grace_period: '01:00', is_credit_course: false});
this.model.set({grade_cutoffs: [0.9]}, {validate: true}); this.model.set({grade_cutoffs: [0.9]}, {validate: true});
return expect(this.model.validationError).toBe(null); expect(this.model.validationError).toBe(null);
}); });
}); });
}) })
......
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
define(["js/models/uploads"], FileUpload => define(["js/models/uploads"], FileUpload =>
describe("FileUpload", function() { describe("FileUpload", function() {
beforeEach(function() { beforeEach(function() {
return this.model = new FileUpload(); this.model = new FileUpload();
}); });
it("is unfinished by default", function() { it("is unfinished by default", function() {
return expect(this.model.get("finished")).toBeFalsy(); expect(this.model.get("finished")).toBeFalsy();
}); });
it("is not uploading by default", function() { it("is not uploading by default", function() {
return expect(this.model.get("uploading")).toBeFalsy(); expect(this.model.get("uploading")).toBeFalsy();
}); });
it("is valid by default", function() { it("is valid by default", function() {
return expect(this.model.isValid()).toBeTruthy(); expect(this.model.isValid()).toBeTruthy();
}); });
it("is valid for text files by default", function() { it("is valid for text files by default", function() {
const file = {"type": "text/plain", "name": "filename.txt"}; const file = {"type": "text/plain", "name": "filename.txt"};
this.model.set("selectedFile", file); this.model.set("selectedFile", file);
return expect(this.model.isValid()).toBeTruthy(); expect(this.model.isValid()).toBeTruthy();
}); });
it("is valid for PNG files by default", function() { it("is valid for PNG files by default", function() {
const file = {"type": "image/png", "name": "filename.png"}; const file = {"type": "image/png", "name": "filename.png"};
this.model.set("selectedFile", file); this.model.set("selectedFile", file);
return expect(this.model.isValid()).toBeTruthy(); expect(this.model.isValid()).toBeTruthy();
}); });
it("can accept a file type when explicitly set", function() { it("can accept a file type when explicitly set", function() {
const file = {"type": "image/png", "name": "filename.png"}; const file = {"type": "image/png", "name": "filename.png"};
this.model.set({"mimeTypes": ["image/png"]}); this.model.set({"mimeTypes": ["image/png"]});
this.model.set("selectedFile", file); this.model.set("selectedFile", file);
return expect(this.model.isValid()).toBeTruthy(); expect(this.model.isValid()).toBeTruthy();
}); });
it("can accept a file format when explicitly set", function() { it("can accept a file format when explicitly set", function() {
const file = {"type": "", "name": "filename.png"}; const file = {"type": "", "name": "filename.png"};
this.model.set({"fileFormats": ["png"]}); this.model.set({"fileFormats": ["png"]});
this.model.set("selectedFile", file); this.model.set("selectedFile", file);
return expect(this.model.isValid()).toBeTruthy(); expect(this.model.isValid()).toBeTruthy();
}); });
it("can accept multiple file types", function() { it("can accept multiple file types", function() {
const file = {"type": "image/gif", "name": "filename.gif"}; const file = {"type": "image/gif", "name": "filename.gif"};
this.model.set({"mimeTypes": ["image/png", "image/jpeg", "image/gif"]}); this.model.set({"mimeTypes": ["image/png", "image/jpeg", "image/gif"]});
this.model.set("selectedFile", file); this.model.set("selectedFile", file);
return expect(this.model.isValid()).toBeTruthy(); expect(this.model.isValid()).toBeTruthy();
}); });
it("can accept multiple file formats", function() { it("can accept multiple file formats", function() {
const file = {"type": "image/gif", "name": "filename.gif"}; const file = {"type": "image/gif", "name": "filename.gif"};
this.model.set({"fileFormats": ["png", "jpeg", "gif"]}); this.model.set({"fileFormats": ["png", "jpeg", "gif"]});
this.model.set("selectedFile", file); this.model.set("selectedFile", file);
return expect(this.model.isValid()).toBeTruthy(); expect(this.model.isValid()).toBeTruthy();
}); });
describe("fileTypes", () => describe("fileTypes", () =>
it("returns a list of the uploader's file types", function() { it("returns a list of the uploader's file types", function() {
this.model.set('mimeTypes', ['image/png', 'application/json']); this.model.set('mimeTypes', ['image/png', 'application/json']);
this.model.set('fileFormats', ['gif', 'srt']); this.model.set('fileFormats', ['gif', 'srt']);
return expect(this.model.fileTypes()).toEqual(['PNG', 'JSON', 'GIF', 'SRT']); expect(this.model.fileTypes()).toEqual(['PNG', 'JSON', 'GIF', 'SRT']);
}) })
); );
return describe("formatValidTypes", function() { describe("formatValidTypes", function() {
it("returns a map of formatted file types and extensions", function() { it("returns a map of formatted file types and extensions", function() {
this.model.set('mimeTypes', ['image/png', 'image/jpeg', 'application/json']); this.model.set('mimeTypes', ['image/png', 'image/jpeg', 'application/json']);
const formatted = this.model.formatValidTypes(); const formatted = this.model.formatValidTypes();
return expect(formatted).toEqual({ expect(formatted).toEqual({
fileTypes: 'PNG, JPEG or JSON', fileTypes: 'PNG, JPEG or JSON',
fileExtensions: '.png, .jpeg or .json' fileExtensions: '.png, .jpeg or .json'
}); });
}); });
return it("does not format with only one mime type", function() { it("does not format with only one mime type", function() {
this.model.set('mimeTypes', ['application/pdf']); this.model.set('mimeTypes', ['application/pdf']);
const formatted = this.model.formatValidTypes(); const formatted = this.model.formatValidTypes();
return expect(formatted).toEqual({ expect(formatted).toEqual({
fileTypes: 'PDF', fileTypes: 'PDF',
fileExtensions: '.pdf' fileExtensions: '.pdf'
}); });
......
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter", define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter",
"edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "js/spec_helpers/modal_helpers"], "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "js/spec_helpers/modal_helpers"],
(sinon, FileUpload, UploadDialog, Chapter, AjaxHelpers, modal_helpers) => (sinon, FileUpload, UploadDialog, Chapter, AjaxHelpers, modal_helpers) =>
...@@ -19,11 +14,11 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter", ...@@ -19,11 +14,11 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter",
mimeTypes: ['application/pdf'] mimeTypes: ['application/pdf']
}); });
this.dialogResponse = (dialogResponse = []); this.dialogResponse = (dialogResponse = []);
return this.mockFiles = [];}); this.mockFiles = [];});
afterEach(function() { afterEach(function() {
delete CMS.URL.UPLOAD_ASSET; delete CMS.URL.UPLOAD_ASSET;
return modal_helpers.cancelModalIfShowing(); modal_helpers.cancelModalIfShowing();
}); });
const createTestView = function(test) { const createTestView = function(test) {
...@@ -49,7 +44,8 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter", ...@@ -49,7 +44,8 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter",
return originalView$.apply(this, arguments); return originalView$.apply(this, arguments);
} }
}); });
return this.lastView = view; this.lastView = view;
return view;
}; };
describe("Basic", function() { describe("Basic", function() {
...@@ -57,7 +53,7 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter", ...@@ -57,7 +53,7 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter",
const view = createTestView(this); const view = createTestView(this);
view.render(); view.render();
expect(view.$el).toContainElement("input[type=file]"); expect(view.$el).toContainElement("input[type=file]");
return expect(view.$(".action-upload")).toHaveClass("disabled"); expect(view.$(".action-upload")).toHaveClass("disabled");
}); });
it("should render with a PDF selected", function() { it("should render with a PDF selected", function() {
...@@ -68,7 +64,7 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter", ...@@ -68,7 +64,7 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter",
view.render(); view.render();
expect(view.$el).toContainElement("input[type=file]"); expect(view.$el).toContainElement("input[type=file]");
expect(view.$el).not.toContainElement("#upload_error"); expect(view.$el).not.toContainElement("#upload_error");
return expect(view.$(".action-upload")).not.toHaveClass("disabled"); expect(view.$(".action-upload")).not.toHaveClass("disabled");
}); });
it("should render an error with an invalid file type selected", function() { it("should render an error with an invalid file type selected", function() {
...@@ -79,10 +75,10 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter", ...@@ -79,10 +75,10 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter",
view.render(); view.render();
expect(view.$el).toContainElement("input[type=file]"); expect(view.$el).toContainElement("input[type=file]");
expect(view.$el).toContainElement("#upload_error"); expect(view.$el).toContainElement("#upload_error");
return expect(view.$(".action-upload")).toHaveClass("disabled"); expect(view.$(".action-upload")).toHaveClass("disabled");
}); });
return it("should render an error with an invalid file type after a correct file type selected", function() { it("should render an error with an invalid file type after a correct file type selected", function() {
const view = createTestView(this); const view = createTestView(this);
const correctFile = {name: "fake.pdf", "type": "application/pdf"}; const correctFile = {name: "fake.pdf", "type": "application/pdf"};
const inCorrectFile = {name: "fake.png", "type": "image/png"}; const inCorrectFile = {name: "fake.png", "type": "image/png"};
...@@ -109,18 +105,18 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter", ...@@ -109,18 +105,18 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter",
view.selectFile(event); view.selectFile(event);
expect(view.$el).toContainElement("input[type=file]"); expect(view.$el).toContainElement("input[type=file]");
expect(view.$el).toContainElement("#upload_error"); expect(view.$el).toContainElement("#upload_error");
return expect(view.$(".action-upload")).toHaveClass("disabled"); expect(view.$(".action-upload")).toHaveClass("disabled");
}); });
}); });
return describe("Uploads", function() { describe("Uploads", function() {
beforeEach(function() { beforeEach(function() {
return this.clock = sinon.useFakeTimers(); this.clock = sinon.useFakeTimers();
}); });
afterEach(function() { afterEach(function() {
modal_helpers.cancelModalIfShowing(); modal_helpers.cancelModalIfShowing();
return this.clock.restore(); this.clock.restore();
}); });
it("can upload correctly", function() { it("can upload correctly", function() {
...@@ -133,7 +129,7 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter", ...@@ -133,7 +129,7 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter",
AjaxHelpers.respondWithJson(requests, { response: "dummy_response"}); AjaxHelpers.respondWithJson(requests, { response: "dummy_response"});
expect(this.model.get("uploading")).toBeFalsy(); expect(this.model.get("uploading")).toBeFalsy();
expect(this.model.get("finished")).toBeTruthy(); expect(this.model.get("finished")).toBeTruthy();
return expect(this.dialogResponse.pop()).toEqual("dummy_response"); expect(this.dialogResponse.pop()).toEqual("dummy_response");
}); });
it("can handle upload errors", function() { it("can handle upload errors", function() {
...@@ -143,10 +139,10 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter", ...@@ -143,10 +139,10 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter",
view.upload(); view.upload();
AjaxHelpers.respondWithError(requests); AjaxHelpers.respondWithError(requests);
expect(this.model.get("title")).toMatch(/error/); expect(this.model.get("title")).toMatch(/error/);
return expect(view.remove).not.toHaveBeenCalled(); expect(view.remove).not.toHaveBeenCalled();
}); });
return it("removes itself after two seconds on successful upload", function() { it("removes itself after two seconds on successful upload", function() {
const requests = AjaxHelpers.requests(this); const requests = AjaxHelpers.requests(this);
const view = createTestView(this); const view = createTestView(this);
view.render(); view.render();
...@@ -154,7 +150,7 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter", ...@@ -154,7 +150,7 @@ define(["sinon", "js/models/uploads", "js/views/uploads", "js/models/chapter",
AjaxHelpers.respondWithJson(requests, { response: "dummy_response"}); AjaxHelpers.respondWithJson(requests, { response: "dummy_response"});
expect(modal_helpers.isShowingModal(view)).toBeTruthy(); expect(modal_helpers.isShowingModal(view)).toBeTruthy();
this.clock.tick(2001); this.clock.tick(2001);
return expect(modal_helpers.isShowingModal(view)).toBeFalsy(); expect(modal_helpers.isShowingModal(view)).toBeFalsy();
}); });
}); });
}) })
......
/* /*
* decaffeinate suggestions: * decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks * DS207: Consider shorter variations of null checks
* DS208: Avoid top-level this * DS208: Avoid top-level this
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
...@@ -18,7 +17,7 @@ class XProblemGenerator { ...@@ -18,7 +17,7 @@ class XProblemGenerator {
generate() { generate() {
return console.error("Abstract method called: XProblemGenerator.generate"); console.error("Abstract method called: XProblemGenerator.generate");
} }
} }
...@@ -36,16 +35,16 @@ class XProblemDisplay { ...@@ -36,16 +35,16 @@ class XProblemDisplay {
render() { render() {
return console.error("Abstract method called: XProblemDisplay.render"); console.error("Abstract method called: XProblemDisplay.render");
} }
updateSubmission() { updateSubmission() {
return this.submissionField.val(JSON.stringify(this.getCurrentSubmission())); this.submissionField.val(JSON.stringify(this.getCurrentSubmission()));
} }
getCurrentSubmission() { getCurrentSubmission() {
return console.error("Abstract method called: XProblemDisplay.getCurrentSubmission"); console.error("Abstract method called: XProblemDisplay.getCurrentSubmission");
} }
} }
...@@ -63,12 +62,12 @@ class XProblemGrader { ...@@ -63,12 +62,12 @@ class XProblemGrader {
solve() { solve() {
return console.error("Abstract method called: XProblemGrader.solve"); console.error("Abstract method called: XProblemGrader.solve");
} }
grade() { grade() {
return console.error("Abstract method called: XProblemGrader.grade"); console.error("Abstract method called: XProblemGrader.grade");
} }
} }
......
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
describe('Annotatable', function() { describe('Annotatable', function() {
beforeEach(() => loadFixtures('annotatable.html')); beforeEach(() => loadFixtures('annotatable.html'));
return describe('constructor', function() { describe('constructor', function() {
const el = $('.xblock-student_view.xmodule_AnnotatableModule'); const el = $('.xblock-student_view.xmodule_AnnotatableModule');
beforeEach(function() { beforeEach(function() {
return this.annotatable = new Annotatable(el); this.annotatable = new Annotatable(el);
}); });
return it('works', () => expect(1).toBe(1)); it('works', () => expect(1).toBe(1));
}); });
}); });
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
describe('HTMLEditingDescriptor', function() { describe('HTMLEditingDescriptor', function() {
beforeEach(() => window.baseUrl = "/static/deadbeef"); beforeEach(() => window.baseUrl = "/static/deadbeef");
afterEach(() => delete window.baseUrl); afterEach(() => delete window.baseUrl);
describe('Visual HTML Editor', function() { describe('Visual HTML Editor', function() {
beforeEach(function() { beforeEach(function() {
loadFixtures('html-edit-visual.html'); loadFixtures('html-edit-visual.html');
return this.descriptor = new HTMLEditingDescriptor($('.test-component')); this.descriptor = new HTMLEditingDescriptor($('.test-component'));
}); });
it('Returns data from Visual Editor if text has changed', function() { it('Returns data from Visual Editor if text has changed', function() {
const visualEditorStub = const visualEditorStub =
{getContent() { return 'from visual editor'; }}; {getContent() { return 'from visual editor'; }};
spyOn(this.descriptor, 'getVisualEditor').and.callFake(() => visualEditorStub); spyOn(this.descriptor, 'getVisualEditor').and.callFake(() => visualEditorStub);
const { data } = this.descriptor.save(); const { data } = this.descriptor.save();
return expect(data).toEqual('from visual editor'); expect(data).toEqual('from visual editor');
}); });
it('Returns data from Raw Editor if text has not changed', function() { it('Returns data from Raw Editor if text has not changed', function() {
const visualEditorStub = const visualEditorStub =
{getContent() { return '<p>original visual text</p>'; }}; {getContent() { return '<p>original visual text</p>'; }};
spyOn(this.descriptor, 'getVisualEditor').and.callFake(() => visualEditorStub); spyOn(this.descriptor, 'getVisualEditor').and.callFake(() => visualEditorStub);
const { data } = this.descriptor.save(); const { data } = this.descriptor.save();
return expect(data).toEqual('raw text'); expect(data).toEqual('raw text');
}); });
it('Performs link rewriting for static assets when saving', function() { it('Performs link rewriting for static assets when saving', function() {
const visualEditorStub = const visualEditorStub =
{getContent() { return 'from visual editor with /c4x/foo/bar/asset/image.jpg'; }}; {getContent() { return 'from visual editor with /c4x/foo/bar/asset/image.jpg'; }};
spyOn(this.descriptor, 'getVisualEditor').and.callFake(() => visualEditorStub); spyOn(this.descriptor, 'getVisualEditor').and.callFake(() => visualEditorStub);
const { data } = this.descriptor.save(); const { data } = this.descriptor.save();
return expect(data).toEqual('from visual editor with /static/image.jpg'); expect(data).toEqual('from visual editor with /static/image.jpg');
}); });
it('When showing visual editor links are rewritten to c4x format', function() { it('When showing visual editor links are rewritten to c4x format', function() {
const visualEditorStub = { const visualEditorStub = {
content: 'text /static/image.jpg', content: 'text /static/image.jpg',
startContent: 'text /static/image.jpg', startContent: 'text /static/image.jpg',
focus() {}, focus() {},
setContent(x) { return this.content = x; }, setContent(x) { this.content = x; },
getContent() { return this.content; } getContent() { return this.content; }
}; };
this.descriptor.initInstanceCallback(visualEditorStub); this.descriptor.initInstanceCallback(visualEditorStub);
return expect(visualEditorStub.getContent()).toEqual('text /c4x/foo/bar/asset/image.jpg'); expect(visualEditorStub.getContent()).toEqual('text /c4x/foo/bar/asset/image.jpg');
}); });
return it('Enables spellcheck', () => expect($('.html-editor iframe')[0].contentDocument.body.spellcheck).toBe(true)); it('Enables spellcheck', () => expect($('.html-editor iframe')[0].contentDocument.body.spellcheck).toBe(true));
}); });
return describe('Raw HTML Editor', function() { describe('Raw HTML Editor', function() {
beforeEach(function() { beforeEach(function() {
loadFixtures('html-editor-raw.html'); loadFixtures('html-editor-raw.html');
return this.descriptor = new HTMLEditingDescriptor($('.test-component')); this.descriptor = new HTMLEditingDescriptor($('.test-component'));
}); });
return it('Returns data from raw editor', function() { it('Returns data from raw editor', function() {
const { data } = this.descriptor.save(); const { data } = this.descriptor.save();
return expect(data).toEqual('raw text'); expect(data).toEqual('raw text');
}); });
}); });
}); });
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
// This file tests the parsing of extended-hints, double bracket sections {{ .. }} // This file tests the parsing of extended-hints, double bracket sections {{ .. }}
// for all sorts of markdown. // for all sorts of markdown.
describe('Markdown to xml extended hint dropdown', function() { describe('Markdown to xml extended hint dropdown', function() {
...@@ -30,7 +25,7 @@ Clowns have funny _________ to make people laugh. ...@@ -30,7 +25,7 @@ Clowns have funny _________ to make people laugh.
]] ]]
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<p>Translation between Dropdown and ________ is straightforward.</p> <p>Translation between Dropdown and ________ is straightforward.</p>
<optionresponse> <optionresponse>
...@@ -82,7 +77,7 @@ Translation between Dropdown and ________ is straightforward. ...@@ -82,7 +77,7 @@ Translation between Dropdown and ________ is straightforward.
|| 1) one || || 1) one ||
|| 2) two ||\ || 2) two ||\
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<optionresponse> <optionresponse>
<p>Translation between Dropdown and ________ is straightforward.</p> <p>Translation between Dropdown and ________ is straightforward.</p>
...@@ -113,7 +108,7 @@ A Question ________ is answered. ...@@ -113,7 +108,7 @@ A Question ________ is answered.
|| 0) zero || || 0) zero ||
|| 1) one ||\ || 1) one ||\
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<optionresponse> <optionresponse>
<p>A Question ________ is answered.</p> <p>A Question ________ is answered.</p>
...@@ -135,7 +130,7 @@ A Question ________ is answered. ...@@ -135,7 +130,7 @@ A Question ________ is answered.
bb bb
cc {{ hint2 }} ]]\ cc {{ hint2 }} ]]\
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<optionresponse> <optionresponse>
<label>q1</label> <label>q1</label>
...@@ -153,7 +148,7 @@ A Question ________ is answered. ...@@ -153,7 +148,7 @@ A Question ________ is answered.
`); `);
}); });
return it('produces xml even with lots of whitespace', function() { it('produces xml even with lots of whitespace', function() {
const data = MarkdownEditingDescriptor.markdownToXml(`\ const data = MarkdownEditingDescriptor.markdownToXml(`\
>>q1<< >>q1<<
[[ [[
...@@ -166,7 +161,7 @@ A Question ________ is answered. ...@@ -166,7 +161,7 @@ A Question ________ is answered.
]]\ ]]\
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<optionresponse> <optionresponse>
<label>q1</label> <label>q1</label>
...@@ -212,7 +207,7 @@ describe('Markdown to xml extended hint checkbox', function() { ...@@ -212,7 +207,7 @@ describe('Markdown to xml extended hint checkbox', function() {
{{ ((A*B)) Making a banana split? }} {{ ((A*B)) Making a banana split? }}
{{ ((B*D)) That will make a horrible dessert: a brussel sprout split? }}\ {{ ((B*D)) That will make a horrible dessert: a brussel sprout split? }}\
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<label>Select all the fruits from the list</label> <label>Select all the fruits from the list</label>
<choiceresponse> <choiceresponse>
...@@ -263,7 +258,7 @@ describe('Markdown to xml extended hint checkbox', function() { ...@@ -263,7 +258,7 @@ describe('Markdown to xml extended hint checkbox', function() {
`); `);
}); });
return it('produces xml also with demand hints', function() { it('produces xml also with demand hints', function() {
const data = MarkdownEditingDescriptor.markdownToXml(`\ const data = MarkdownEditingDescriptor.markdownToXml(`\
>>Select all the fruits from the list<< >>Select all the fruits from the list<<
...@@ -290,7 +285,7 @@ describe('Markdown to xml extended hint checkbox', function() { ...@@ -290,7 +285,7 @@ describe('Markdown to xml extended hint checkbox', function() {
|| Hint two. || || Hint two. ||
|| Hint three. ||\ || Hint three. ||\
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<label>Select all the fruits from the list</label> <label>Select all the fruits from the list</label>
<choiceresponse> <choiceresponse>
...@@ -364,7 +359,7 @@ describe('Markdown to xml extended hint multiple choice', function() { ...@@ -364,7 +359,7 @@ describe('Markdown to xml extended hint multiple choice', function() {
(x) Potato {{ Potato is a root vegetable. }} (x) Potato {{ Potato is a root vegetable. }}
() Apple {{ OOPS::Apple is a fruit.}}\ () Apple {{ OOPS::Apple is a fruit.}}\
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<label>Select the fruit from the list</label> <label>Select the fruit from the list</label>
<multiplechoiceresponse> <multiplechoiceresponse>
...@@ -397,7 +392,7 @@ describe('Markdown to xml extended hint multiple choice', function() { ...@@ -397,7 +392,7 @@ describe('Markdown to xml extended hint multiple choice', function() {
`); `);
}); });
return it('produces xml with demand hints', function() { it('produces xml with demand hints', function() {
const data = MarkdownEditingDescriptor.markdownToXml(`\ const data = MarkdownEditingDescriptor.markdownToXml(`\
>>Select the fruit from the list<< >>Select the fruit from the list<<
...@@ -417,7 +412,7 @@ describe('Markdown to xml extended hint multiple choice', function() { ...@@ -417,7 +412,7 @@ describe('Markdown to xml extended hint multiple choice', function() {
|| 2) where are the lions? || || 2) where are the lions? ||
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<label>Select the fruit from the list</label> <label>Select the fruit from the list</label>
<multiplechoiceresponse> <multiplechoiceresponse>
...@@ -464,7 +459,7 @@ describe('Markdown to xml extended hint text input', function() { ...@@ -464,7 +459,7 @@ describe('Markdown to xml extended hint text input', function() {
= France {{ BRAVO::Viva la France! }} = France {{ BRAVO::Viva la France! }}
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<stringresponse answer="France" type="ci"> <stringresponse answer="France" type="ci">
<label>In which country would you find the city of Paris?</label> <label>In which country would you find the city of Paris?</label>
...@@ -483,7 +478,7 @@ describe('Markdown to xml extended hint text input', function() { ...@@ -483,7 +478,7 @@ describe('Markdown to xml extended hint text input', function() {
or= USA {{ meh::hint2 }} or= USA {{ meh::hint2 }}
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<stringresponse answer="France" type="ci"> <stringresponse answer="France" type="ci">
<label>Where Paris?</label> <label>Where Paris?</label>
...@@ -504,7 +499,7 @@ or= USA {{ meh::hint2 }} ...@@ -504,7 +499,7 @@ or= USA {{ meh::hint2 }}
not= warm {{feedback2}} not= warm {{feedback2}}
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<stringresponse answer="cold" type="ci"> <stringresponse answer="cold" type="ci">
<label>Revenge is a dish best served</label> <label>Revenge is a dish best served</label>
...@@ -523,7 +518,7 @@ not= warm {{feedback2}} ...@@ -523,7 +518,7 @@ not= warm {{feedback2}}
s= 2 {{feedback1}} s= 2 {{feedback1}}
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<stringresponse answer="2" type="ci"> <stringresponse answer="2" type="ci">
<label>q</label> <label>q</label>
...@@ -544,7 +539,7 @@ not= no {{feedback2}} ...@@ -544,7 +539,7 @@ not= no {{feedback2}}
or= ccc or= ccc
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<stringresponse answer="aaa" type="ci"> <stringresponse answer="aaa" type="ci">
<label>q</label> <label>q</label>
...@@ -567,7 +562,7 @@ or= bbb {{feedback2}} ...@@ -567,7 +562,7 @@ or= bbb {{feedback2}}
or= ccc or= ccc
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<stringresponse answer="2" type="ci"> <stringresponse answer="2" type="ci">
<label>q</label> <label>q</label>
...@@ -590,7 +585,7 @@ or= ccc ...@@ -590,7 +585,7 @@ or= ccc
or= bbb or= bbb
s= ccc\ s= ccc\
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<label>q</label> <label>q</label>
<stringresponse answer="aaa" type="ci"> <stringresponse answer="aaa" type="ci">
...@@ -616,7 +611,7 @@ s= ccc ...@@ -616,7 +611,7 @@ s= ccc
paragraph 2 paragraph 2
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<p>paragraph</p> <p>paragraph</p>
<label>q</label> <label>q</label>
...@@ -640,7 +635,7 @@ or= aaa ...@@ -640,7 +635,7 @@ or= aaa
paragraph 2 paragraph 2
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<p>paragraph</p> <p>paragraph</p>
<label>q</label> <label>q</label>
...@@ -658,7 +653,7 @@ or= bbb {{feedback1}} ...@@ -658,7 +653,7 @@ or= bbb {{feedback1}}
= ccc {{feedback2}} = ccc {{feedback2}}
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<label>q</label> <label>q</label>
<stringresponse answer="aaa" type="ci"> <stringresponse answer="aaa" type="ci">
...@@ -675,7 +670,7 @@ or= bbb {{feedback1}} ...@@ -675,7 +670,7 @@ or= bbb {{feedback1}}
`); `);
}); });
return it('produces xml with demand hints', function() { it('produces xml with demand hints', function() {
const data = MarkdownEditingDescriptor.markdownToXml(`>>Where Paris?<< const data = MarkdownEditingDescriptor.markdownToXml(`>>Where Paris?<<
= France {{ BRAVO::hint1 }} = France {{ BRAVO::hint1 }}
...@@ -683,7 +678,7 @@ or= bbb {{feedback1}} ...@@ -683,7 +678,7 @@ or= bbb {{feedback1}}
|| Paris is the capital of one of those countries. || || Paris is the capital of one of those countries. ||
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<stringresponse answer="France" type="ci"> <stringresponse answer="France" type="ci">
<label>Where Paris?</label> <label>Where Paris?</label>
...@@ -713,7 +708,7 @@ describe('Markdown to xml extended hint numeric input', function() { ...@@ -713,7 +708,7 @@ describe('Markdown to xml extended hint numeric input', function() {
= 5 = 5
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<label>Enter the numerical value of Pi:</label> <label>Enter the numerical value of Pi:</label>
<numericalresponse answer="3.14159"> <numericalresponse answer="3.14159">
...@@ -739,7 +734,7 @@ describe('Markdown to xml extended hint numeric input', function() { ...@@ -739,7 +734,7 @@ describe('Markdown to xml extended hint numeric input', function() {
// The output xml here shows some of the quirks of how historical markdown parsing does or does not put // The output xml here shows some of the quirks of how historical markdown parsing does or does not put
// in blank lines. // in blank lines.
return it('numeric input with hints and demand hints', function() { it('numeric input with hints and demand hints', function() {
const data = MarkdownEditingDescriptor.markdownToXml(`\ const data = MarkdownEditingDescriptor.markdownToXml(`\
>>text1<< >>text1<<
= 1 {{ hint1 }} = 1 {{ hint1 }}
...@@ -750,7 +745,7 @@ describe('Markdown to xml extended hint numeric input', function() { ...@@ -750,7 +745,7 @@ describe('Markdown to xml extended hint numeric input', function() {
|| hintB || || hintB ||
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<label>text1</label> <label>text1</label>
<numericalresponse answer="1"> <numericalresponse answer="1">
...@@ -820,7 +815,7 @@ hint ...@@ -820,7 +815,7 @@ hint
|| ccc || || ccc ||
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<label>Checkboxes</label> <label>Checkboxes</label>
<choiceresponse> <choiceresponse>
...@@ -902,7 +897,7 @@ describe('Markdown to xml extended hint with tricky syntax cases', function() { ...@@ -902,7 +897,7 @@ describe('Markdown to xml extended hint with tricky syntax cases', function() {
|| Ø || || Ø ||
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<multiplechoiceresponse> <multiplechoiceresponse>
<label>á and Ø</label> <label>á and Ø</label>
...@@ -928,7 +923,7 @@ describe('Markdown to xml extended hint with tricky syntax cases', function() { ...@@ -928,7 +923,7 @@ describe('Markdown to xml extended hint with tricky syntax cases', function() {
(x) "isn't" {{ "hello" }} (x) "isn't" {{ "hello" }}
\ \
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<multiplechoiceresponse> <multiplechoiceresponse>
<label>"quotes" aren't \`fun\`</label> <label>"quotes" aren't \`fun\`</label>
...@@ -953,7 +948,7 @@ this (x) ...@@ -953,7 +948,7 @@ this (x)
(x) b (x) b
that (y)\ that (y)\
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<multiplechoiceresponse> <multiplechoiceresponse>
<label>q1</label> <label>q1</label>
...@@ -980,7 +975,7 @@ this [x] ...@@ -980,7 +975,7 @@ this [x]
[x] b {{ this hint passes through }} [x] b {{ this hint passes through }}
that []\ that []\
`); `);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<choiceresponse> <choiceresponse>
<label>q1</label> <label>q1</label>
...@@ -999,7 +994,7 @@ that []\ ...@@ -999,7 +994,7 @@ that []\
// It's sort of a pain to edit DOS line endings without some editor or other "fixing" them // It's sort of a pain to edit DOS line endings without some editor or other "fixing" them
// for you. Therefore, we construct DOS line endings on the fly just for the test. // for you. Therefore, we construct DOS line endings on the fly just for the test.
return it('produces xml with DOS \r\n line endings', function() { it('produces xml with DOS \r\n line endings', function() {
let markdown = `\ let markdown = `\
>>q22<< >>q22<<
...@@ -1015,7 +1010,7 @@ that []\ ...@@ -1015,7 +1010,7 @@ that []\
`; `;
markdown = markdown.replace(/\n/g, '\r\n'); // make DOS line endings markdown = markdown.replace(/\n/g, '\r\n'); // make DOS line endings
const data = MarkdownEditingDescriptor.markdownToXml(markdown); const data = MarkdownEditingDescriptor.markdownToXml(markdown);
return expect(data).toXMLEqual(`\ expect(data).toXMLEqual(`\
<problem> <problem>
<optionresponse> <optionresponse>
<label>q22</label> <label>q22</label>
......
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
describe("TabsEditingDescriptor", function() { describe("TabsEditingDescriptor", function() {
beforeEach(function() { beforeEach(function() {
this.isInactiveClass = "is-inactive"; this.isInactiveClass = "is-inactive";
...@@ -22,7 +17,7 @@ describe("TabsEditingDescriptor", function() { ...@@ -22,7 +17,7 @@ describe("TabsEditingDescriptor", function() {
spyOn($.fn, 'hide').and.callThrough(); spyOn($.fn, 'hide').and.callThrough();
spyOn($.fn, 'show').and.callThrough(); spyOn($.fn, 'show').and.callThrough();
spyOn(TabsEditingDescriptor.Model, 'initialize'); spyOn(TabsEditingDescriptor.Model, 'initialize');
return spyOn(TabsEditingDescriptor.Model, 'updateValue'); spyOn(TabsEditingDescriptor.Model, 'updateValue');
}); });
afterEach(() => TabsEditingDescriptor.Model.modules= {}); afterEach(() => TabsEditingDescriptor.Model.modules= {});
...@@ -30,7 +25,7 @@ describe("TabsEditingDescriptor", function() { ...@@ -30,7 +25,7 @@ describe("TabsEditingDescriptor", function() {
describe("constructor", () => describe("constructor", () =>
it("first tab should be visible", function() { it("first tab should be visible", function() {
expect(this.descriptor.$tabs.first()).toHaveClass(this.isCurrent); expect(this.descriptor.$tabs.first()).toHaveClass(this.isCurrent);
return expect(this.descriptor.$content.first()).not.toHaveClass(this.isInactiveClass); expect(this.descriptor.$content.first()).not.toHaveClass(this.isInactiveClass);
}) })
); );
...@@ -41,7 +36,7 @@ describe("TabsEditingDescriptor", function() { ...@@ -41,7 +36,7 @@ describe("TabsEditingDescriptor", function() {
expect(this.descriptor.$content.eq(0)).toHaveClass(this.isInactiveClass); expect(this.descriptor.$content.eq(0)).toHaveClass(this.isInactiveClass);
expect(this.descriptor.$tabs.eq(1)).toHaveClass(this.isCurrent); expect(this.descriptor.$tabs.eq(1)).toHaveClass(this.isCurrent);
expect(this.descriptor.$content.eq(1)).not.toHaveClass(this.isInactiveClass); expect(this.descriptor.$content.eq(1)).not.toHaveClass(this.isInactiveClass);
return expect(this.tab_1_switch).toHaveBeenCalled(); expect(this.tab_1_switch).toHaveBeenCalled();
}); });
it("if click on current tab, nothing should happen", function() { it("if click on current tab, nothing should happen", function() {
...@@ -49,27 +44,27 @@ describe("TabsEditingDescriptor", function() { ...@@ -49,27 +44,27 @@ describe("TabsEditingDescriptor", function() {
const currentTab = this.descriptor.$tabs.filter(`.${this.isCurrent}`); const currentTab = this.descriptor.$tabs.filter(`.${this.isCurrent}`);
this.descriptor.$tabs.eq(0).trigger("click"); this.descriptor.$tabs.eq(0).trigger("click");
expect(this.descriptor.$tabs.filter(`.${this.isCurrent}`)).toEqual(currentTab); expect(this.descriptor.$tabs.filter(`.${this.isCurrent}`)).toEqual(currentTab);
return expect($.fn.trigger.calls.count()).toEqual(1); expect($.fn.trigger.calls.count()).toEqual(1);
}); });
return it("onSwitch function call", function() { it("onSwitch function call", function() {
this.descriptor.$tabs.eq(1).trigger("click"); this.descriptor.$tabs.eq(1).trigger("click");
expect(TabsEditingDescriptor.Model.updateValue).toHaveBeenCalled(); expect(TabsEditingDescriptor.Model.updateValue).toHaveBeenCalled();
return expect(this.tab_1_switch).toHaveBeenCalled(); expect(this.tab_1_switch).toHaveBeenCalled();
}); });
}); });
return describe("save", function() { describe("save", function() {
it("function for current tab should be called", function() { it("function for current tab should be called", function() {
this.descriptor.$tabs.eq(1).trigger("click"); this.descriptor.$tabs.eq(1).trigger("click");
const { data } = this.descriptor.save(); const { data } = this.descriptor.save();
return expect(this.tab_1_modelUpdate).toHaveBeenCalled(); expect(this.tab_1_modelUpdate).toHaveBeenCalled();
}); });
return it("detach click event", function() { it("detach click event", function() {
spyOn($.fn, "off"); spyOn($.fn, "off");
this.descriptor.save(); this.descriptor.save();
return expect($.fn.off).toHaveBeenCalledWith( expect($.fn.off).toHaveBeenCalledWith(
'click', 'click',
'.editor-tabs .tab', '.editor-tabs .tab',
this.descriptor.onSwitchEditor this.descriptor.onSwitchEditor
...@@ -84,28 +79,28 @@ describe("TabsEditingDescriptor special save cases", function() { ...@@ -84,28 +79,28 @@ describe("TabsEditingDescriptor special save cases", function() {
this.isCurrent = "current"; this.isCurrent = "current";
loadFixtures('tabs-edit.html'); loadFixtures('tabs-edit.html');
this.descriptor = new window.TabsEditingDescriptor($('.xblock')); this.descriptor = new window.TabsEditingDescriptor($('.xblock'));
return this.html_id = 'test_id'; this.html_id = 'test_id';
}); });
return describe("save", function() { describe("save", function() {
it("case: no init", function() { it("case: no init", function() {
const { data } = this.descriptor.save(); const { data } = this.descriptor.save();
return expect(data).toEqual(null); expect(data).toEqual(null);
}); });
it("case: no function in model update", function() { it("case: no function in model update", function() {
TabsEditingDescriptor.Model.initialize(this.html_id); TabsEditingDescriptor.Model.initialize(this.html_id);
const { data } = this.descriptor.save(); const { data } = this.descriptor.save();
return expect(data).toEqual(null); expect(data).toEqual(null);
}); });
return it("case: no function in model update, but value presented", function() { it("case: no function in model update, but value presented", function() {
this.tab_0_modelUpdate = jasmine.createSpy('tab_0_modelUpdate').and.returnValue(1); this.tab_0_modelUpdate = jasmine.createSpy('tab_0_modelUpdate').and.returnValue(1);
TabsEditingDescriptor.Model.addModelUpdate(this.html_id, 'Tab 0 Editor', this.tab_0_modelUpdate); TabsEditingDescriptor.Model.addModelUpdate(this.html_id, 'Tab 0 Editor', this.tab_0_modelUpdate);
this.descriptor.$tabs.eq(1).trigger("click"); this.descriptor.$tabs.eq(1).trigger("click");
expect(this.tab_0_modelUpdate).toHaveBeenCalled(); expect(this.tab_0_modelUpdate).toHaveBeenCalled();
const { data } = this.descriptor.save(); const { data } = this.descriptor.save();
return expect(data).toEqual(1); expect(data).toEqual(1);
}); });
}); });
}); });
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
describe("$.immediateDescendents", function() { describe("$.immediateDescendents", function() {
beforeEach(function() { beforeEach(function() {
setFixtures(`\ setFixtures(`\
...@@ -17,22 +12,22 @@ describe("$.immediateDescendents", function() { ...@@ -17,22 +12,22 @@ describe("$.immediateDescendents", function() {
` `
); );
return this.descendents = $('#jasmine-fixtures').immediateDescendents(".xblock").get(); this.descendents = $('#jasmine-fixtures').immediateDescendents(".xblock").get();
}); });
it("finds non-immediate children", function() { it("finds non-immediate children", function() {
return expect(this.descendents).toContain($('#grandchild').get(0)); expect(this.descendents).toContain($('#grandchild').get(0));
}); });
it("finds immediate children", function() { it("finds immediate children", function() {
return expect(this.descendents).toContain($('#child').get(0)); expect(this.descendents).toContain($('#child').get(0));
}); });
it("skips nested descendents", function() { it("skips nested descendents", function() {
return expect(this.descendents).not.toContain($('#nested').get(0)); expect(this.descendents).not.toContain($('#nested').get(0));
}); });
return it("finds 2 children", function() { it("finds 2 children", function() {
return expect(this.descendents.length).toBe(2); expect(this.descendents.length).toBe(2);
}); });
}); });
\ No newline at end of file
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
describe('Courseware', function() { describe('Courseware', function() {
describe('start', () => describe('start', () =>
it('binds the Logger', function() { it('binds the Logger', function() {
spyOn(Logger, 'bind'); spyOn(Logger, 'bind');
Courseware.start(); Courseware.start();
return expect(Logger.bind).toHaveBeenCalled(); expect(Logger.bind).toHaveBeenCalled();
}) })
); );
return describe('render', function() { describe('render', function() {
beforeEach(function() { beforeEach(function() {
jasmine.stubRequests(); jasmine.stubRequests();
this.courseware = new Courseware; this.courseware = new Courseware;
...@@ -30,11 +25,11 @@ describe('Courseware', function() { ...@@ -30,11 +25,11 @@ describe('Courseware', function() {
</div>\ </div>\
` `
); );
return this.courseware.render(); this.courseware.render();
}); });
it('ensure that the XModules have been loaded', () => expect(XBlock.initializeBlocks).toHaveBeenCalled()); it('ensure that the XModules have been loaded', () => expect(XBlock.initializeBlocks).toHaveBeenCalled());
return it('detect the histrogram element and convert it', () => expect(window.Histogram).toHaveBeenCalledWith('3', [[0, 1]])); it('detect the histrogram element and convert it', () => expect(window.Histogram).toHaveBeenCalledWith('3', [[0, 1]]));
}); });
}); });
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
describe('FeedbackForm', function() { describe('FeedbackForm', function() {
beforeEach(() => loadFixtures('coffee/fixtures/feedback_form.html')); beforeEach(() => loadFixtures('coffee/fixtures/feedback_form.html'));
return describe('constructor', function() { describe('constructor', function() {
beforeEach(function() { beforeEach(function() {
new FeedbackForm; new FeedbackForm;
return spyOn($, 'postWithPrefix').and.callFake((url, data, callback, format) => callback()); spyOn($, 'postWithPrefix').and.callFake((url, data, callback, format) => callback());
}); });
it('post data to /send_feedback on click', function() { it('post data to /send_feedback on click', function() {
...@@ -17,17 +12,17 @@ describe('FeedbackForm', function() { ...@@ -17,17 +12,17 @@ describe('FeedbackForm', function() {
$('#feedback_message').val('This site is really good.'); $('#feedback_message').val('This site is really good.');
$('#feedback_button').click(); $('#feedback_button').click();
return expect($.postWithPrefix).toHaveBeenCalledWith('/send_feedback', { expect($.postWithPrefix).toHaveBeenCalledWith('/send_feedback', {
subject: 'Awesome!', subject: 'Awesome!',
message: 'This site is really good.', message: 'This site is really good.',
url: window.location.href url: window.location.href
}, jasmine.any(Function), 'json'); }, jasmine.any(Function), 'json');
}); });
return it('replace the form with a thank you message', function() { it('replace the form with a thank you message', function() {
$('#feedback_button').click(); $('#feedback_button').click();
return expect($('#feedback_div').html()).toEqual('Feedback submitted. Thank you'); expect($('#feedback_div').html()).toEqual('Feedback submitted. Thank you');
}); });
}); });
}); });
/* /*
* decaffeinate suggestions: * decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks * DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/ */
......
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
describe('Histogram', function() { describe('Histogram', function() {
beforeEach(() => spyOn($, 'plot')); beforeEach(() => spyOn($, 'plot'));
...@@ -11,29 +6,29 @@ describe('Histogram', function() { ...@@ -11,29 +6,29 @@ describe('Histogram', function() {
const histogram = new Histogram(1, []); const histogram = new Histogram(1, []);
expect(histogram.xTicks).toEqual([]); expect(histogram.xTicks).toEqual([]);
expect(histogram.yTicks).toEqual([]); expect(histogram.yTicks).toEqual([]);
return expect(histogram.data).toEqual([]); expect(histogram.data).toEqual([]);
}) })
); );
describe('calculate', function() { describe('calculate', function() {
beforeEach(function() { beforeEach(function() {
return this.histogram = new Histogram(1, [[null, 1], [1, 1], [2, 2], [3, 3]]); this.histogram = new Histogram(1, [[null, 1], [1, 1], [2, 2], [3, 3]]);
}); });
it('store the correct value for data', function() { it('store the correct value for data', function() {
return expect(this.histogram.data).toEqual([[1, Math.log(2)], [2, Math.log(3)], [3, Math.log(4)]]); expect(this.histogram.data).toEqual([[1, Math.log(2)], [2, Math.log(3)], [3, Math.log(4)]]);
}); });
it('store the correct value for x ticks', function() { it('store the correct value for x ticks', function() {
return expect(this.histogram.xTicks).toEqual([[1, '1'], [2, '2'], [3, '3']]); expect(this.histogram.xTicks).toEqual([[1, '1'], [2, '2'], [3, '3']]);
}); });
return it('store the correct value for y ticks', function() { it('store the correct value for y ticks', function() {
return expect(this.histogram.yTicks).toEqual; expect(this.histogram.yTicks).toEqual;
}); });
}); });
return describe('render', () => describe('render', () =>
it('call flot with correct option', function() { it('call flot with correct option', function() {
new Histogram(1, [[1, 1], [2, 2], [3, 3]]); new Histogram(1, [[1, 1], [2, 2], [3, 3]]);
...@@ -53,7 +48,7 @@ describe('Histogram', function() { ...@@ -53,7 +48,7 @@ describe('Histogram', function() {
color: "#b72121" color: "#b72121"
} }
]); ]);
return expect(thirdArg).toEqual({ expect(thirdArg).toEqual({
xaxis: { xaxis: {
min: -1, min: -1,
max: 4, max: 4,
......
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
describe('Tab', function() { describe('Tab', function() {
beforeEach(function() { beforeEach(function() {
loadFixtures('coffee/fixtures/tab.html'); loadFixtures('coffee/fixtures/tab.html');
return this.items = $.parseJSON(readFixtures('coffee/fixtures/items.json')); this.items = $.parseJSON(readFixtures('coffee/fixtures/items.json'));
}); });
describe('constructor', function() { describe('constructor', function() {
beforeEach(function() { beforeEach(function() {
spyOn($.fn, 'tabs'); spyOn($.fn, 'tabs');
return this.tab = new Tab(1, this.items); this.tab = new Tab(1, this.items);
}); });
it('set the element', function() { it('set the element', function() {
return expect(this.tab.el).toEqual($('#tab_1')); expect(this.tab.el).toEqual($('#tab_1'));
}); });
it('build the tabs', function() { it('build the tabs', function() {
const links = $('.navigation li>a').map(function() { return $(this).attr('href'); }).get(); const links = $('.navigation li>a').map(function() { return $(this).attr('href'); }).get();
return expect(links).toEqual(['#tab-1-0', '#tab-1-1', '#tab-1-2']); expect(links).toEqual(['#tab-1-0', '#tab-1-1', '#tab-1-2']);
}); });
it('build the container', function() { it('build the container', function() {
const containers = $('section').map(function() { return $(this).attr('id'); }).get(); const containers = $('section').map(function() { return $(this).attr('id'); }).get();
return expect(containers).toEqual(['tab-1-0', 'tab-1-1', 'tab-1-2']); expect(containers).toEqual(['tab-1-0', 'tab-1-1', 'tab-1-2']);
}); });
return it('bind the tabs', function() { it('bind the tabs', function() {
return expect($.fn.tabs).toHaveBeenCalledWith({show: this.tab.onShow}); expect($.fn.tabs).toHaveBeenCalledWith({show: this.tab.onShow});
}); });
}); });
...@@ -39,23 +34,23 @@ describe('Tab', function() { ...@@ -39,23 +34,23 @@ describe('Tab', function() {
// The code below tests that onShow does what is expected, // The code below tests that onShow does what is expected,
// but note that onShow will NOT be called when the user // but note that onShow will NOT be called when the user
// clicks on the tab if we're using jQuery version >= 1.9 // clicks on the tab if we're using jQuery version >= 1.9
return describe('onShow', function() { describe('onShow', function() {
beforeEach(function() { beforeEach(function() {
this.tab = new Tab(1, this.items); this.tab = new Tab(1, this.items);
return this.tab.onShow($('#tab-1-0'), {'index': 1}); this.tab.onShow($('#tab-1-0'), {'index': 1});
}); });
it('replace content in the container', function() { it('replace content in the container', function() {
this.tab.onShow($('#tab-1-1'), {'index': 1}); this.tab.onShow($('#tab-1-1'), {'index': 1});
expect($('#tab-1-0').html()).toEqual(''); expect($('#tab-1-0').html()).toEqual('');
expect($('#tab-1-1').html()).toEqual('Video 2'); expect($('#tab-1-1').html()).toEqual('Video 2');
return expect($('#tab-1-2').html()).toEqual(''); expect($('#tab-1-2').html()).toEqual('');
}); });
return it('trigger contentChanged event on the element', function() { it('trigger contentChanged event on the element', function() {
spyOnEvent(this.tab.el, 'contentChanged'); spyOnEvent(this.tab.el, 'contentChanged');
this.tab.onShow($('#tab-1-1'), {'index': 1}); this.tab.onShow($('#tab-1-1'), {'index': 1});
return expect('contentChanged').toHaveBeenTriggeredOn(this.tab.el); expect('contentChanged').toHaveBeenTriggeredOn(this.tab.el);
}); });
}); });
}); });
...@@ -42,10 +42,10 @@ describe("RequireJS namespacing", function() { ...@@ -42,10 +42,10 @@ describe("RequireJS namespacing", function() {
it("check that the RequireJS object is present in the global namespace", function() { it("check that the RequireJS object is present in the global namespace", function() {
expect(RequireJS).toEqual(jasmine.any(Object)); expect(RequireJS).toEqual(jasmine.any(Object));
return expect(window.RequireJS).toEqual(jasmine.any(Object)); expect(window.RequireJS).toEqual(jasmine.any(Object));
}); });
return it("check that requirejs(), require(), and define() are not in the global namespace", function() { it("check that requirejs(), require(), and define() are not in the global namespace", function() {
// The custom matchers that we defined in the beforeEach() function do // The custom matchers that we defined in the beforeEach() function do
// not operate on an object. We pass a dummy empty object {} not to // not operate on an object. We pass a dummy empty object {} not to
...@@ -55,7 +55,7 @@ describe("RequireJS namespacing", function() { ...@@ -55,7 +55,7 @@ describe("RequireJS namespacing", function() {
expect({}).defineTobeUndefined(); expect({}).defineTobeUndefined();
expect(window.requirejs).not.toBeDefined(); expect(window.requirejs).not.toBeDefined();
expect(window.require).not.toBeDefined(); expect(window.require).not.toBeDefined();
return expect(window.define).not.toBeDefined(); expect(window.define).not.toBeDefined();
}); });
}); });
...@@ -63,7 +63,7 @@ describe("RequireJS namespacing", function() { ...@@ -63,7 +63,7 @@ describe("RequireJS namespacing", function() {
describe("RequireJS module creation", function() { describe("RequireJS module creation", function() {
let inDefineCallback = undefined; let inDefineCallback = undefined;
let inRequireCallback = undefined; let inRequireCallback = undefined;
return it("check that we can use RequireJS to define() and require() a module", function(done) { it("check that we can use RequireJS to define() and require() a module", function(done) {
const d1 = $.Deferred(); const d1 = $.Deferred();
const d2 = $.Deferred(); const d2 = $.Deferred();
// Because Require JS works asynchronously when defining and requiring // Because Require JS works asynchronously when defining and requiring
...@@ -105,10 +105,10 @@ describe("RequireJS module creation", function() { ...@@ -105,10 +105,10 @@ describe("RequireJS module creation", function() {
func(); func();
// We will wait before checking if our module was defined and that we were able to require() the module. // We will wait before checking if our module was defined and that we were able to require() the module.
return $.when(d1, d2).done(function() { $.when(d1, d2).done(function() {
// The final test behavior // The final test behavior
expect(inDefineCallback).toBeTruthy(); expect(inDefineCallback).toBeTruthy();
return expect(inRequireCallback).toBeTruthy(); expect(inRequireCallback).toBeTruthy();
}).always(done); }).always(done);
}); });
}); });
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