forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
168 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
{ | ||
"presets": [ | ||
["env", { | ||
"targets": { | ||
"browsers": [ | ||
"last 2 versions", | ||
"IE >= 11" | ||
] | ||
}, | ||
"useBuiltIns": true, | ||
"modules": false, | ||
"exclude": [ | ||
"transform-regenerator" | ||
] | ||
}], | ||
"react" | ||
], | ||
"plugins": [ | ||
"transform-object-rest-spread" | ||
[ | ||
"env", | ||
{ | ||
"targets": { | ||
"browsers": [ | ||
"last 2 versions", | ||
"IE >= 11" | ||
] | ||
}, | ||
"modules": "commonjs" | ||
} | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
extends: 'eslint-config-edx', | ||
root: true, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
openedx/features/course_experience/static/course_experience/js/spec/CourseOutline_spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import * as constants from "edx-ui-toolkit/js/utils/constants"; | ||
import log from 'logger'; | ||
import { CourseOutline } from "../CourseOutline"; | ||
|
||
describe('Course outline factory', () => { | ||
describe('keyboard listener', () => { | ||
const triggerKeyListener = (current, destination, keyCode) => { | ||
current.focus(); | ||
spyOn(destination, 'focus'); | ||
|
||
$('.block-tree').trigger( | ||
$.Event('keydown', { | ||
keyCode, | ||
target: current, | ||
}), | ||
); | ||
}; | ||
|
||
beforeEach(() => { | ||
loadFixtures('course_experience/fixtures/course-outline-fragment.html'); | ||
new CourseOutline('.block-tree'); | ||
}); | ||
|
||
describe('when the down arrow is pressed', () => { | ||
it('moves focus from a subsection to the next subsection in the outline', () => { | ||
const current = $('a.focusable:contains("Homework - Labs and Demos")')[0]; | ||
const destination = $('a.focusable:contains("Homework - Essays")')[0]; | ||
|
||
triggerKeyListener(current, destination, constants.keyCodes.down); | ||
|
||
expect(destination.focus).toHaveBeenCalled(); | ||
}); | ||
|
||
it('moves focus to the section list if at a section boundary', () => { | ||
const current = $('li.focusable:contains("Example Week 3: Be Social")')[0]; | ||
const destination = $('ol.focusable:contains("Lesson 3 - Be Social")')[0]; | ||
|
||
triggerKeyListener(current, destination, constants.keyCodes.down); | ||
|
||
expect(destination.focus).toHaveBeenCalled(); | ||
}); | ||
|
||
it('moves focus to the next section if on the last subsection', () => { | ||
const current = $('a.focusable:contains("Homework - Essays")')[0]; | ||
const destination = $('li.focusable:contains("Example Week 3: Be Social")')[0]; | ||
|
||
triggerKeyListener(current, destination, constants.keyCodes.down); | ||
|
||
expect(destination.focus).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
describe('when the up arrow is pressed', () => { | ||
it('moves focus from a subsection to the previous subsection in the outline', () => { | ||
const current = $('a.focusable:contains("Homework - Essays")')[0]; | ||
const destination = $('a.focusable:contains("Homework - Labs and Demos")')[0]; | ||
|
||
triggerKeyListener(current, destination, constants.keyCodes.up); | ||
|
||
expect(destination.focus).toHaveBeenCalled(); | ||
}); | ||
|
||
it('moves focus to the section group if at the first subsection', () => { | ||
const current = $('a.focusable:contains("Lesson 3 - Be Social")')[0]; | ||
const destination = $('ol.focusable:contains("Lesson 3 - Be Social")')[0]; | ||
|
||
triggerKeyListener(current, destination, constants.keyCodes.up); | ||
|
||
expect(destination.focus).toHaveBeenCalled(); | ||
}); | ||
|
||
it('moves focus last subsection of the previous section if at a section boundary', () => { | ||
const current = $('li.focusable:contains("Example Week 3: Be Social")')[0]; | ||
const destination = $('a.focusable:contains("Homework - Essays")')[0]; | ||
|
||
triggerKeyListener(current, destination, constants.keyCodes.up); | ||
|
||
expect(destination.focus).toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("eventing", function() { | ||
beforeEach(function() { | ||
loadFixtures("course_experience/fixtures/course-outline-fragment.html"); | ||
CourseOutlineFactory(".block-tree"); | ||
spyOn(Logger, "log"); | ||
}); | ||
|
||
it("sends an event when an outline section is clicked", function() { | ||
$('a.focusable:contains("Homework - Labs and Demos")').click(); | ||
|
||
expect(Logger.log).toHaveBeenCalledWith("edx.ui.lms.link_clicked", { | ||
target_url: ( | ||
window.location.origin + | ||
"/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type" + | ||
"@sequential+block@graded_simulations" | ||
), | ||
current_url: window.location.toString() | ||
}); | ||
}); | ||
}); | ||
|
||
}); |
Oops, something went wrong.