@adobe/acc-js-sdk 1.1.6 → 1.1.8

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.
package/src/transport.js CHANGED
@@ -10,7 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
  governing permissions and limitations under the License.
11
11
  */
12
12
  (function() {
13
- "use strict";
13
+ "use strict";
14
14
 
15
15
  const { Util } = require('./util.js');
16
16
 
@@ -41,9 +41,9 @@ class HttpError {
41
41
  }
42
42
 
43
43
  /**********************************************************************************
44
- *
44
+ *
45
45
  * Node implementation
46
- *
46
+ *
47
47
  *********************************************************************************/
48
48
  /* istanbul ignore else */
49
49
  if (!Util.isBrowser()) {
@@ -52,13 +52,13 @@ if (!Util.isBrowser()) {
52
52
  const axios = require('axios');
53
53
 
54
54
  /**
55
- *
55
+ *
56
56
  * Request body (options)
57
57
  * - headers (kv)
58
58
  * - method
59
59
  * - url
60
60
  * - data
61
- *
61
+ *
62
62
  * Response
63
63
  * - data
64
64
  * - statusCode
@@ -96,11 +96,11 @@ if (!Util.isBrowser()) {
96
96
  }
97
97
 
98
98
  /**********************************************************************************
99
- *
99
+ *
100
100
  * Browser-side implementation of the request-promise-native node module.
101
101
  * This simply wraps the fetch API
102
102
  * From https://www.npmjs.com/package/request-promise-native
103
- *
103
+ *
104
104
  *********************************************************************************/
105
105
  else {
106
106
 
@@ -109,11 +109,12 @@ if (!Util.isBrowser()) {
109
109
  const headers = new Headers();
110
110
  for (var k in options.headers) {
111
111
  headers.append(k, options.headers[k]);
112
- }
112
+ }
113
113
  const r = new Request(options.url, {
114
114
  method: options.method,
115
115
  headers: headers,
116
- body: options.data
116
+ body: options.data,
117
+ credentials: options.credentials || 'same-origin'
117
118
  });
118
119
 
119
120
  const p = fetch(r).then(async (response) => {
@@ -135,4 +136,4 @@ if (!Util.isBrowser()) {
135
136
 
136
137
  }
137
138
 
138
- })();
139
+ })();
@@ -2021,6 +2021,77 @@ describe('Application', () => {
2021
2021
  expect(schema.userDescription).toBe("recipient");
2022
2022
  });
2023
2023
  });
2024
+
2025
+ describe("Translation ids", () => {
2026
+ it("schema should have a correct label localization id", () => {
2027
+ const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='recipient' label='Recipients'/></schema>");
2028
+ const schema = newSchema(xml);
2029
+ expect(schema.labelLocalizationId).toBe('nms__recipient__@label');
2030
+ expect(schema.descriptionLocalizationId).toBe('nms__recipient__@desc');
2031
+ });
2032
+
2033
+ it("schema should have a correct singular label localization id", () => {
2034
+ const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='recipient' label='Recipients'/></schema>");
2035
+ const schema = newSchema(xml);
2036
+ expect(schema.labelSingularLocalizationId).toBe('nms__recipient__@labelSingular');
2037
+ });
2038
+
2039
+ it("root node should have a correct label localization id", () => {
2040
+ const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='recipient' label='Recipients'/></schema>");
2041
+ const schema = newSchema(xml);
2042
+ const root = schema.root;
2043
+ expect(root.labelLocalizationId).toBe('nms__recipient__e____recipient__@label');
2044
+ expect(root.descriptionLocalizationId).toBe('nms__recipient__e____recipient__@desc');
2045
+ });
2046
+
2047
+ it("child node should have a correct label localization id", () => {
2048
+ const xml = DomUtil.parse("<schema namespace='nms' name='recipient'><element name='lib' label='library'/><element name='recipient' label='Recipients'/></schema>");
2049
+ const schema = newSchema(xml);
2050
+ const lib = schema.children["lib"];
2051
+ expect(lib.labelLocalizationId).toBe('nms__recipient__e____lib__@label');
2052
+ expect(lib.descriptionLocalizationId).toBe('nms__recipient__e____lib__@desc');
2053
+ });
2054
+
2055
+ it("attribute should have a correct label localization id", () => {
2056
+ const xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
2057
+ <element name='recipient' label='Recipients'>
2058
+ <attribute name='email' type='string' label='email' length='3'/>
2059
+ </element>
2060
+ </schema>`);
2061
+ const schema = newSchema(xml);
2062
+ const root = schema.root;
2063
+ expect(root.children.get("@email").labelLocalizationId).toBe('nms__recipient__e____recipient__email__@label');
2064
+ expect(root.children.get("@email").descriptionLocalizationId).toBe('nms__recipient__e____recipient__email__@desc');
2065
+ });
2066
+
2067
+ it("Enumeration should have a correct label localization id", () => {
2068
+ const xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
2069
+ <enumeration name="gender" basetype="byte"/>
2070
+ <element name='recipient' label='Recipients'></element>
2071
+ </schema>`);
2072
+ const schema = newSchema(xml);
2073
+ const enumerations = schema.enumerations;
2074
+ expect(enumerations.gender.labelLocalizationId).toBe('nms__recipient__gender__@label');
2075
+ expect(enumerations.gender.descriptionLocalizationId).toBe('nms__recipient__gender__@desc');
2076
+ });
2077
+
2078
+ it("Enumeration value should have a correct label localization id", () => {
2079
+ const xml = DomUtil.parse(`<schema namespace='nms' name='recipient'>
2080
+ <enumeration name="gender" basetype="byte">
2081
+ <value name="male" value="0"/>
2082
+ <value name="female" value="1"/>
2083
+ </enumeration>
2084
+ <element name='recipient' label='Recipients'>
2085
+ <attribute advanced="true" desc="Recipient sex" enum="nms:recipient:gender"
2086
+ label="Gender" name="gender" sqlname="iGender" type="byte"/>
2087
+ </element>
2088
+ </schema>`);
2089
+ const schema = newSchema(xml);
2090
+ const enumerations = schema.enumerations;
2091
+ expect(enumerations.gender.values.male.labelLocalizationId).toBe('nms__recipient__gender__male__@label');
2092
+ expect(enumerations.gender.values.male.descriptionLocalizationId).toBe('nms__recipient__gender__male__@desc');
2093
+ })
2094
+ });
2024
2095
  });
2025
2096
 
2026
2097
  describe("CurrentLogin", () => {
@@ -30,13 +30,16 @@ describe('Caches', function() {
30
30
  it("Should cache with default TTL and default key function", () => {
31
31
  const cache = new Cache();
32
32
  cache.put("Hello", "World");
33
+ expect(cache._stats).toMatchObject({ reads: 0, writes: 1 });
33
34
  expect(cache.get("Hello")).toBe("World");
35
+ expect(cache._stats).toMatchObject({ reads: 1, writes: 1, memoryHits: 1, storageHits: 0 });
34
36
  })
35
37
 
36
38
  it("Should expires after TTL", () => {
37
39
  const cache = new Cache(undefined, undefined, -1); // negative TTL => will immediately expire
38
40
  cache.put("Hello", "World");
39
41
  expect(cache.get("Hello")).toBeUndefined();
42
+ expect(cache._stats).toMatchObject({ reads: 1, writes: 1, memoryHits: 0, storageHits: 0 });
40
43
  })
41
44
 
42
45
  it("Should support custom key function", () => {
@@ -53,6 +56,7 @@ describe('Caches', function() {
53
56
  expect(cache.get("Hello")).toBe("World");
54
57
  cache.clear();
55
58
  expect(cache.get("Hello")).toBeUndefined();
59
+ expect(cache._stats).toMatchObject({ reads: 2, writes: 1, memoryHits: 1, storageHits: 0, clears: 1 });
56
60
  })
57
61
 
58
62
  it("Should remove key in cache", () => {
@@ -61,9 +65,11 @@ describe('Caches', function() {
61
65
  cache.put("Hi", "A");
62
66
  expect(cache.get("Hello")).toBe("World");
63
67
  expect(cache.get("Hi")).toBe("A");
68
+ expect(cache._stats).toMatchObject({ reads: 2, writes: 2, memoryHits: 2 });
64
69
  cache.remove("Hello");
65
70
  expect(cache.get("Hello")).toBeUndefined();
66
71
  expect(cache.get("Hi")).toBe("A");
72
+ expect(cache._stats).toMatchObject({ reads: 4, writes: 2, memoryHits: 3, removals: 1 });
67
73
  // should support removing a key which has already been removed
68
74
  cache.remove("Hello");
69
75
  expect(cache.get("Hello")).toBeUndefined();