Skip to content

Commit 3d1480f

Browse files
NHDalydavidwzhao
authored andcommitted
Make javascript ClientSDK tests agnostic to number of standard libraries.
Also add instructions to README for how to run the tests
1 parent 770bdfb commit 3d1480f

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ module: {
9393
}
9494
```
9595

96+
### Running Tests
97+
98+
To run the tests, cd into one of the directories below (e.g. `client`), and then after
99+
running `npm install` per above, you can run:
100+
101+
```shell
102+
npm run test
103+
```
104+
96105
## Getting Started
97106

98107
Please follow the [installation](#installation) instruction and execute the following JS code:

client/test/sdk/RelAPIMixin.test.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const fs = require('fs').promises;
33
const os = require('os');
44
import LocalConnection from '../../src/sdk/LocalConnection.js';
55

6-
const defaultSources = ["alglib", "intrinsics", "stdlib", "ml"];
76
const incrementQuery =
87
`
98
def insert[:x] = x + 1
@@ -75,13 +74,13 @@ describe('RelAPIMixin', () => {
7574
const dbname = createUniqueName('db');
7675
initializeDatabase(dbname);
7776

78-
it(`listSources for ${dbname} should include the keys [${defaultSources.join()}]`, () => {
77+
it(`listSources for ${dbname} should include at least one file`, () => {
7978
return lc.listSources(dbname).then(res => {
8079
assert.notStrictEqual(res.result.actions, null);
8180
assert.notStrictEqual(res.result.actions[0], null);
8281
assert.notStrictEqual(res.result.actions[0].result, null);
8382
assert.notStrictEqual(res.result.actions[0].result.sources, null);
84-
assert(setsEqual(new Set(res.result.actions[0].result.sources.map(x => x.name)), new Set(defaultSources)));
83+
assert.notStrictEqual(res.result.actions[0].result.sources.length, 0);
8584
});
8685
}).timeout(60000);
8786
it(`should install 'def foo = {(1,);(2,);(3,)}' without error into test-1.delve via #installSource`, () => {
@@ -94,9 +93,9 @@ describe('RelAPIMixin', () => {
9493
return lc.listSources(dbname).then(res => {
9594
assert.strictEqual(res.error, null);
9695
assert.strictEqual(res.result.problems.length, 0);
97-
assert.strictEqual(res.result.actions[0].result.sources.length, defaultSources.length + 1);
96+
assert.notStrictEqual(res.result.actions[0].result.sources.length, 0);
9897
let match = false;
99-
for (let i = 0; i < (defaultSources.length + 1); i++) {
98+
for (let i = 0; i < (res.result.actions[0].result.sources.length); i++) {
10099
if (res.result.actions[0].result.sources[i].name === 'test-1.delve') {
101100
match = true;
102101
}
@@ -117,9 +116,16 @@ describe('RelAPIMixin', () => {
117116
assert.strictEqual(res.result.problems.length, 0);
118117
});
119118
}).timeout(60000);
120-
it(`should be only ${defaultSources.length} sources installed now`, () => {
119+
it(`test-1.delve should no longer be installed`, () => {
121120
return lc.listSources(dbname).then(res => {
122-
assert.strictEqual(res.result.actions[0].result.sources.length, defaultSources.length);
121+
assert.notStrictEqual(res.result.actions[0].result.sources.length, 0);
122+
let match = false;
123+
for (let i = 0; i < (res.result.actions[0].result.sources.length); i++) {
124+
if (res.result.actions[0].result.sources[i].name === 'test-1.delve') {
125+
match = true;
126+
}
127+
}
128+
assert(!match);
123129
});
124130
}).timeout(60000);
125131
});
@@ -471,9 +477,9 @@ describe('RelAPIMixin', () => {
471477
return lc.listSources(dbname).then(res => {
472478
assert.strictEqual(res.error, null);
473479
assert.strictEqual(res.result.problems.length, 0);
474-
assert.strictEqual(res.result.actions[0].result.sources.length, defaultSources.length + 1);
480+
assert.notStrictEqual(res.result.actions[0].result.sources.length, 0);
475481
let match = false;
476-
for (let i = 0; i < (defaultSources.length + 1); i++) {
482+
for (let i = 0; i < (res.result.actions[0].result.sources.length); i++) {
477483
if (res.result.actions[0].result.sources[i].name === 'test-1.delve') {
478484
match = true;
479485
}
@@ -491,9 +497,9 @@ describe('RelAPIMixin', () => {
491497
return lc.listSources(uniqueCloneName).then(res => {
492498
assert.strictEqual(res.error, null);
493499
assert.strictEqual(res.result.problems.length, 0);
494-
assert.strictEqual(res.result.actions[0].result.sources.length, defaultSources.length + 1);
500+
assert.notStrictEqual(res.result.actions[0].result.sources.length, 0);
495501
let match = false;
496-
for (let i = 0; i < (defaultSources.length + 1); i++) {
502+
for (let i = 0; i < (res.result.actions[0].result.sources.length); i++) {
497503
if (res.result.actions[0].result.sources[i].name === 'test-1.delve') {
498504
match = true;
499505
}
@@ -518,9 +524,9 @@ describe('RelAPIMixin', () => {
518524
return lc.listSources(uniqueCloneName).then(res => {
519525
assert.strictEqual(res.error, null);
520526
assert.strictEqual(res.result.problems.length, 0);
521-
assert.strictEqual(res.result.actions[0].result.sources.length, defaultSources.length + 1);
527+
assert.notStrictEqual(res.result.actions[0].result.sources.length, 0);
522528
let match = false;
523-
for (let i = 0; i < (defaultSources.length + 1); i++) {
529+
for (let i = 0; i < (res.result.actions[0].result.sources.length); i++) {
524530
if (res.result.actions[0].result.sources[i].name === 'test-1.delve') {
525531
match = true;
526532
}

0 commit comments

Comments
 (0)