Skip to content

Update dependencies & Remove old code & Prepare patch 6.0.1 #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reactivexcomponent.js",
"version": "6.0.0",
"version": "6.0.1",
"description": "Javascript reactive client API for XComponent",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -17,7 +17,9 @@
"lint": "tslint -c tslint.json 'src/**/*.{ts,tsx}'"
},
"jest": {
"setupTestFrameworkScriptFile": "<rootDir>/config/jest/setup.js",
"setupFilesAfterEnv": [
"<rootDir>/config/jest/setup.js"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}"
],
Expand Down Expand Up @@ -66,8 +68,8 @@
"homepage": "https://github.com/xcomponent/ReactiveXComponent.js",
"dependencies": {
"@types/es6-shim": "^0.31.32",
"@types/jest": "^23.0.0",
"@types/node": "^10.0.0",
"@types/jest": "^24.0.0",
"@types/node": "^11.0.0",
"@types/pako": "^1.0.0",
"@types/rx": "^4.1.1",
"@types/xml2js": "0.4.3",
Expand All @@ -85,14 +87,14 @@
"clean-webpack-plugin": "^1.0.0",
"compression": "^1.6.2",
"husky": "^1.0.0-rc.13",
"jest": "^23.0.0",
"jest-cli": "^23.0.0",
"jest": "^24.0.0",
"jest-cli": "^24.0.0",
"json-loader": "^0.5.4",
"mock-socket": "^8.0.1",
"prettier": "^1.14.0",
"pretty-quick": "^1.6.0",
"source-map-loader": "^0.2.0",
"ts-jest": "^23.0.0",
"ts-jest": "^24.0.0",
"ts-loader": "^5.0.0",
"ts-mockito": "^2.3.0",
"tslint": "^5.0.0",
Expand Down
23 changes: 8 additions & 15 deletions src/communication/WebSocketConnection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ describe('Test Connection module', function() {
mockServer.close(undefined);
});
new XComponent()
.connect(
serverUrl,
new FakeErrorHandler(err => done())
)
.connect(serverUrl, new FakeErrorHandler(err => done()))
.then(connection => {
connection.createSession(xcApiFileName);
})
Expand All @@ -108,14 +105,9 @@ describe('Test Connection module', function() {
// tslint:disable-next-line:typedef
it('given an unknown server url, should call the error listener', function(done) {
let serverUrl = 'wss://wrongServerUrl';
new XComponent()
.connect(
serverUrl,
new FakeErrorHandler(err => done())
)
.catch(error => {
/**/
});
new XComponent().connect(serverUrl, new FakeErrorHandler(err => done())).catch(error => {
/**/
});
});
});

Expand All @@ -130,9 +122,10 @@ describe('Test Connection module', function() {
new XComponent().connect(serverUrl).then(connection => {
let apiName = 'unknownApi';
connection.getCompositionModel(apiName).then(compositionModel => {
expect(compositionModel.projectName).not.toBe(null);
expect(compositionModel.components).not.toBe(null);
expect(compositionModel.composition).not.toBe(null);
expect(compositionModel).not.toBe(undefined);
expect(compositionModel!.projectName).not.toBe(null);
expect(compositionModel!.components).not.toBe(null);
expect(compositionModel!.composition).not.toBe(null);
serverMock.stop(done);
});
});
Expand Down
10 changes: 6 additions & 4 deletions src/communication/WebSocketSession.test.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
import { WebSocket } from 'mock-socket';
import { WebSocketSession } from '../../src/communication/WebSocketSession';

describe('Test xcSession module', function() {
describe('Add private topic / SetPrivateTopic', function() {
it('should not trigger server subscription on undefined topic', () => {
// tslint:disable-next-line:no-any
let mockWebSocket: any = {};
// tslint:disable-next-line:no-any
let apiConfiguration: any = {};
mockWebSocket.send = jest.fn();
mockWebSocket.getObservable = jest.fn();
const session = new WebSocketSession(mockWebSocket, null);
const session = new WebSocketSession(mockWebSocket, apiConfiguration);
session.privateTopics.setDefaultPublisherTopic(undefined);
session.privateTopics.addSubscriberTopic(undefined);
expect(mockWebSocket.send).toHaveBeenCalledTimes(1);
});

it('Should add and set correctly the given private topics', () => {
const serverUrl = 'wss:\\serverUrl';
// tslint:disable-next-line:no-any
let mockWebSocket: any = {};
// tslint:disable-next-line:no-any
let apiConfiguration: any = {};
mockWebSocket.send = jest.fn();
mockWebSocket.getObservable = jest.fn();
const session = new WebSocketSession(mockWebSocket, null);
const session = new WebSocketSession(mockWebSocket, apiConfiguration);
const privateTopic = 'privateTopic';
const anotherPrivateTopic = 'anotherPrivateTopic';
session.privateTopics.setDefaultPublisherTopic(privateTopic);
Expand Down
2 changes: 1 addition & 1 deletion src/communication/WebSocketSubscriber.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('Test xcWebSocketSubscriber module', function() {
// tslint:disable-next-line:no-any
mockServer.on('connection', function(server: any) {
let n = -3;
let topic: string = undefined;
let topic: string = '';

// tslint:disable-next-line:no-any
server.on('message', function(message: any) {
Expand Down
3 changes: 2 additions & 1 deletion src/configuration/apiConfiguration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ test('GetComponentCode throws exception when using an unkonwn component name', (

test('GetStateMachineCode throws exception when using an unkonwn component name', () => {
const componentName = 'random component';
const stateMachineName = 'random state machine';
const messageError = "Component '" + componentName + "' not found";
return parse()
.then(config => {
config.getStateMachineCode(componentName, null);
config.getStateMachineCode(componentName, stateMachineName);
fail();
})
.catch(e => expect(e.message).toBe(messageError));
Expand Down
9 changes: 2 additions & 7 deletions src/interfaces/Connection.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { CompositionModel } from '../communication/xcomponentMessages';
import { Session } from './Session';
import { ErrorListener } from './ErrorListener';

export interface Connection {
getXcApiList(): Promise<Array<string>>;
getCompositionModel(xcApiName: string): Promise<CompositionModel | undefined>;
createSession(xcApiFileName: string, errotListener?: ErrorListener): Promise<Session>;
createAuthenticatedSession(
xcApiFileName: string,
sessionData: string,
errorListener?: ErrorListener
): Promise<Session>;
createSession(xcApiFileName: string): Promise<Session>;
createAuthenticatedSession(xcApiFileName: string, sessionData: string): Promise<Session>;
dispose(): void;
}
4 changes: 2 additions & 2 deletions src/interfaces/PrivateTopics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class PrivateTopics {
this.addSubscriberTopic(this.defaultPublisherTopic);
}

public setDefaultPublisherTopic(newDefaultPublisherTopic: string): void {
public setDefaultPublisherTopic(newDefaultPublisherTopic: string | undefined): void {
if (newDefaultPublisherTopic) {
this.addSubscriberTopic(newDefaultPublisherTopic);
this.removeSubscriberTopic(this.defaultPublisherTopic);
Expand All @@ -23,7 +23,7 @@ export class PrivateTopics {
return this.defaultPublisherTopic;
}

public addSubscriberTopic(privateTopic: string): void {
public addSubscriberTopic(privateTopic: string | undefined): void {
if (privateTopic && this.subscriberTopics.indexOf(privateTopic) === -1) {
this.subscriber.sendSubscribeRequestToTopic(privateTopic, Kinds.Private);
this.subscriberTopics.push(privateTopic);
Expand Down
Loading