-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(taToolbar): Update insertVideo to handle youtube link variants
* Create new function taToolFunctions.extractYoutubeVideoId * Add tests to verify extractYoutubeVideoId function
- Loading branch information
1 parent
72cca33
commit 1372bc1
Showing
3 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
describe('taToolFunctions', function(){ | ||
var taToolFunctions; | ||
|
||
beforeEach(module('textAngular')); | ||
|
||
beforeEach(inject(function(_taToolFunctions_){ | ||
taToolFunctions = _taToolFunctions_; | ||
})); | ||
|
||
describe('extractYoutubeVideoId', function(){ | ||
|
||
it('should extract video id from youtube link variations', function(){ | ||
youtubeVideUrlVariations = [ | ||
'http://www.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index', | ||
'http://www.youtube.com/user/IngridMichaelsonVEVO#p/a/u/1/0zM3nApSvMg', | ||
'http://www.youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0', | ||
'http://www.youtube.com/watch?v=0zM3nApSvMg#t=0m10s', | ||
'http://www.youtube.com/embed/0zM3nApSvMg?rel=0', | ||
'http://www.youtube.com/watch?v=0zM3nApSvMg', | ||
'http://youtu.be/0zM3nApSvMg', | ||
'https://www.youtube-nocookie.com/embed/0zM3nApSvMg' | ||
]; | ||
|
||
angular.forEach(youtubeVideUrlVariations, function(youtubeVideUrl) { | ||
expect(taToolFunctions.extractYoutubeVideoId(youtubeVideUrl)).toBe('0zM3nApSvMg'); | ||
}); | ||
}); | ||
it('should not extract video id from invalid youtube link variations', function(){ | ||
invalidYoutubeVideUrlVariations = [ | ||
'http://www.youtube.com/watch?v=0zM3nApS&feature=feedrec_grec_index', | ||
'http://www.youtube.com/user/elsonVEVO#p/a/u/1/8U-VIH_o', | ||
'http://www.youtube.com/v/0zM3nApS?fs=1&hl=en_US&rel=0', | ||
'http://www.youtube.com/watch?v=0zApSvMg#t=0m10s', | ||
'http://www.youtube.com/embed/0zM3Mg?rel=0', | ||
'http://www.youtube.com/watch?v=0znApSvMg', | ||
'http://youtu.be/0zM3nAvMg', | ||
'https://www.youtube-nocookie.com/embed/0zM3nApSvMg' | ||
]; | ||
|
||
angular.forEach(invalidYoutubeVideUrlVariations, function(youtubeVideUrl) { | ||
expect(taToolFunctions.extractYoutubeVideoId(youtubeVideUrl)).toBeNull(); | ||
}); | ||
}); | ||
}); | ||
}); |
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