gabrieldoty / simplify-scorm

Scorm 1.2 Javascript API
MIT License
230 stars 77 forks source link

Add multiple listeners at once #14

Closed markedmondson closed 5 years ago

markedmondson commented 5 years ago

Allow adding of multiple listeners at once, like:

window.API.on('LMSCommit LMSFinish', function() {
    postResultsAjax();
});

(Thanks a million for the API)

xob commented 5 years ago

This changeset breaks two karma tests on the baseAPI.js file (test/baseAPI.spec.js). Although they break because we used dummy test function names that include spaces in them, it is a broken test.

These tests breaking is a good reminder that we should be adding automated tests for pull requests. I will look into that.

I would also like to see at least one test added for this feature. It could probably be done by changing the setup function of the processListeners tests, for example api.on(anyFunctionName + " " + anyOtherFunctionName, callbacks[0]);, and changing a further test to use callbacks[0] instead of callbacks[3].

markedmondson commented 5 years ago

Oh I totally didn't see the tests, sorry! An automated suite would definitely be useful. Anything I can do to help?

xob commented 5 years ago

Automated tests are now in place. The next commit / pull request will have Travis CI running. There is unfortunately no way to run the suite on the pull request as it stands right now.

In your development environment, you can install the necessary components by running npm install, and then you can run the tests using npm test. There is also grunt karma:dev available to watch files for changes and automatically re-run the test suite.

Your next commit should trigger a build with Travis CI.

gabrieldoty commented 5 years ago

@markedmondson are you planning on building the suggested tests? I think this would be a good feature to add in

markedmondson commented 5 years ago

Thanks for the reminder. Yes, I'll give it a shot!

markedmondson commented 5 years ago

Tests changed here: 77eeb47

First time using Karma so feedback welcome, and matching someone else's test patterns is always tricky!

Adding the contribution instructions for running the tests to the README would be useful too.