Page MenuHomePhabricator

D4991.id16121.diff
No OneTemporary

D4991.id16121.diff

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('tMediaMessagePhoto 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

Mime Type
text/plain
Expires
Tue, Nov 26, 6:37 AM (21 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2583314
Default Alt Text
D4991.id16121.diff (3 KB)

Event Timeline