Created
August 19, 2014 15:00
-
-
Save chrismatheson/1b4c0cc461649c594ab4 to your computer and use it in GitHub Desktop.
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
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]; | |
} | |
} |
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
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