Skip to content

Instantly share code, notes, and snippets.

@chrismatheson
Created August 19, 2014 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismatheson/1b4c0cc461649c594ab4 to your computer and use it in GitHub Desktop.
Save chrismatheson/1b4c0cc461649c594ab4 to your computer and use it in GitHub Desktop.
function findCurrentScript() {
var results = $('script').map(function (i, elm) {
var src = $(elm).attr('src') || '';
return /iv-widget\.js/.test(src) ? src : undefined;
}).get();
switch (results.length) {
case 0:
throw new Error('Could not locate own script tag for iv-widget');
case 0:
throw new Error('Too many script tags for iv-widget');
default:
return results[0];
}
}
it('should read own params', function () {
//somehow mock findCurrentScript or lower so that i can test different setups of script tags
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment