Skip to content

Instantly share code, notes, and snippets.

@frederikprijck
Created January 24, 2017 07:04
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 frederikprijck/caf5d407af0c40d2805951f4450e0ead to your computer and use it in GitHub Desktop.
Save frederikprijck/caf5d407af0c40d2805951f4450e0ead to your computer and use it in GitHub Desktop.
describe('Youtube api service', () => {
let service;
beforeEach(() => {
angular
.module('app', [])
.service('youtubeService', YoutubeService);
angular.mock.module('app');
});
beforeEach(angular.mock.inject((youtubeService) => {
service = youtubeService;
}));
it('should get an ID from long youtube link', () => {
let link = 'https://www.youtube.com/watch?v=TFeSNOdNtyo';
let id = service.getId(link);
expect(id).toBe('TFeSNOdNtyo');
});
it('should get an ID from short youtube link', () => {
let link = 'https://www.youtu.be/TFeSNOdNtyo';
let id = service.getId(link);
expect(id).toBe('TFeSNOdNtyo');
});
it('should get an ID from same ID', () => {
let inputID = 'TFeSNOdNtyo';
let id = service.getId(inputID);
expect(id).toBe('TFeSNOdNtyo');
});
});
describe('Youtube api service', () => {
let service;
beforeEach(() => {
service = new YoutubeService();
});
it('should get an ID from long youtube link', () => {
let link = 'https://www.youtube.com/watch?v=TFeSNOdNtyo';
let id = service.getId(link);
expect(id).toBe('TFeSNOdNtyo');
});
it('should get an ID from short youtube link', () => {
let link = 'https://www.youtu.be/TFeSNOdNtyo';
let id = service.getId(link);
expect(id).toBe('TFeSNOdNtyo');
});
it('should get an ID from same ID', () => {
let inputID = 'TFeSNOdNtyo';
let id = service.getId(inputID);
expect(id).toBe('TFeSNOdNtyo');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment