vitest describe
This commit is contained in:
@@ -1,24 +1,26 @@
|
||||
import { expect, test } from 'vitest';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import { isValidEmail, isValidPassword } from './validate';
|
||||
|
||||
test('validate email', () => {
|
||||
const email1 = 'aaa@gmail.com';
|
||||
expect(isValidEmail(email1)).toBe(true);
|
||||
describe('account validation', () => {
|
||||
test('validate email', () => {
|
||||
const email1 = 'aaa@gmail.com';
|
||||
expect(isValidEmail(email1)).toBe(true);
|
||||
|
||||
const email2 = 'gmail.com';
|
||||
expect(isValidEmail(email2)).toBe(false);
|
||||
const email2 = 'gmail.com';
|
||||
expect(isValidEmail(email2)).toBe(false);
|
||||
|
||||
const email23 = '';
|
||||
expect(isValidEmail(email23)).toBe(false);
|
||||
});
|
||||
|
||||
test('validate password', () => {
|
||||
const pass1 = 'aaaaaaaa';
|
||||
expect(isValidPassword(pass1)).toBe(true);
|
||||
|
||||
const pass2 = 'abcdefg';
|
||||
expect(isValidPassword(pass2)).toBe(false);
|
||||
|
||||
const pass3 = '';
|
||||
expect(isValidPassword(pass3)).toBe(false);
|
||||
const email23 = '';
|
||||
expect(isValidEmail(email23)).toBe(false);
|
||||
});
|
||||
|
||||
test('validate password', () => {
|
||||
const pass1 = 'aaaaaaaa';
|
||||
expect(isValidPassword(pass1)).toBe(true);
|
||||
|
||||
const pass2 = 'abcdefg';
|
||||
expect(isValidPassword(pass2)).toBe(false);
|
||||
|
||||
const pass3 = '';
|
||||
expect(isValidPassword(pass3)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,35 +1,37 @@
|
||||
import { expect, test } from 'vitest';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import { isImage } from './isImage';
|
||||
import { AttachmentType } from '@/types/case';
|
||||
|
||||
test('isImage', () => {
|
||||
type CaseAttachmentType = {
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
CaseId: number;
|
||||
AttachmentId: number;
|
||||
};
|
||||
describe('attachment control', () => {
|
||||
test('isImage', () => {
|
||||
type CaseAttachmentType = {
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
CaseId: number;
|
||||
AttachmentId: number;
|
||||
};
|
||||
|
||||
const sampleCaseAttachment: CaseAttachmentType = {
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
CaseId: 1,
|
||||
AttachmentId: 1,
|
||||
};
|
||||
const sampleCaseAttachment: CaseAttachmentType = {
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
CaseId: 1,
|
||||
AttachmentId: 1,
|
||||
};
|
||||
|
||||
const sampleAttachment: AttachmentType = {
|
||||
id: 1,
|
||||
title: '',
|
||||
detail: '',
|
||||
path: '',
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
caseAttachments: sampleCaseAttachment,
|
||||
};
|
||||
const sampleAttachment: AttachmentType = {
|
||||
id: 1,
|
||||
title: '',
|
||||
detail: '',
|
||||
path: '',
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
caseAttachments: sampleCaseAttachment,
|
||||
};
|
||||
|
||||
sampleAttachment.path = 'public/uploads/abc.png';
|
||||
expect(isImage(sampleAttachment)).toBe(true);
|
||||
sampleAttachment.path = 'public/uploads/abc.png';
|
||||
expect(isImage(sampleAttachment)).toBe(true);
|
||||
|
||||
sampleAttachment.path = 'public/uploads/abc.mp3';
|
||||
expect(isImage(sampleAttachment)).toBe(false);
|
||||
sampleAttachment.path = 'public/uploads/abc.mp3';
|
||||
expect(isImage(sampleAttachment)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user