Skip to content

Commit

Permalink
1.0.0-rc9
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrdjan committed May 24, 2019
1 parent dbc1331 commit 779c3a9
Show file tree
Hide file tree
Showing 12 changed files with 1,840 additions and 1,591 deletions.
26 changes: 26 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# utf-8
charset = utf-8

# trim trailing whitespace
trim_trailing_whitespace = true

[**.js]
indent_style = space
indent_size = 4

[**.html, *.py]
indent_style = space
indent_size = 4

[*.md]
trim_trailing_whitespace = false
10 changes: 5 additions & 5 deletions test/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
# npm -g install npm yarn

# https://github.com/nodejs/node-addon-api/issues/387
declare -a LTS_TEST=("8.9.0" "10.13.0" "11.0.0" "12.0.0")
declare -a LTS_BUILD=("8.9.0" "10.13.0" "11.0.0" "12.0.0")
#declare -a LTS_TEST=("8.9.0" "8.16.0" "10.13.0" "10.15.3" "11.0.0" "11.15.0" "12.3.0")
declare -a LTS_BUILD=("8.16.0" "10.15.3" "11.15.0" "12.3.0")
declare -a LTS_TEST=("8.16.0" "10.15.3" "11.15.0" "12.3.0")

version=`cat ./VERSION`
version=`cat ./VERSION`

platform=`uname`

Expand Down Expand Up @@ -64,7 +64,7 @@ if [ "$1" != "test" ]; then
if [ $? -ne 0 ]; then
exit
fi

if [ "$osext" == "darwin" ]; then
# https://github.com/nodejs/node-gyp/issues/1564
env CXXFLAGS="-mmacosx-version-min=10.9" node-pre-gyp clean configure build package && printf "build: node: $(node -v) npm:$(npm -v) abi:$(node -e 'console.log(process.versions.modules)')\n" >> $BUILD_LOG
Expand All @@ -73,7 +73,7 @@ if [ "$1" != "test" ]; then
fi

for filename in build/stage/$version/*.tar.gz; do
mv $filename $NPMRELEASE/.
mv $filename $NPMRELEASE/.
done
done

Expand Down
215 changes: 112 additions & 103 deletions test/connection.promise.spec.js
Original file line number Diff line number Diff line change
@@ -1,103 +1,112 @@
// Copyright 2014 SAP AG.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http: //www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

'use strict';

const setup = require('./setup');
const client = setup.client;

beforeEach(function () {
return client.reopen();
});

afterEach(function () {
return client.close();
});

afterAll(function (done) {
delete setup.client;
delete setup.rfcClient;
delete setup.rfcPool;
done();
});

it('call() STFC_CONNECTION should return unicode string', function () {
return client.call('STFC_CONNECTION', { REQUTEXT: setup.UNICODETEST }).then(res => {
expect(res).toBeDefined();
expect(res).toHaveProperty('ECHOTEXT');
expect(res.ECHOTEXT.indexOf(setup.UNICODETEST)).toEqual(0);
});
});

it('call() STFC_STRUCTURE should return structure and table', function () {
let importStruct = {
RFCFLOAT: 1.23456789,
RFCCHAR1: 'A',
RFCCHAR2: 'BC',
RFCCHAR4: 'DEFG',

RFCINT1: 1,
RFCINT2: 2,
RFCINT4: 345,

RFCHEX3: Buffer.from('\x01\x02\x03', 'ascii'),

RFCTIME: '121120',
RFCDATE: '20140101',

RFCDATA1: '1DATA1',
RFCDATA2: 'DATA222',
};
let importTable = [importStruct];

return client.call('STFC_STRUCTURE', { IMPORTSTRUCT: importStruct, RFCTABLE: importTable }).then(res => {
expect(res).toBeDefined();
expect(res).toHaveProperty('ECHOSTRUCT');
expect(res).toHaveProperty('RFCTABLE');

expect(res.ECHOSTRUCT.RFCCHAR1).toEqual(importStruct.RFCCHAR1);
expect(res.ECHOSTRUCT.RFCCHAR2).toEqual(importStruct.RFCCHAR2);
expect(res.ECHOSTRUCT.RFCCHAR4).toEqual(importStruct.RFCCHAR4);
expect(res.ECHOSTRUCT.RFCFLOAT).toEqual(importStruct.RFCFLOAT);
expect(res.ECHOSTRUCT.RFCINT1).toEqual(importStruct.RFCINT1);
expect(res.ECHOSTRUCT.RFCINT2).toEqual(importStruct.RFCINT2);
expect(res.ECHOSTRUCT.RFCINT4).toEqual(importStruct.RFCINT4);
expect(res.ECHOSTRUCT.RFCDATA1).toContain(importStruct.RFCDATA1);
expect(res.ECHOSTRUCT.RFCDATA2).toContain(importStruct.RFCDATA2);
expect(res.ECHOSTRUCT.RFCHEX3.toString()).toEqual(importStruct.RFCHEX3.toString());

expect(res.RFCTABLE.length).toBe(2);
expect(res.RFCTABLE[1].RFCFLOAT).toEqual(importStruct.RFCFLOAT + 1);
expect(res.RFCTABLE[1].RFCINT1).toEqual(importStruct.RFCINT1 + 1);
expect(res.RFCTABLE[1].RFCINT2).toEqual(importStruct.RFCINT2 + 1);
expect(res.RFCTABLE[1].RFCINT4).toEqual(importStruct.RFCINT4 + 1);
});
});

it('isAlive and ping() should be true when connected', function () {
expect(client.isAlive).toBeTruthy();
return client.ping().then(res => {
expect(res).toBeTruthy();
});
});

it('isAlive ands ping() should be false when disconnected', function (done) {
client.close().then(() => {
expect(client.isAlive).toBeFalsy();
client.ping().then(res => {
expect(res).toBeFalsy();
done();
});
});
});
// Copyright 2014 SAP AG.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http: //www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

"use strict";

const setup = require("./setup");
const client = setup.client;

beforeEach(function() {
return client.reopen();
});

afterEach(function() {
return client.close();
});

afterAll(function(done) {
delete setup.client;
delete setup.rfcClient;
delete setup.rfcPool;
done();
});

it("call() STFC_CONNECTION should return unicode string", function() {
return client
.call("STFC_CONNECTION", { REQUTEXT: setup.UNICODETEST })
.then(res => {
expect(res).toBeDefined();
expect(res).toHaveProperty("ECHOTEXT");
expect(res.ECHOTEXT.indexOf(setup.UNICODETEST)).toEqual(0);
});
});

it("call() STFC_STRUCTURE should return structure and table", function() {
let importStruct = {
RFCFLOAT: 1.23456789,
RFCCHAR1: "A",
RFCCHAR2: "BC",
RFCCHAR4: "DEFG",

RFCINT1: 1,
RFCINT2: 2,
RFCINT4: 345,

RFCHEX3: Buffer.from("\x01\x02\x03", "ascii"),

RFCTIME: "121120",
RFCDATE: "20140101",

RFCDATA1: "1DATA1",
RFCDATA2: "DATA222"
};
let importTable = [importStruct];

return client
.call("STFC_STRUCTURE", {
IMPORTSTRUCT: importStruct,
RFCTABLE: importTable
})
.then(res => {
expect(res).toBeDefined();
expect(res).toHaveProperty("ECHOSTRUCT");
expect(res).toHaveProperty("RFCTABLE");

expect(res.ECHOSTRUCT.RFCCHAR1).toEqual(importStruct.RFCCHAR1);
expect(res.ECHOSTRUCT.RFCCHAR2).toEqual(importStruct.RFCCHAR2);
expect(res.ECHOSTRUCT.RFCCHAR4).toEqual(importStruct.RFCCHAR4);
expect(res.ECHOSTRUCT.RFCFLOAT).toEqual(importStruct.RFCFLOAT);
expect(res.ECHOSTRUCT.RFCINT1).toEqual(importStruct.RFCINT1);
expect(res.ECHOSTRUCT.RFCINT2).toEqual(importStruct.RFCINT2);
expect(res.ECHOSTRUCT.RFCINT4).toEqual(importStruct.RFCINT4);
expect(res.ECHOSTRUCT.RFCDATA1).toContain(importStruct.RFCDATA1);
expect(res.ECHOSTRUCT.RFCDATA2).toContain(importStruct.RFCDATA2);
expect(res.ECHOSTRUCT.RFCHEX3.toString()).toEqual(
importStruct.RFCHEX3.toString()
);

expect(res.RFCTABLE.length).toBe(2);
expect(res.RFCTABLE[1].RFCFLOAT).toEqual(importStruct.RFCFLOAT + 1);
expect(res.RFCTABLE[1].RFCINT1).toEqual(importStruct.RFCINT1 + 1);
expect(res.RFCTABLE[1].RFCINT2).toEqual(importStruct.RFCINT2 + 1);
expect(res.RFCTABLE[1].RFCINT4).toEqual(importStruct.RFCINT4 + 1);
});
});

it("isAlive and ping() should be true when connected", function() {
expect(client.isAlive).toBeTruthy();
return client.ping().then(res => {
expect(res).toBeTruthy();
});
});

it("isAlive ands ping() should be false when disconnected", function(done) {
client.close().then(() => {
expect(client.isAlive).toBeFalsy();
client.ping().then(res => {
expect(res).toBeFalsy();
done();
});
});
});
Loading

0 comments on commit 779c3a9

Please sign in to comment.