Skip to content

Commit 26c6717

Browse files
Merge pull request #32 from oslabs-beta/mx/jestTestsBranch
Mx/jest tests branch
2 parents b1392a8 + 60d5923 commit 26c6717

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

__tests__/integrationtests.js

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ describe('--Integration Tests--', () => {
2525
})
2626

2727
it('.createStream properly creates a stream', async () => {
28+
await client.ksql('DROP STREAM IF EXISTS TESTJESTSTREAM DELETE TOPIC;')
2829
const result = await client.createStream('TESTJESTSTREAM', ['name VARCHAR', 'email varchar', 'age INTEGER'], 'testJestTopic', 'json', 1);
2930
const streams = await client.ksql('LIST STREAMS;');
3031
const allStreams = streams.streams;
@@ -56,17 +57,19 @@ describe('--Integration Tests--', () => {
5657
})
5758

5859
it('.insertStream properly inserts a row into a stream', async () => {
59-
const response = await client.insertStream('TESTJESTSTREAM', [
60-
{ "name": "stab-rabbit", "email": "123@mail.com", "age": 100 }
61-
]);
60+
6261
const data = [];
6362
await client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES;', async (chunk) => {
6463
data.push(JSON.parse(chunk));
64+
console.log(data);
6565
if (data[1]) {
6666
client.terminate(data[0].queryId);
6767
expect(data[1]).toEqual(["stab-rabbit", "123@mail.com", 100])
6868
}
6969
});
70+
const response = await client.insertStream('TESTJESTSTREAM', [
71+
{ "name": "stab-rabbit", "email": "123@mail.com", "age": 100 }
72+
]);
7073
})
7174

7275
it('.pull receives the correct data from a pull query', async () => {
@@ -98,24 +101,24 @@ describe('--Integration Tests--', () => {
98101
beforeAll(async () => {
99102
// await client.ksql('DROP STREAM IF EXISTS testAsStream;')
100103
// await client.ksql('DROP STREAM IF EXISTS newTestStream DELETE TOPIC;');
101-
104+
102105
// await client.createStream('newTestStream', ['name VARCHAR', 'age INTEGER'], 'newTestTopic', 'json', 1);
103106
testAsQueryId = await client.createStreamAs('testAsStream', ['name', 'age'], 'newTestStream', {
104107
kafka_topic: 'newTestTopic',
105108
value_format: 'json',
106109
partitions: 1
107-
}, 'age > 50');
110+
}, 'age > 50');
108111
})
109-
112+
110113
afterAll(async () => {
111114
await client.ksql('DROP STREAM IF EXISTS testAsStream;')
112115
// await client.ksql('DROP STREAM IF EXISTS newTestStream DELETE TOPIC;');
113116
})
114-
117+
115118
it('creates materialized stream', async () => {
116119
let streamFound = false;
117-
const {streams} = await client.ksql('LIST STREAMS;');
118-
120+
const { streams } = await client.ksql('LIST STREAMS;');
121+
119122
for (let i = 0; i < streams.length; i++) {
120123
if (streams[i].name, streams[i].name === 'TESTASSTREAM') {
121124
streamFound = true;
@@ -128,8 +131,8 @@ describe('--Integration Tests--', () => {
128131

129132

130133
describe('--Materialized Tables Tests--', () => {
131-
beforeAll( async () => {
132-
await client.createTableAs('testAsTable', 'newTestStream', ['name', 'LATEST_BY_OFFSET(age) AS recentAge'], {topic:'newTestTopic'},{WHERE: 'age >= 21', GROUP_BY: 'name'});
134+
beforeAll(async () => {
135+
await client.createTableAs('testAsTable', 'newTestStream', ['name', 'LATEST_BY_OFFSET(age) AS recentAge'], { topic: 'newTestTopic' }, { WHERE: 'age >= 21', GROUP_BY: 'name' });
133136
});
134137
afterAll(async () => {
135138
await client.ksql('DROP TABLE IF EXISTS testAsTable;');
@@ -138,29 +141,16 @@ describe('--Integration Tests--', () => {
138141
})
139142

140143
it('creates a materialized table view of a stream', async () => {
141-
const {tables} = await client.ksql('LIST TABLES;');
144+
const { tables } = await client.ksql('LIST TABLES;');
142145
let tableFound = false;
143-
for (let i = 0; i < tables.length; i++){
146+
for (let i = 0; i < tables.length; i++) {
144147
if (tables[i].name === 'TESTASTABLE') {
145148
tableFound = true;
146149
break;
147150
}
148151
}
149152
expect(tableFound).toEqual(true);
150153
})
151-
152-
// it('receives updates from source stream', async () => {
153-
// let rowReceived = false;
154-
// await client.push('SELECT * FROM testAsTable EMIT CHANGES LIMIT 1;', async (data) => {
155-
// if (Array.isArray(JSON.parse(data))){
156-
// if (JSON.parse(data)[0] === "firstTester" && JSON.parse(data)[1] === 25){
157-
// rowReceived = true;
158-
// }
159-
// }
160-
// })
161-
// await client.insertStream('NEWTESTSTREAM', [{"NAME":"firstTester", "AGE":25}]);
162-
// await waitForExpect(() => expect(rowReceived).toEqual(true))
163-
// })
164154
})
165155
})
166156
})

0 commit comments

Comments
 (0)