1- import chai from 'chai' ;
21import { v4 as uuidv4 } from 'uuid' ;
32
43import { generateChannel } from './test-utils/generateChannel' ;
@@ -13,7 +12,7 @@ import { mockChannelQueryResponse } from './test-utils/mockChannelQueryResponse'
1312import { ChannelState , StreamChat } from '../../src' ;
1413import { DEFAULT_QUERY_CHANNEL_MESSAGE_LIST_PAGE_SIZE } from '../../src/constants' ;
1514
16- const expect = chai . expect ;
15+ import { describe , beforeEach , it , expect } from 'vitest' ;
1716
1817describe ( 'Channel count unread' , function ( ) {
1918 let lastRead ;
@@ -845,77 +844,68 @@ describe('Uninitialized Channel', () => {
845844describe ( 'Channels - Constructor' , function ( ) {
846845 const client = new StreamChat ( 'key' , 'secret' ) ;
847846
848- it ( 'canonical form' , function ( done ) {
847+ it ( 'canonical form' , function ( ) {
849848 const channel = client . channel ( 'messaging' , '123' , { cool : true } ) ;
850849 expect ( channel . cid ) . to . eql ( 'messaging:123' ) ;
851850 expect ( channel . id ) . to . eql ( '123' ) ;
852851 expect ( channel . data ) . to . eql ( { cool : true } ) ;
853- done ( ) ;
854852 } ) ;
855853
856- it ( 'custom data merges to the right with current data' , function ( done ) {
854+ it ( 'custom data merges to the right with current data' , function ( ) {
857855 let channel = client . channel ( 'messaging' , 'brand_new_123' , { cool : true } ) ;
858856 expect ( channel . cid ) . to . eql ( 'messaging:brand_new_123' ) ;
859857 expect ( channel . id ) . to . eql ( 'brand_new_123' ) ;
860858 expect ( channel . data ) . to . eql ( { cool : true } ) ;
861859 channel = client . channel ( 'messaging' , 'brand_new_123' , { custom_cool : true } ) ;
862860 console . log ( channel . data ) ;
863861 expect ( channel . data ) . to . eql ( { cool : true , custom_cool : true } ) ;
864- done ( ) ;
865862 } ) ;
866863
867- it ( 'default options' , function ( done ) {
864+ it ( 'default options' , function ( ) {
868865 const channel = client . channel ( 'messaging' , '123' ) ;
869866 expect ( channel . cid ) . to . eql ( 'messaging:123' ) ;
870867 expect ( channel . id ) . to . eql ( '123' ) ;
871- done ( ) ;
872868 } ) ;
873869
874- it ( 'null ID no options' , function ( done ) {
870+ it ( 'null ID no options' , function ( ) {
875871 const channel = client . channel ( 'messaging' , null ) ;
876872 expect ( channel . id ) . to . eq ( undefined ) ;
877- done ( ) ;
878873 } ) ;
879874
880- it ( 'undefined ID no options' , function ( done ) {
875+ it ( 'undefined ID no options' , function ( ) {
881876 const channel = client . channel ( 'messaging' , undefined ) ;
882877 expect ( channel . id ) . to . eql ( undefined ) ;
883878 expect ( channel . data ) . to . eql ( { } ) ;
884- done ( ) ;
885879 } ) ;
886880
887- it ( 'short version with options' , function ( done ) {
881+ it ( 'short version with options' , function ( ) {
888882 const channel = client . channel ( 'messaging' , { members : [ 'tommaso' , 'thierry' ] } ) ;
889883 expect ( channel . data ) . to . eql ( { members : [ 'tommaso' , 'thierry' ] } ) ;
890884 expect ( channel . id ) . to . eql ( undefined ) ;
891- done ( ) ;
892885 } ) ;
893886
894- it ( 'null ID with options' , function ( done ) {
887+ it ( 'null ID with options' , function ( ) {
895888 const channel = client . channel ( 'messaging' , null , {
896889 members : [ 'tommaso' , 'thierry' ] ,
897890 } ) ;
898891 expect ( channel . data ) . to . eql ( { members : [ 'tommaso' , 'thierry' ] } ) ;
899892 expect ( channel . id ) . to . eql ( undefined ) ;
900- done ( ) ;
901893 } ) ;
902894
903- it ( 'empty ID with options' , function ( done ) {
895+ it ( 'empty ID with options' , function ( ) {
904896 const channel = client . channel ( 'messaging' , '' , {
905897 members : [ 'tommaso' , 'thierry' ] ,
906898 } ) ;
907899 expect ( channel . data ) . to . eql ( { members : [ 'tommaso' , 'thierry' ] } ) ;
908900 expect ( channel . id ) . to . eql ( undefined ) ;
909- done ( ) ;
910901 } ) ;
911902
912- it ( 'empty ID with options' , function ( done ) {
903+ it ( 'empty ID with options' , function ( ) {
913904 const channel = client . channel ( 'messaging' , undefined , {
914905 members : [ 'tommaso' , 'thierry' ] ,
915906 } ) ;
916907 expect ( channel . data ) . to . eql ( { members : [ 'tommaso' , 'thierry' ] } ) ;
917908 expect ( channel . id ) . to . eql ( undefined ) ;
918- done ( ) ;
919909 } ) ;
920910} ) ;
921911
@@ -1242,13 +1232,10 @@ describe('Channel search', async () => {
12421232 await channel . search ( 'query' , { sort : [ { custom_field : - 1 } ] } ) ;
12431233 } ) ;
12441234 it ( 'sorting and offset works' , async ( ) => {
1245- await expect ( channel . search ( 'query' , { offset : 1 , sort : [ { custom_field : - 1 } ] } ) ) . to
1246- . be . fulfilled ;
1235+ await expect ( channel . search ( 'query' , { offset : 1 , sort : [ { custom_field : - 1 } ] } ) ) ;
12471236 } ) ;
12481237 it ( 'next and offset fails' , async ( ) => {
1249- await expect ( channel . search ( 'query' , { offset : 1 , next : 'next' } ) ) . to . be . rejectedWith (
1250- Error ,
1251- ) ;
1238+ await expect ( channel . search ( 'query' , { offset : 1 , next : 'next' } ) ) . rejects . toThrow ( ) ;
12521239 } ) ;
12531240} ) ;
12541241
0 commit comments