@yousolution/node-red-contrib-you-sap-service-layer 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -835,6 +835,211 @@ describe('support library', () => {
835
835
  }).to.throw('Missing method');
836
836
  });
837
837
 
838
+ it('should generate a correct request with SQLQuery create query', () => {
839
+ const node = {
840
+ context: () => {
841
+ return {
842
+ flow: {
843
+ get: (param) => {
844
+ if (param == '_YOU_SapServiceLayer_1.host') {
845
+ return 'host';
846
+ }
847
+ if (param == '_YOU_SapServiceLayer_1.port') {
848
+ return 'port';
849
+ }
850
+ if (param == '_YOU_SapServiceLayer_1.version') {
851
+ return 'version';
852
+ }
853
+ if (param == '_YOU_SapServiceLayer_1.headers') {
854
+ return ['header:1', 'header:2'];
855
+ }
856
+ },
857
+ },
858
+ };
859
+ },
860
+ };
861
+
862
+ const msg = {
863
+ _YOU_SapServiceLayer: {
864
+ idAuth: 1,
865
+ },
866
+ entityId: 3,
867
+ };
868
+ let config = {
869
+ sqlCode: 'sqlCode',
870
+ sqlName: 'sqlName',
871
+ sqlText: 'sqlText',
872
+ };
873
+ const options = { method: 'POST', hasRawQuery: false, hasEntityId: false, isCreateSQLQuery: true };
874
+ const expectedValue = {
875
+ axiosOptions: {
876
+ headers: {
877
+ Cookie: 'header:1;header:2',
878
+ },
879
+ method: 'POST',
880
+ rejectUnauthorized: false,
881
+ url: 'https://host:port/b1s/version/SQLQueries',
882
+ withCredentials: true,
883
+ },
884
+ idAuthNode: 1,
885
+ };
886
+
887
+ should.deepEqual(Support.generateRequest(node, msg, config, options), expectedValue);
888
+ });
889
+
890
+ it('should generate a correct request with SQLQuery execute query without params', () => {
891
+ const node = {
892
+ context: () => {
893
+ return {
894
+ flow: {
895
+ get: (param) => {
896
+ if (param == '_YOU_SapServiceLayer_1.host') {
897
+ return 'host';
898
+ }
899
+ if (param == '_YOU_SapServiceLayer_1.port') {
900
+ return 'port';
901
+ }
902
+ if (param == '_YOU_SapServiceLayer_1.version') {
903
+ return 'version';
904
+ }
905
+ if (param == '_YOU_SapServiceLayer_1.headers') {
906
+ return ['header:1', 'header:2'];
907
+ }
908
+ },
909
+ },
910
+ };
911
+ },
912
+ };
913
+
914
+ const msg = {
915
+ _YOU_SapServiceLayer: {
916
+ idAuth: 1,
917
+ },
918
+ entityId: 3,
919
+ sqlCode: 'queryCode',
920
+ };
921
+ let config = {
922
+ sqlCode: 'sqlCode',
923
+ };
924
+ const options = { method: 'POST', hasRawQuery: false, hasEntityId: false, isSQLQuery: true };
925
+ const expectedValue = {
926
+ axiosOptions: {
927
+ headers: {
928
+ Cookie: 'header:1;header:2',
929
+ },
930
+ method: 'POST',
931
+ rejectUnauthorized: false,
932
+ url: `https://host:port/b1s/version/SQLQueries('queryCode')/List`,
933
+ withCredentials: true,
934
+ },
935
+ idAuthNode: 1,
936
+ };
937
+
938
+ should.deepEqual(Support.generateRequest(node, msg, config, options), expectedValue);
939
+ });
940
+
941
+ it('should generate a correct request with SQLQuery execute query with params', () => {
942
+ const node = {
943
+ context: () => {
944
+ return {
945
+ flow: {
946
+ get: (param) => {
947
+ if (param == '_YOU_SapServiceLayer_1.host') {
948
+ return 'host';
949
+ }
950
+ if (param == '_YOU_SapServiceLayer_1.port') {
951
+ return 'port';
952
+ }
953
+ if (param == '_YOU_SapServiceLayer_1.version') {
954
+ return 'version';
955
+ }
956
+ if (param == '_YOU_SapServiceLayer_1.headers') {
957
+ return ['header:1', 'header:2'];
958
+ }
959
+ },
960
+ },
961
+ };
962
+ },
963
+ };
964
+
965
+ const msg = {
966
+ _YOU_SapServiceLayer: {
967
+ idAuth: 1,
968
+ },
969
+ entityId: 3,
970
+ sqlCode: 'queryCode',
971
+ };
972
+ let config = {
973
+ sqlCode: 'sqlCode',
974
+ };
975
+ const options = { method: 'POST', hasRawQuery: false, hasEntityId: false, isSQLQuery: true };
976
+ const expectedValue = {
977
+ axiosOptions: {
978
+ headers: {
979
+ Cookie: 'header:1;header:2',
980
+ },
981
+ method: 'POST',
982
+ rejectUnauthorized: false,
983
+ url: `https://host:port/b1s/version/SQLQueries('queryCode')/List`,
984
+ withCredentials: true,
985
+ },
986
+ idAuthNode: 1,
987
+ };
988
+
989
+ should.deepEqual(Support.generateRequest(node, msg, config, options), expectedValue);
990
+ });
991
+
992
+ it('should generate a correct request with SQLQuery execute query with nextLink', () => {
993
+ const node = {
994
+ context: () => {
995
+ return {
996
+ flow: {
997
+ get: (param) => {
998
+ if (param == '_YOU_SapServiceLayer_1.host') {
999
+ return 'host';
1000
+ }
1001
+ if (param == '_YOU_SapServiceLayer_1.port') {
1002
+ return 'port';
1003
+ }
1004
+ if (param == '_YOU_SapServiceLayer_1.version') {
1005
+ return 'version';
1006
+ }
1007
+ if (param == '_YOU_SapServiceLayer_1.headers') {
1008
+ return ['header:1', 'header:2'];
1009
+ }
1010
+ },
1011
+ },
1012
+ };
1013
+ },
1014
+ };
1015
+
1016
+ const msg = {
1017
+ _YOU_SapServiceLayer: {
1018
+ idAuth: 1,
1019
+ },
1020
+ entityId: 3,
1021
+ sqlCode: 'queryCode',
1022
+ };
1023
+ let config = {
1024
+ sqlCode: 'sqlCode',
1025
+ };
1026
+ const options = { method: 'POST', hasRawQuery: false, hasEntityId: false, isSQLQuery: true };
1027
+ const expectedValue = {
1028
+ axiosOptions: {
1029
+ headers: {
1030
+ Cookie: 'header:1;header:2',
1031
+ },
1032
+ method: 'POST',
1033
+ rejectUnauthorized: false,
1034
+ url: `https://host:port/b1s/version/SQLQueries('queryCode')/List`,
1035
+ withCredentials: true,
1036
+ },
1037
+ idAuthNode: 1,
1038
+ };
1039
+
1040
+ should.deepEqual(Support.generateRequest(node, msg, config, options), expectedValue);
1041
+ });
1042
+
838
1043
  it('should have error missing object', () => {
839
1044
  const node = {
840
1045
  context: () => {