Skip to content

Commit 01cef60

Browse files
committed
Inserted chai testing suite
2 parents ce64c8f + d0d0ed0 commit 01cef60

File tree

7 files changed

+1408
-238
lines changed

7 files changed

+1408
-238
lines changed

.test/suite/extensionRuns.ts

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,55 @@
1-
// These tests are run using the "npm run parseUnitTest" command in package.json
1+
/**
2+
* @author : Shahrukh Khan, Roseanne Demasco, Steve Canavan
3+
* @functionality : Implementing chai tests for throttle functionality
4+
* @changelog : ##WHOEVER CHANGES THE FILE, date, details
5+
* * */
26

37
import { expect } from 'chai';
4-
import 'mocha';
5-
import 'path';
68

79
const displayOutputMessage = require('../../src/modules/client/displayOutputMessage');
8-
const getRootProjectDir = require('../../src/modules/client/getRootProjectDir');
9-
const onSaveCb = require('../../src/modules/client/onSaveCb');
1010
const sendgRPCRequest = require('../../src/modules/client/sendgRPCRequest');
11+
const throttle = require('../../src/modules/client/throttleOnSave');
1112

1213
describe('Testing all functions', function () {
1314
describe('Testing displayOutputMessage', function () {
1415
it('should be a function', function () {
1516
expect(typeof displayOutputMessage).to.equal('function');
1617
});
17-
it('should fail on uneven number of brackets', function () {
18-
const result = displayOutputMessage('{');
19-
expect(result.toString()).to.equal('Error: The following character makes the gRPC request unbalanced: {\nThe portion of the gRPC request that ran before the unbalance was detected was:\n{\n\n');
18+
});
19+
describe('Testing sendgRPCRequest', function () {
20+
it('should be a function', function () {
21+
expect(typeof sendgRPCRequest).to.equal('function');
22+
});
23+
});
24+
describe('Testing throttle', function () {
25+
it('should be a function', function () {
26+
expect(typeof throttle).to.equal('function');
27+
});
28+
const add = (num1: number, num2: number): number => num1 + num2;
29+
const throttledAdd = throttle(add, 1000);
30+
it('should return a function', function () {
31+
expect(typeof throttledAdd).to.equal('function');
2032
});
21-
it('should fail on wrong brackets', function () {
22-
const result = displayOutputMessage('{)})');
23-
expect(result.toString()).to.equal('Error: The following character makes the gRPC request unbalanced: {\nThe portion of the query that ran before the unbalance was detected was:\n{\n\n');
33+
describe('Testing function returned (throttledAdd) from throttle', function () {
34+
it('should invoke add the first time', function () {
35+
const firstResult = throttledAdd(1, 2);
36+
expect(firstResult).not.to.equal(undefined);
37+
});
38+
it('should return undefined if immediately invoked again', function () {
39+
const secondResult = throttledAdd(2, 3);
40+
expect(secondResult).to.equal(undefined);
41+
});
42+
it('should invoke add after designated delay', function (done) {
43+
setTimeout(() => {
44+
try {
45+
const secondResult = throttledAdd(2, 3);
46+
expect(secondResult).not.to.equal(undefined);
47+
done();
48+
} catch (e) {
49+
done(e);
50+
}
51+
}, 1001);
52+
});
2453
});
25-
// describe('Testing getRootProjectDir', function () {
26-
// it('should be a function', function () {
27-
// expect(typeof getRootProjectDir).to.equal('function');
28-
// });
29-
// });
30-
// describe('Testing onSaveCb', function () {
31-
// it('should be a function', function () {
32-
// expect(typeof onSaveCb).to.equal('function');
33-
// });
34-
// });
35-
// describe('Testing sendgRPCRequest', function () {
36-
// it('should be a function', function () {
37-
// expect(typeof sendgRPCRequest).to.equal('function');
38-
// // });
3954
});
4055
});

DOCUMENTATION/images/icon.png

10.3 KB
Loading

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ A Visual Studio Code extension that provides gRPC Remote Procedure Call (gRPC) A
2222

2323
### **Installation**
2424

25-
tropicRPC can be installed from the VS Code Extensions Marketplace [here]().
25+
tropicRPC can be installed from the VS Code Extensions Marketplace [here](https://marketplace.visualstudio.com/items?itemName=tropicRPC.tropicrpc).
2626

2727
### **Setting up the config file**
2828

0 commit comments

Comments
 (0)