From 63bd9dcc612c6dc1f77738e6ac4adc66ea4320ea Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Mon, 7 May 2018 15:47:33 -0400 Subject: [PATCH] Add tests for `Attachment.isVisualMedia` --- ts/test/types/Attachment_test.ts | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/ts/test/types/Attachment_test.ts b/ts/test/types/Attachment_test.ts index 23fa40995..b7ef5f754 100644 --- a/ts/test/types/Attachment_test.ts +++ b/ts/test/types/Attachment_test.ts @@ -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 = {