77} from "~/tests/__fixtures" ;
88import { clearDatabase } from "~/tests/__fixtures/databaseHelper" ;
99import { CommnunityStatus } from "~/generated/types" ;
10- import { faker } from "@faker-js/faker" ;
10+ import { fa , faker } from "@faker-js/faker" ;
1111import {
1212 CreateCommunity ,
1313 CreateCommunityMutation ,
@@ -74,7 +74,7 @@ describe("Community", () => {
7474 } ) ;
7575 it ( "If community slug already exist" , async ( ) => {
7676 await insertCommunity ( {
77- name : "a " ,
77+ name : "aas " ,
7878 slug : "c" ,
7979 } ) ;
8080 const fakeData = {
@@ -95,5 +95,53 @@ describe("Community", () => {
9595 assert . equal ( response . errors ?. length , 1 ) ;
9696 assert . equal ( response . errors ?. [ 0 ] ?. message , "This slug already exist" ) ;
9797 } ) ;
98+ it ( "If community name shorter than 2 characters" , async ( ) => {
99+ const fakeData = {
100+ name : "s" ,
101+ slug : "c" ,
102+ description : faker . lorem . paragraph ( 3 ) ,
103+ } ;
104+ const response = await executeGraphqlOperationAsSuperAdmin <
105+ CreateCommunityMutation ,
106+ CreateCommunityMutationVariables
107+ > ( {
108+ document : CreateCommunity ,
109+ variables : {
110+ input : fakeData ,
111+ } ,
112+ } ) ;
113+ const msg = JSON . parse ( response . errors ?. [ 0 ] ?. message || "" ) as {
114+ message : string ;
115+ } [ ] ;
116+ assert . equal ( response . errors ?. length , 1 ) ;
117+ assert . equal (
118+ msg [ 0 ] . message ,
119+ "String must contain at least 2 character(s)" ,
120+ ) ;
121+ } ) ;
122+ it ( "If community name shorter than 65 characters" , async ( ) => {
123+ const fakeData = {
124+ name : faker . lorem . words ( 65 ) ,
125+ slug : "c" ,
126+ description : faker . lorem . paragraph ( 3 ) ,
127+ } ;
128+ const response = await executeGraphqlOperationAsSuperAdmin <
129+ CreateCommunityMutation ,
130+ CreateCommunityMutationVariables
131+ > ( {
132+ document : CreateCommunity ,
133+ variables : {
134+ input : fakeData ,
135+ } ,
136+ } ) ;
137+ const msg = JSON . parse ( response . errors ?. [ 0 ] ?. message || "" ) as {
138+ message : string ;
139+ } [ ] ;
140+ assert . equal ( response . errors ?. length , 1 ) ;
141+ assert . equal (
142+ msg [ 0 ] . message ,
143+ "String must contain at most 64 character(s)" ,
144+ ) ;
145+ } ) ;
98146 } ) ;
99147} ) ;
0 commit comments