فهرست منبع

added test cases

davitbejanyan 2 سال پیش
والد
کامیت
4b94a8ecf0
1فایلهای تغییر یافته به همراه32 افزوده شده و 6 حذف شده
  1. 32 6
      kafka-ui-react-app/src/lib/__test__/yupExtended.spec.ts

+ 32 - 6
kafka-ui-react-app/src/lib/__test__/yupExtended.spec.ts

@@ -1,4 +1,4 @@
-import { isValidEnum, isValidJsonObject } from 'lib/yupExtended';
+import { isValidSchema, isValidJsonObject } from 'lib/yupExtended';
 
 const invalidEnum = `
 ennum SchemType {
@@ -14,6 +14,26 @@ enum SchemType {
   PROTOBUF = 3;
 }
 `;
+const invalidSchema = `
+ssssyntax = "proto3";
+package com.provectus;
+
+message TestProtoRecord {
+  string f1 = 1;
+  int32 f2 = 2;
+  int32 f6 = 3;
+}
+`;
+const validSchema = `
+syntax = "proto3";
+package com.provectus;
+
+message TestProtoRecord {
+  string f1 = 1;
+  int32 f2 = 2;
+  int32 f6 = 3;
+}
+`;
 describe('yup extended', () => {
   describe('isValidJsonObject', () => {
     it('returns false for no value', () => {
@@ -36,20 +56,26 @@ describe('yup extended', () => {
     });
   });
 
-  describe('isValidEnum', () => {
+  describe('isValidSchema', () => {
     it('returns false for invalid enum', () => {
-      expect(isValidEnum(invalidEnum)).toBeFalsy();
+      expect(isValidSchema(invalidEnum)).toBeFalsy();
+    });
+    it('returns false for invalid schema', () => {
+      expect(isValidSchema(invalidSchema)).toBeFalsy();
     });
     it('returns false for no value', () => {
-      expect(isValidEnum()).toBeFalsy();
+      expect(isValidSchema()).toBeFalsy();
     });
     it('returns true should trim value', () => {
       expect(
-        isValidEnum(`  enum SchemType {AVRO = 0; PROTOBUF = 3;}   `)
+        isValidSchema(`  enum SchemType {AVRO = 0; PROTOBUF = 3;}   `)
       ).toBeTruthy();
     });
     it('returns true for valid enum', () => {
-      expect(isValidEnum(validEnum)).toBeTruthy();
+      expect(isValidSchema(validEnum)).toBeTruthy();
+    });
+    it('returns true for valid schema', () => {
+      expect(isValidSchema(validSchema)).toBeTruthy();
     });
   });
 });