Add tests for Attachment.isVisualMedia
This commit is contained in:
parent
53918d68de
commit
63bd9dcc61
1 changed files with 39 additions and 0 deletions
|
@ -59,6 +59,45 @@ describe('Attachment', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('isVisualMedia', () => {
|
||||
it('should return true for images', () => {
|
||||
const attachment: Attachment.Attachment = {
|
||||
fileName: 'meme.gif',
|
||||
data: stringToArrayBuffer('gif'),
|
||||
contentType: MIME.IMAGE_GIF,
|
||||
};
|
||||
assert.isTrue(Attachment.isVisualMedia(attachment));
|
||||
});
|
||||
|
||||
it('should return true for videos', () => {
|
||||
const attachment: Attachment.Attachment = {
|
||||
fileName: 'meme.mp4',
|
||||
data: stringToArrayBuffer('mp4'),
|
||||
contentType: MIME.VIDEO_MP4,
|
||||
};
|
||||
assert.isTrue(Attachment.isVisualMedia(attachment));
|
||||
});
|
||||
|
||||
it('should return false for voice message attachment', () => {
|
||||
const attachment: Attachment.Attachment = {
|
||||
fileName: 'Voice Message.aac',
|
||||
flags: SignalService.AttachmentPointer.Flags.VOICE_MESSAGE,
|
||||
data: stringToArrayBuffer('voice message'),
|
||||
contentType: MIME.AUDIO_AAC,
|
||||
};
|
||||
assert.isFalse(Attachment.isVisualMedia(attachment));
|
||||
});
|
||||
|
||||
it('should return false for other attachments', () => {
|
||||
const attachment: Attachment.Attachment = {
|
||||
fileName: 'foo.json',
|
||||
data: stringToArrayBuffer('{"foo": "bar"}'),
|
||||
contentType: MIME.APPLICATION_JSON,
|
||||
};
|
||||
assert.isFalse(Attachment.isVisualMedia(attachment));
|
||||
});
|
||||
});
|
||||
|
||||
describe('isFile', () => {
|
||||
it('should return true for JSON', () => {
|
||||
const attachment: Attachment.Attachment = {
|
||||
|
|
Loading…
Add table
Reference in a new issue