@@ -12,76 +12,76 @@ server using the command 'docker compose-up'. This will spin up a ksqlDB server
12
12
// Once the ksqlDB server is running, tests can be run with terminal line: (npm test)
13
13
14
14
describe ( '--Integration Tests--' , ( ) => {
15
- /* describe('--Method Tests--', () => {
16
- beforeAll((done) => {
17
- client = new ksqljs({ ksqldbURL: 'http://localhost:8088' });
18
- done();
19
- });
15
+ // describe('--Method Tests--', () => {
16
+ // beforeAll((done) => {
17
+ // client = new ksqljs({ ksqldbURL: 'http://localhost:8088' });
18
+ // done();
19
+ // });
20
20
21
- afterAll(async () => {
22
- await client.ksql('DROP STREAM IF EXISTS TESTJESTSTREAM DELETE TOPIC;');
23
- })
21
+ // afterAll(async () => {
22
+ // await client.ksql('DROP STREAM IF EXISTS TESTJESTSTREAM DELETE TOPIC;');
23
+ // })
24
24
25
- it('.createStream properly creates a stream', async () => {
26
- const result = await client.createStream('TESTJESTSTREAM', ['name VARCHAR', 'email varchar', 'age INTEGER'], 'testJestTopic', 'json', 1);
27
- const streams = await client.ksql('LIST STREAMS;');
28
- const allStreams = streams.streams;
29
- let streamExists = false;
30
- for (let i = 0; i < allStreams.length; i++) {
31
- if (allStreams[i].name === "TESTJESTSTREAM") {
32
- streamExists = true;
33
- break;
34
- }
35
- }
36
- expect(streamExists).toEqual(true);
37
- })
25
+ // it('.createStream properly creates a stream', async () => {
26
+ // const result = await client.createStream('TESTJESTSTREAM', ['name VARCHAR', 'email varchar', 'age INTEGER'], 'testJestTopic', 'json', 1);
27
+ // const streams = await client.ksql('LIST STREAMS;');
28
+ // const allStreams = streams.streams;
29
+ // let streamExists = false;
30
+ // for (let i = 0; i < allStreams.length; i++) {
31
+ // if (allStreams[i].name === "TESTJESTSTREAM") {
32
+ // streamExists = true;
33
+ // break;
34
+ // }
35
+ // }
36
+ // expect(streamExists).toEqual(true);
37
+ // })
38
38
39
- it('.push properly creates a push query', () => {
40
- let pushActive = false;
41
- client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 1;', async (data) => {
42
- if (JSON.parse(data).queryId) {
43
- pushActive = true;
44
- }
45
- expect(pushActive).toEqual(true)
46
- });
47
- })
39
+ // it('.push properly creates a push query', () => {
40
+ // let pushActive = false;
41
+ // client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 1;', async (data) => {
42
+ // if (JSON.parse(data).queryId) {
43
+ // pushActive = true;
44
+ // }
45
+ // expect(pushActive).toEqual(true)
46
+ // });
47
+ // })
48
48
49
- it('.terminate properly terminates a push query', () => {
50
- client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 3;', async (data) => {
51
- const terminateRes = await client.terminate(JSON.parse(data).queryId);
52
- expect(terminateRes.wasTerminated).toEqual(true);
53
- })
54
- })
49
+ // it('.terminate properly terminates a push query', () => {
50
+ // client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 3;', async (data) => {
51
+ // const terminateRes = await client.terminate(JSON.parse(data).queryId);
52
+ // expect(terminateRes.wasTerminated).toEqual(true);
53
+ // })
54
+ // })
55
55
56
- it('.insertStream properly inserts a row into a stream', async () => {
57
- const response = await client.insertStream('TESTJESTSTREAM', [
58
- { "name": "stab-rabbit", "email": "123@mail .com", "age": 100 }
59
- ]);
60
- console.log(response);
61
- const data = [];
62
- await client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES;', async (chunk) => {
63
- data.push(JSON.parse(chunk));
64
- if (data[1]) {
65
- client.terminate(data[0].queryId);
66
- expect(data[1]).toEqual(["stab-rabbit", "123@mail .com", 100])
67
- }
68
- });
69
- })
56
+ // it('.insertStream properly inserts a row into a stream', async () => {
57
+ // const response = await client.insertStream('TESTJESTSTREAM', [
58
+ // { "name": "stab-rabbit", "email": "123@mail.com", "age": 100 }
59
+ // ]);
60
+ // console.log(response);
61
+ // const data = [];
62
+ // await client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES;', async (chunk) => {
63
+ // data.push(JSON.parse(chunk));
64
+ // if (data[1]) {
65
+ // client.terminate(data[0].queryId);
66
+ // expect(data[1]).toEqual(["stab-rabbit", "123@mail.com", 100])
67
+ // }
68
+ // });
69
+ // })
70
70
71
- it('.pull receives the correct data from a pull query', async () => {
72
- const pullData = await client.pull("SELECT * FROM TESTJESTSTREAM;");
73
- console.log(pullData[1]);
74
- expect(pullData[1]).toEqual(["stab-rabbit", "123@mail .com", 100]);
75
- })
71
+ // it('.pull receives the correct data from a pull query', async () => {
72
+ // const pullData = await client.pull("SELECT * FROM TESTJESTSTREAM;");
73
+ // console.log(pullData[1]);
74
+ // expect(pullData[1]).toEqual(["stab-rabbit", "123@mail.com", 100]);
75
+ // })
76
76
77
- it('.pullFromTo receives all the data', async () => {
78
- const pullData = await client.pull("SELECT * FROM TESTJESTSTREAM;");
79
- const data = await client.pullFromTo('TESTJESTSTREAM', 'America/Los_Angeles', ['2022-01-01', '00', '00', '00']);
80
- const expectPullData = pullData[1];
81
- const expectData = data[0].slice(0, 3);
82
- expect(expectPullData).toEqual(expectData);
83
- })
84
- }) */
77
+ // it('.pullFromTo receives all the data', async () => {
78
+ // const pullData = await client.pull("SELECT * FROM TESTJESTSTREAM;");
79
+ // const data = await client.pullFromTo('TESTJESTSTREAM', 'America/Los_Angeles', ['2022-01-01', '00', '00', '00']);
80
+ // const expectPullData = pullData[1];
81
+ // const expectData = data[0].slice(0, 3);
82
+ // expect(expectPullData).toEqual(expectData);
83
+ // })
84
+ // })
85
85
86
86
describe ( '--Materialized Views Test--' , ( ) => {
87
87
beforeAll ( async ( ) => {
@@ -106,24 +106,23 @@ describe('--Integration Tests--', () => {
106
106
expect ( tableCheck ) . toEqual ( true ) ;
107
107
108
108
} )
109
- // it('materialized table view updates with source stream', async () => {
110
- // let rowCheck = false;
111
- // // push query for the table
112
- // await client.push('SELECT * FROM TABLEOFSTREAM EMIT CHANGES LIMIT 1;', async (data) => {
113
- // if (Array.isArray(JSON.parse(data))){
114
- // console.log(JSON.parse(data))
115
- // if (JSON.parse(data)[0] === "firstTester" && JSON.parse(data)[1] === 25 && JSON.parse(data)[2] === "Seattle" && JSON.parse(data)[3] === 130){
116
- // rowCheck = true;
117
- // }
118
- // expect(rowCheck).toEqual(true);
119
- // }
120
- // })
121
- // await client.insertStream('TESTJESTSTREAM', [{"NAME":"firstTester", "AGE":25, "LOCATION": "Seattle", "WEIGHT": 130}]);
122
-
123
- // })
109
+ it ( 'materialized table view updates with source stream' , async ( ) => {
110
+ let rowCheck = false ;
111
+ // push query for the table
112
+ await client . push ( 'SELECT * FROM TABLEOFSTREAM EMIT CHANGES LIMIT 1;' , async ( data ) => {
113
+ if ( Array . isArray ( JSON . parse ( data ) ) ) {
114
+ console . log ( 'PARSED DATA HERE' , JSON . parse ( data ) )
115
+ if ( JSON . parse ( data ) [ 0 ] === "firstTester" && JSON . parse ( data ) [ 1 ] === 25 && JSON . parse ( data ) [ 2 ] === "Seattle" && JSON . parse ( data ) [ 3 ] === 130 ) {
116
+ rowCheck = true ;
117
+ }
118
+ }
119
+ } )
120
+ await client . insertStream ( 'TESTJESTSTREAM' , [ { "NAME" :"firstTester" , "AGE" :25 , "LOCATION" : "Seattle" , "WEIGHT" : 130 } ] ) ;
121
+ await waitFor ( ( ) => expect ( rowCheck ) . toEqual ( true ) ) ;
122
+ } )
124
123
} )
125
124
126
- /* describe('--Health Tests--', () => {
125
+ /* describe('--Health Tests--', () => {
127
126
beforeAll((done) => {
128
127
client = new ksqljs({ ksqldbURL: 'http://localhost:8088' });
129
128
done();
0 commit comments