vitest describe

This commit is contained in:
Takeshi Kimata
2024-06-01 13:52:11 +09:00
parent 8382f862fb
commit 39d5ab16a6
2 changed files with 50 additions and 46 deletions

View File

@@ -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);
});
});