I am writing test cases in JavaScript and jQuery, the framework is Jasmine and Karma.
describe('When a user selects a multiple-response Hotspot response', function () {
it('Then allow highlighting multiple responses', function (done) {
utils.clickHotspotElementAtIndex(view, 1, function() {});
utils.clickHotspotElementAtIndex(view, 0, function() {});
utils.clickHotspotElementAtIndex(view, 2, function() {});
setTimeout(function() {
expect(utils.verifyHotSpotHasBeenHiglightedAtIndex(view, 0)).toBe('true');
expect(utils.verifyHotSpotHasBeenHiglightedAtIndex(view, 1)).toBe('true');
expect(utils.verifyHotSpotHasBeenHiglightedAtIndex(view, 2)).toBe('true');
done();
}), 2000});
});
What it does is:
- click on element 1, sync action
- click on element 0, sync action
- click on element 2. sync action
- When the main thread is free, wait for 2 seconds and then
- expect element 0 has been highlighted
- expect element 1 has been highlighted
- expect element 2 has been highlighted
Is there a more elegant way to do this?