Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32216417
D4991.1765167180.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D4991.1765167180.diff
View Options
diff --git a/lib/utils/validation-utils.test.js b/lib/utils/validation-utils.test.js
--- a/lib/utils/validation-utils.test.js
+++ b/lib/utils/validation-utils.test.js
@@ -2,7 +2,11 @@
import { threadTypes } from '../types/thread-types';
import { values } from '../utils/objects';
-import { tNumEnum } from './validation-utils';
+import {
+ tMediaMessagePhoto,
+ tMediaMessageVideo,
+ tNumEnum,
+} from './validation-utils';
describe('Validation utils', () => {
describe('tNumEnum validator', () => {
@@ -26,4 +30,113 @@
expect(tNumEnum(values(threadTypes)).is(123)).toBe(false);
});
});
+
+ describe('tMediaMessagePhoto validator', () => {
+ it('Should succeed when valid MediaMessagePhoto', () => {
+ expect(tMediaMessagePhoto.is({ type: 'photo', uploadID: '12345' })).toBe(
+ true,
+ );
+ });
+
+ it('Should fail when missing uploadID', () => {
+ expect(tMediaMessagePhoto.is({ type: 'photo' })).toBe(false);
+ });
+
+ it('Should fail when uploadID is not a string', () => {
+ expect(tMediaMessagePhoto.is({ type: 'photo', uploadID: 12345 })).toBe(
+ false,
+ );
+ });
+
+ it('Should fail when type is not photo', () => {
+ expect(tMediaMessagePhoto.is({ type: 'blah', uploadID: '12345' })).toBe(
+ false,
+ );
+ });
+
+ it('Should fail when type is video', () => {
+ expect(tMediaMessagePhoto.is({ type: 'video', uploadID: '12345' })).toBe(
+ false,
+ );
+ });
+ });
+
+ describe('tMediaMessageVideo validator', () => {
+ it('Should succeed when valid tMediaMessageVideo', () => {
+ expect(
+ tMediaMessageVideo.is({
+ type: 'video',
+ uploadID: '12345',
+ thumbnailUploadID: '7890',
+ }),
+ ).toBe(true);
+ });
+
+ it('Should fail when missing thumbnailUploadID', () => {
+ expect(
+ tMediaMessageVideo.is({
+ type: 'video',
+ uploadID: '12345',
+ }),
+ ).toBe(false);
+ });
+
+ it('Should fail when uploadID is not a string', () => {
+ expect(
+ tMediaMessageVideo.is({
+ type: 'video',
+ uploadID: 12345,
+ thumbnailUploadID: '7890',
+ }),
+ ).toBe(false);
+ });
+
+ it('Should fail when type is not video', () => {
+ expect(
+ tMediaMessageVideo.is({
+ type: 'blah',
+ uploadID: '12345',
+ thumbnailUploadID: '7890',
+ }),
+ ).toBe(false);
+ });
+
+ it('Should fail when type is photo', () => {
+ expect(
+ tMediaMessageVideo.is({
+ type: 'photo',
+ uploadID: '12345',
+ thumbnailUploadID: '7890',
+ }),
+ ).toBe(false);
+ });
+ });
+
+ describe('tMediaMessageMedia validator', () => {
+ it('Should succeed when valid MediaMessagePhoto', () => {
+ expect(tMediaMessagePhoto.is({ type: 'photo', uploadID: '12345' })).toBe(
+ true,
+ );
+ });
+
+ it('Should succeed when valid tMediaMessageVideo', () => {
+ expect(
+ tMediaMessageVideo.is({
+ type: 'video',
+ uploadID: '12345',
+ thumbnailUploadID: '7890',
+ }),
+ ).toBe(true);
+ });
+
+ it('Should fail when not valid MediaMessagePhoto or tMediaMessageVideo', () => {
+ expect(
+ tMediaMessageVideo.is({
+ type: 'audio',
+ uploadID: '1000',
+ thumbnailUploadID: '1000',
+ }),
+ ).toBe(false);
+ });
+ });
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 8, 4:13 AM (10 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5842298
Default Alt Text
D4991.1765167180.diff (3 KB)
Attached To
Mode
D4991: [lib] Introduce tests for `tMediaMessage[Photo/Video/Media]`
Attached
Detach File
Event Timeline
Log In to Comment