45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import { SetYouTubeVideoValidator } from '@/validators/Lessons.validator';
|
|
|
|
describe('SetYouTubeVideoValidator', () => {
|
|
it('should pass with valid youtube_video_id and video_title', () => {
|
|
const { error } = SetYouTubeVideoValidator.validate({
|
|
youtube_video_id: 'dQw4w9WgXcQ',
|
|
video_title: 'Introduction to TypeScript',
|
|
});
|
|
expect(error).toBeUndefined();
|
|
});
|
|
|
|
it('should fail without youtube_video_id', () => {
|
|
const { error } = SetYouTubeVideoValidator.validate({
|
|
video_title: 'Intro to TS',
|
|
});
|
|
expect(error).toBeDefined();
|
|
expect(error?.details[0].message).toMatch(/YouTube video ID is required/i);
|
|
});
|
|
|
|
it('should fail with empty youtube_video_id string', () => {
|
|
const { error } = SetYouTubeVideoValidator.validate({
|
|
youtube_video_id: '',
|
|
video_title: 'Intro to TS',
|
|
});
|
|
expect(error).toBeDefined();
|
|
expect(error?.details[0].message).toMatch(/cannot be empty/i);
|
|
});
|
|
|
|
it('should fail without video_title', () => {
|
|
const { error } = SetYouTubeVideoValidator.validate({
|
|
youtube_video_id: 'dQw4w9WgXcQ',
|
|
});
|
|
expect(error).toBeDefined();
|
|
expect(error?.details[0].message).toMatch(/Video title is required/i);
|
|
});
|
|
|
|
it('should fail with empty video_title string', () => {
|
|
const { error } = SetYouTubeVideoValidator.validate({
|
|
youtube_video_id: 'dQw4w9WgXcQ',
|
|
video_title: '',
|
|
});
|
|
expect(error).toBeDefined();
|
|
expect(error?.details[0].message).toMatch(/cannot be empty/i);
|
|
});
|
|
});
|