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