1- import { describe , it , expect } from "vitest" ;
1+ import { describe , it , expect , beforeEach } from "vitest" ;
22import { setupServer } from "@ldo/test-solid-server" ;
33import { testFiles } from "./testFiles.helper" ;
44import path from "path" ;
55import { fileURLToPath } from "url" ;
6+ import { ConnectedLdoDataset , createConnectedLdoDataset } from "@ldo/connected" ;
7+ import { solidConnectedPlugin , SolidConnectedPlugin } from "@ldo/connected-solid" ;
8+ import { Chat } from "../src" ;
9+ import { ChatMessageShape , ChatShape } from "../src/.ldo/longChat.typings" ;
610
711const __filename = fileURLToPath ( import . meta. url ) ;
812const __dirname = path . dirname ( __filename ) ;
913
14+ const BASE_URI = "http://localhost:3003/example/" ;
15+ const SAMPLE_CHAT_1_CONTAINER_URI = `${ BASE_URI } sample-chat-1/` ;
16+ const SAMPLE_CHAT_1_INDEX_URI = `${ SAMPLE_CHAT_1_CONTAINER_URI } index.ttl` ;
17+ const SAMPLE_CHAT_1_INDEX_INFO : ChatShape = {
18+ "@id" : `${ SAMPLE_CHAT_1_INDEX_URI } #this` ,
19+ "type" : { "@id" : "LongChat" } ,
20+ author : { "@id" : "http://example.com/profile/card#me" } ,
21+ created : "2023-11-25T20:58:21.266Z" ,
22+ title : "Scatterverse "
23+ }
24+ const SAMPLE_CHAT_1_MESSAGE_RESOURCE_1_URI = `${ SAMPLE_CHAT_1_CONTAINER_URI } 2023/11/25/index.ttl` ;
25+ const SAMPLE_CHAT_1_MESSAGE_RESOURCE_1__MESSAGES : ChatMessageShape [ ] = [
26+ {
27+ "@id" : `${ SAMPLE_CHAT_1_MESSAGE_RESOURCE_1_URI } #6def4609-3a97-44a7-ac5f-7cb8d2c5d2e0` ,
28+ created2 : "2023-11-25T20:58:26.606Z" ,
29+ content : 'thmooove created "Scatterverse "' ,
30+ maker : { "@id" : "http://example.com/profile/card#me" }
31+ } ,
32+ {
33+ "@id" : `${ SAMPLE_CHAT_1_MESSAGE_RESOURCE_1_URI } #bf343557-915b-4302-8377-d6e98d0963fc` ,
34+ created2 : "2023-11-25T21:34:17.354Z" ,
35+ content : "If youre reading this, ily " ,
36+ maker : { "@id" : "http://example.com/profile/card#me" }
37+ } ,
38+ {
39+ "@id" : `${ SAMPLE_CHAT_1_MESSAGE_RESOURCE_1_URI } #c22cf637-7a5e-4c1f-b83d-74eeb6638657` ,
40+ created2 : "2023-11-25T20:59:49.014Z" ,
41+ content : "How many people actively use this?" ,
42+ maker : { "@id" : "http://example.com/profile/card#me" }
43+ } ,
44+ {
45+ "@id" : `${ SAMPLE_CHAT_1_MESSAGE_RESOURCE_1_URI } #cb1a3293-d890-4d16-b462-ee60fceb3bc2` ,
46+ created2 : "2023-11-25T20:58:43.163Z" ,
47+ content : "this is pretty clean " ,
48+ maker : { "@id" : "http://example.com/profile/card#me" }
49+ }
50+ ]
51+ const SAMPLE_CHAT_1_MESSAGE_RESOURCE_2_URI = `${ SAMPLE_CHAT_1_CONTAINER_URI } 2024/11/27/index.ttl` ;
52+ const SAMPLE_CHAT_1_MESSAGE_RESOURCE_2_MESSAGES = [
53+ {
54+ "@id" : `${ SAMPLE_CHAT_1_MESSAGE_RESOURCE_2_URI } #d4d513fa-23e0-4726-89aa-f5e433bb6c58` ,
55+ created2 : "2024-11-07T08:52:38.447Z" ,
56+ content : "Hi" ,
57+ maker : { "@id" : "https://juliusisnya.solidcommunity.net/profile/card#me" }
58+ }
59+ ]
60+
1061describe ( "integration" , ( ) => {
1162 const s = setupServer (
1263 3003 ,
@@ -18,7 +69,19 @@ describe("integration", () => {
1869 true
1970 ) ;
2071
21- it ( "trivial" , ( ) => {
22- expect ( true ) . toBe ( true ) ;
72+ let dataset : ConnectedLdoDataset < SolidConnectedPlugin [ ] > ;
73+ let sample1Chat : Chat ;
74+
75+ beforeEach ( ( ) => {
76+ dataset = createConnectedLdoDataset ( [ solidConnectedPlugin ] ) ;
77+ sample1Chat = new Chat ( SAMPLE_CHAT_1_CONTAINER_URI , dataset ) ;
78+ } )
79+
80+ it ( "Fetches chat information" , async ( ) => {
81+ const chatInfo = await sample1Chat . getChatInfo ( ) ;
82+ expect ( chatInfo [ "@id" ] ) . toBe ( SAMPLE_CHAT_1_INDEX_INFO [ "@id" ] ) ;
83+ expect ( chatInfo . author ) . toBe ( SAMPLE_CHAT_1_INDEX_INFO . author ) ;
84+ expect ( chatInfo . created ) . toBe ( SAMPLE_CHAT_1_INDEX_INFO . created ) ;
85+ expect ( chatInfo . title ) . toBe ( SAMPLE_CHAT_1_INDEX_INFO . title ) ;
2386 } ) ;
2487} ) ;
0 commit comments