Skip to content

Instantly share code, notes, and snippets.

@ndemengel
Last active November 13, 2016 20:58
Show Gist options
  • Save ndemengel/749b3e7b2171a364fcaf860173694521 to your computer and use it in GitHub Desktop.
Save ndemengel/749b3e7b2171a364fcaf860173694521 to your computer and use it in GitHub Desktop.
Example of JS test "interpreting" a JSP (the JSP can be found here: https://gist.github.com/ndemengel/54df1425968d9e8d05d052e71b31e4d9)
const tu = require('../tu');
const expect = tu.expect;
const withDocument = tu.withDocument;
const ratingStarsJspAndScript = {
jsp: 'include/editableRatingStars',
hopModules: 'Hop/components/editable-rating-stars',
attributes: {
param: {path: 'someRadioInput'}
}
};
describe('Editable Rating Stars', () => {
it('should add "active" class to all ".star"s before the one that has been clicked',
withDocument(ratingStarsJspAndScript, $ => {
// when
$('.star:eq(3) input').change();
// then
expect($('.star').get(0).className).to.match(/\bactive\b/);
expect($('.star').get(1).className).to.match(/\bactive\b/);
expect($('.star').get(2).className).to.match(/\bactive\b/);
expect($('.star').get(3).className).to.match(/\bactive\b/);
expect($('.star').get(4).className).to.not.match(/\bactive\b/);
}));
// more tests...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment