fiftyone.pipeline.core 4.4.7 → 4.4.9

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/tests/jsoutput.js CHANGED
@@ -20,218 +20,218 @@
20
20
  * such notice(s) shall fulfill the requirements of that article.
21
21
  * ********************************************************************* */
22
22
 
23
- fiftyoneDegreesManager = function() {
24
- 'use-strict';
25
- var json = {"nullValueReasons":{"testengine.four":"This property is not available"},"javascriptProperties":["testengine.three"],"testengine":{"one":1,"two":2,"three":"console.log('ok')","four":null}};
26
-
27
- // Log any errors returned in the JSON object.
28
- if(json.error !== undefined){
29
- console.log(json.error);
23
+ fiftyoneDegreesManager = function () { // eslint-disable-line
24
+ 'use-strict';
25
+ const json = { nullValueReasons: { 'testengine.four': 'This property is not available' }, javascriptProperties: ['testengine.three'], testengine: { one: 1, two: 2, three: "console.log('ok')", four: null } };
26
+
27
+ // Log any errors returned in the JSON object.
28
+ if (json.error !== undefined) {
29
+ console.log(json.error);
30
+ }
31
+ // Set to true when the JSON object is complete.
32
+ const completed = false;
33
+
34
+ // changeFuncs is an array of functions. When onChange is called and passed
35
+ // a function, the function is registered and is called when processing is
36
+ // complete.
37
+ const changeFuncs = [];
38
+
39
+ // Counter is used to count how many pieces of callbacks are expected. Every
40
+ // time the completedCallback method is called, the counter is decremented
41
+ // by 1. The counter's initial value is 1 as the method is always called
42
+ // once to continue execution.
43
+ let callbackCounter = 1;
44
+
45
+ // startsWith polyfill.
46
+ const startsWith = function (source, searchValue) {
47
+ return source.lastIndexOf(searchValue, 0) === 0;
48
+ };
49
+
50
+ // Get cookies with the '51D_' prefix that have been added to the request
51
+ // and return the data as key value pairs. This method is needed to extract
52
+ // cookie values for inclusion in the GET or POST request for situations
53
+ // where CORS will prevent cookies being sent to third parties.
54
+ const getFodCookies = function () {
55
+ const keyValuePairs = document.cookie.split(/; */);
56
+ const fodCookies = [];
57
+ for (let i = 0; i < keyValuePairs.length; i++) {
58
+ const name = keyValuePairs[i].substring(0, keyValuePairs[i].indexOf('='));
59
+ if (startsWith(name, '51D_')) {
60
+ const value = keyValuePairs[i].substring(keyValuePairs[i].indexOf('=') + 1);
61
+ fodCookies[name] = value;
62
+ }
30
63
  }
31
- // Set to true when the JSON object is complete.
32
- var completed = false;
33
-
34
- // changeFuncs is an array of functions. When onChange is called and passed
35
- // a function, the function is registered and is called when processing is
36
- // complete.
37
- var changeFuncs = [];
38
-
39
- // Counter is used to count how many pieces of callbacks are expected. Every
40
- // time the completedCallback method is called, the counter is decremented
41
- // by 1. The counter's initial value is 1 as the method is always called
42
- // once to continue execution.
43
- var callbackCounter = 1;
44
-
45
- // startsWith polyfill.
46
- var startsWith = function(source, searchValue){
47
- return source.lastIndexOf(searchValue, 0) === 0;
64
+ return fodCookies;
65
+ };
66
+
67
+ // Extract key value pairs from the '51D_' prefixed cookies and concatenates
68
+ // them to form a query string for the subsequent json refresh.
69
+ const getParametersFromCookies = function () { // eslint-disable-line
70
+ const fodCookies = getFodCookies();
71
+ const keyValuePairs = [];
72
+ for (const key in fodCookies) {
73
+ if (fodCookies.hasOwnProperty(key)) {
74
+ keyValuePairs.push(key + '=' + fodCookies[key]);
75
+ }
48
76
  }
49
-
50
- // Get cookies with the '51D_' prefix that have been added to the request
51
- // and return the data as key value pairs. This method is needed to extract
52
- // cookie values for inclusion in the GET or POST request for situations
53
- // where CORS will prevent cookies being sent to third parties.
54
- var getFodCookies = function(){
55
- var keyValuePairs = document.cookie.split(/; */);
56
- var fodCookies = [];
57
- for(var i = 0; i < keyValuePairs.length; i++) {
58
- var name = keyValuePairs[i].substring(0, keyValuePairs[i].indexOf('='));
59
- if(startsWith(name, "51D_")){
60
- var value = keyValuePairs[i].substring(keyValuePairs[i].indexOf('=')+1);
61
- fodCookies[name] = value;
62
- }
63
- }
64
- return fodCookies;
65
- };
66
-
67
- // Extract key value pairs from the '51D_' prefixed cookies and concatenates
68
- // them to form a query string for the subsequent json refresh.
69
- var getParametersFromCookies = function(){
70
- var fodCookies = getFodCookies();
71
- var keyValuePairs = [];
72
- for (var key in fodCookies) {
73
- if (fodCookies.hasOwnProperty(key)) {
74
- keyValuePairs.push(key+"="+fodCookies[key]);
75
- }
76
- }
77
- return keyValuePairs;
78
- };
79
-
80
- // Delete a cookie.
81
- function deleteCookie(name) {
82
- document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
77
+ return keyValuePairs;
78
+ };
79
+
80
+ // Delete a cookie.
81
+ /**
82
+ *
83
+ * @param name
84
+ */
85
+ function deleteCookie (name) { // eslint-disable-line
86
+ document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
87
+ }
88
+
89
+ // Fetch a value safely from the json object. If a key somewhere down the
90
+ // '.' separated hierarchy of keys is not present then 'undefined' is
91
+ // returned rather than letting an exception occur.
92
+ const getFromJson = function (key) {
93
+ let result;
94
+ if (typeof (key) === 'string') {
95
+ let functions = json;
96
+ const segments = key.split('.');
97
+ let i = 0;
98
+ while (functions !== undefined && i < segments.length) {
99
+ functions = functions[segments[i++]];
100
+ }
101
+ if (typeof (functions) === 'string') {
102
+ result = functions;
103
+ }
83
104
  }
84
-
85
- // Fetch a value safely from the json object. If a key somewhere down the
86
- // '.' separated hierarchy of keys is not present then 'undefined' is
87
- // returned rather than letting an exception occur.
88
- var getFromJson = function(key) {
89
- var result = undefined;
90
- if (typeof(key) === 'string') {
91
- var functions = json;
92
- var segments = key.split('.');
93
- var i = 0;
94
- while (functions !== undefined && i < segments.length) {
95
- functions = functions[segments[i++]];
96
- }
97
- if (typeof(functions) === "string") {
98
- result = functions;
99
- }
100
- }
101
- return result;
102
- }
103
-
104
- // Executed at the end of the processJSproperties method or for each piece
105
- // of JavaScript which has 51D code injected. When there are 0 pieces of
106
- // JavaScript left to process then reload the JSON object.
107
- var completedCallback = function(resolve, reject){
108
- callbackCounter--;
109
- if (callbackCounter === 0){
110
- } else if (callbackCounter < 0){
111
- reject('Too many callbacks.');
112
- }
105
+ return result;
106
+ };
107
+
108
+ // Executed at the end of the processJSproperties method or for each piece
109
+ // of JavaScript which has 51D code injected. When there are 0 pieces of
110
+ // JavaScript left to process then reload the JSON object.
111
+ const completedCallback = function (resolve, reject) {
112
+ callbackCounter--;
113
+ if (callbackCounter === 0) {
114
+ } else if (callbackCounter < 0) {
115
+ reject('Too many callbacks.');
113
116
  }
114
-
115
- // Executes any Javascript contained in the json data. Sets the processedJs
116
- // flag to true when there is no further Javascript to be processed.
117
- var processJSproperties = function(resolve, reject) {
118
- if (json.javascriptProperties !== undefined){
119
- if (json.javascriptProperties.length > 0) {
120
-
121
- // Execute each of the Javascript property code snippets using the
122
- // index of the value to access the value to avoid problems with
123
- // JavaScript returning erroneous values.
124
- for(var index = 0;
125
- index < json.javascriptProperties.length;
126
- index++) {
127
-
128
- var name = json.javascriptProperties[index];
129
-
130
- // Create new function bound to this instance and execute it.
131
- // This is needed to ensure the scope of the function is
132
- // associated with this instance if any members are altered or
133
- // added. Avoids global scoped variables.
134
- var body = getFromJson(name);
135
-
136
- if (body !== undefined) {
137
- var func = undefined;
138
- var searchString = '// 51D replace this comment with callback function.';
139
-
140
- if(body.indexOf(searchString) !== -1){
141
- callbackCounter++;
142
- body = body.replace(/\/\/ 51D replace this comment with callback function./g, 'callbackFunc(resolveFunc, rejectFunc);');
143
- func = new Function('callbackFunc', 'resolveFunc', 'rejectFunc',
144
- "try {\n" +
145
- body + "\n" +
146
- "} catch (err) {\n" +
147
- "console.log(err);" +
148
- "}"
149
- );
150
- func(completedCallback, resolve, reject);
151
- } else {
152
- func = new Function(
153
- "try {\n" +
154
- body + "\n" +
155
- "} catch (err) {\n" +
156
- "console.log(err);" +
157
- "}"
158
- );
159
- func();
160
- }
161
- }
162
- }
117
+ };
118
+
119
+ // Executes any Javascript contained in the json data. Sets the processedJs
120
+ // flag to true when there is no further Javascript to be processed.
121
+ const processJSproperties = function (resolve, reject) {
122
+ if (json.javascriptProperties !== undefined) {
123
+ if (json.javascriptProperties.length > 0) {
124
+ // Execute each of the Javascript property code snippets using the
125
+ // index of the value to access the value to avoid problems with
126
+ // JavaScript returning erroneous values.
127
+ for (let index = 0;
128
+ index < json.javascriptProperties.length;
129
+ index++) {
130
+ const name = json.javascriptProperties[index];
131
+
132
+ // Create new function bound to this instance and execute it.
133
+ // This is needed to ensure the scope of the function is
134
+ // associated with this instance if any members are altered or
135
+ // added. Avoids global scoped variables.
136
+ let body = getFromJson(name);
137
+
138
+ if (body !== undefined) {
139
+ let func;
140
+ const searchString = '// 51D replace this comment with callback function.';
141
+
142
+ if (body.indexOf(searchString) !== -1) {
143
+ callbackCounter++;
144
+ body = body.replace(/\/\/ 51D replace this comment with callback function./g, 'callbackFunc(resolveFunc, rejectFunc);');
145
+ func = new Function('callbackFunc', 'resolveFunc', 'rejectFunc',// eslint-disable-line
146
+ 'try {\n' +
147
+ body + '\n' +
148
+ '} catch (err) {\n' +
149
+ 'console.log(err);' +
150
+ '}'
151
+ );
152
+ func(completedCallback, resolve, reject);
153
+ } else {
154
+ func = new Function( // eslint-disable-line
155
+ 'try {\n' +
156
+ body + '\n' +
157
+ '} catch (err) {\n' +
158
+ 'console.log(err);' +
159
+ '}'
160
+ );
161
+ func();
163
162
  }
163
+ }
164
164
  }
165
- completedCallback(resolve, reject);
166
- };
167
-
168
-
169
- // Check if the JSON object still has any JavaScript snippets to run.
170
- var hasJSFunctions = function() {
171
- for (var i = i; i < json.javascriptProperties; i++) {
172
- var body = getFromJson(json.javascriptProperties[i]);
173
- if (body !== undefined && body.length > 0) {
174
- return true;
175
- }
176
- }
177
- return false;
165
+ }
178
166
  }
179
-
180
- // Process the JavaScript properties.
181
- var process = function(resolve, reject){
182
- processJSproperties(resolve, reject);
167
+ completedCallback(resolve, reject);
168
+ };
169
+
170
+ // Check if the JSON object still has any JavaScript snippets to run.
171
+ const hasJSFunctions = function () { // eslint-disable-line
172
+ // TODO: Fix i = i
173
+ for (var i = i; i < json.javascriptProperties; i++) { // eslint-disable-line
174
+ const body = getFromJson(json.javascriptProperties[i]);
175
+ if (body !== undefined && body.length > 0) {
176
+ return true;
177
+ }
183
178
  }
184
-
185
-
186
- // Function logs errors, used to 'reject' a promise or for error callbacks.
187
- var catchError = function(value) {
188
- console.log(value.message || value);
189
- }
190
-
191
- // Populate this instance of the FOD object with getters to access the
192
- // properties. If the value is null then get the noValueMessage from the
193
- // JSON object corresponding to the property.
194
- var update = function(data){
195
- var self = this;
196
- Object.getOwnPropertyNames(data).forEach(function(key) {
197
- self[key] = {};
198
- for(var i in data[key]){
199
- var obj = self[key];
200
- (function(i) {
201
- Object.defineProperty(obj, i, {
202
- get: function (){
203
- if(data[key][i] === null && (i !== "javascriptProperties" || i !== "nullValueReasons")){
204
- return data.nullValueReasons[key+'.'+i];
205
- } else {
206
- return data[key][i];
207
- }
208
- }
209
- })
210
- })(i);
179
+ return false;
180
+ };
181
+
182
+ // Process the JavaScript properties.
183
+ const process = function (resolve, reject) {
184
+ processJSproperties(resolve, reject);
185
+ };
186
+
187
+ // Function logs errors, used to 'reject' a promise or for error callbacks.
188
+ const catchError = function (value) {
189
+ console.log(value.message || value);
190
+ };
191
+
192
+ // Populate this instance of the FOD object with getters to access the
193
+ // properties. If the value is null then get the noValueMessage from the
194
+ // JSON object corresponding to the property.
195
+ const update = function (data) {
196
+ const self = this;
197
+ Object.getOwnPropertyNames(data).forEach(function (key) {
198
+ self[key] = {};
199
+ for (const i in data[key]) {
200
+ var obj = self[key];
201
+ (function (i) {
202
+ Object.defineProperty(obj, i, {
203
+ get: function () {
204
+ if (data[key][i] === null && (i !== 'javascriptProperties' || i !== 'nullValueReasons')) {
205
+ return data.nullValueReasons[key + '.' + i];
206
+ } else {
207
+ return data[key][i];
208
+ }
211
209
  }
212
- });
210
+ });
211
+ })(i);
212
+ }
213
+ });
214
+ };
215
+
216
+ this.onChange = function (resolve) {
217
+ changeFuncs.push(resolve);
218
+ if (started === false) { // eslint-disable-line
219
+ process(resolve, catchError);
220
+ started = true; // eslint-disable-line
213
221
  }
222
+ };
214
223
 
215
- this.onChange = function(resolve) {
216
- changeFuncs.push(resolve);
217
- if(started === false){
218
- process(resolve, catchError);
219
- started = true;
220
- }
221
- }
222
-
223
- this.complete = function(resolve) {
224
- if(completed){
225
- resolve(this);
226
- }else{
227
- var parent = this;
228
- process(resolve, catchError);
229
- }
230
- };
224
+ this.complete = function (resolve) {
225
+ if (completed) {
226
+ resolve(this);
227
+ } else {
228
+ process(resolve, catchError);
229
+ }
230
+ };
231
231
 
232
- // Update this instance with the initial JSON payload.
233
- update.call(this, json);
234
- this.complete(json);
235
- }
232
+ // Update this instance with the initial JSON payload.
233
+ update.call(this, json);
234
+ this.complete(json);
235
+ };
236
236
 
237
- var fod = new fiftyoneDegreesManager();
237
+ const fod = new fiftyoneDegreesManager(); // eslint-disable-line
@@ -74,7 +74,7 @@ test('stop flag works', done => {
74
74
  syncFlowData.get('neverRun');
75
75
  } catch (e) {
76
76
  expect(e.indexOf(util.format(errorMessages.noElementData,
77
- 'neverRun','async, sync')) !== -1).toBe(true);
77
+ 'neverRun', 'async, sync')) !== -1).toBe(true);
78
78
  }
79
79
  done();
80
80
  });
@@ -25,29 +25,28 @@ const PipelineBuilder = require('../pipelineBuilder');
25
25
  const Helpers = require('../helpers');
26
26
  const each = require('jest-each').default;
27
27
  const AspectPropertyValue = require('../aspectPropertyValue');
28
- const ElementDataDictionary = require('../elementDataDictionary');
29
- var httpMocks = require('node-mocks-http');
28
+ const httpMocks = require('node-mocks-http');
30
29
 
31
- const unknownValue = new AspectPropertyValue(null, 'Unknown')
32
- const testValue = new AspectPropertyValue(null, 'test')
33
- const browserValue = new AspectPropertyValue(null, 'SEC-CH-UA,SEC-CH-UA-Full-Version')
34
- const platformValue = new AspectPropertyValue(null, 'SEC-CH-UA-Platform,SEC-CH-UA-Platform-Version')
35
- const hardwareValue = new AspectPropertyValue(null, 'SEC-CH-UA-Model,SEC-CH-UA-Mobile,SEC-CH-UA-Arch')
36
- // Value which contains at least one duplicate value from each of other SetHeader values.
37
- const duplicateValue = new AspectPropertyValue(null, 'SEC-CH-UA,SEC-CH-UA-Platform,SEC-CH-UA-Model')
30
+ const unknownValue = new AspectPropertyValue(null, 'Unknown');
31
+ const testValue = new AspectPropertyValue(null, 'test');
32
+ const browserValue = new AspectPropertyValue(null, 'SEC-CH-UA,SEC-CH-UA-Full-Version');
33
+ const platformValue = new AspectPropertyValue(null, 'SEC-CH-UA-Platform,SEC-CH-UA-Platform-Version');
34
+ const hardwareValue = new AspectPropertyValue(null, 'SEC-CH-UA-Model,SEC-CH-UA-Mobile,SEC-CH-UA-Arch');
35
+ // Value which contains at least one duplicate value from each of other SetHeader values.
36
+ const duplicateValue = new AspectPropertyValue(null, 'SEC-CH-UA,SEC-CH-UA-Platform,SEC-CH-UA-Model');
38
37
 
39
38
  // Set up the properties in the element.
40
- setup.device.properties["SetHeaderBrowserAccept-CH"] = {
41
- name: "SetHeaderBrowserAccept-CH"
39
+ setup.device.properties['SetHeaderBrowserAccept-CH'] = {
40
+ name: 'SetHeaderBrowserAccept-CH'
42
41
  };
43
- setup.device.properties["SetHeaderPlatformAccept-CH"] = {
44
- name: "SetHeaderPlatformAccept-CH"
42
+ setup.device.properties['SetHeaderPlatformAccept-CH'] = {
43
+ name: 'SetHeaderPlatformAccept-CH'
45
44
  };
46
- setup.device.properties["SetHeaderHardwareAccept-CH"] = {
47
- name: "SetHeaderHardwareAccept-CH"
45
+ setup.device.properties['SetHeaderHardwareAccept-CH'] = {
46
+ name: 'SetHeaderHardwareAccept-CH'
48
47
  };
49
- setup.device.properties["SetHeaderHardwareSomeOtherHeader"] = {
50
- name: "SetHeaderHardwareSomeOtherHeader"
48
+ setup.device.properties.SetHeaderHardwareSomeOtherHeader = {
49
+ name: 'SetHeaderHardwareSomeOtherHeader'
51
50
  };
52
51
 
53
52
  const pipeline = new PipelineBuilder()
@@ -56,68 +55,66 @@ const pipeline = new PipelineBuilder()
56
55
 
57
56
  /**
58
57
  * Test response header value to be set for UACH
59
- *
58
+ *
60
59
  */
61
60
  each([
62
- ["Ignore all unknown values.",
63
- { "SetHeaderBrowserAccept-CH": unknownValue, "SetHeaderPlatformAccept-CH": unknownValue, "SetHeaderHardwareAccept-CH": unknownValue},
64
- { "Accept-CH": "nil"}],
65
- ["Ignore unknown values.",
66
- { "SetHeaderBrowserAccept-CH": unknownValue, "SetHeaderPlatformAccept-CH": unknownValue, "SetHeaderHardwareAccept-CH": testValue},
67
- { "Accept-CH": "test"}],
68
- ["Single property, single header.",
69
- { "SetHeaderBrowserAccept-CH": browserValue},
70
- { "Accept-CH": "SEC-CH-UA,SEC-CH-UA-Full-Version"}],
71
- ["Two properties, single header.",
72
- { "SetHeaderPlatformAccept-CH": platformValue, "SetHeaderHardwareAccept-CH": hardwareValue},
73
- { "Accept-CH": "SEC-CH-UA-Platform,SEC-CH-UA-Platform-Version,SEC-CH-UA-Model,SEC-CH-UA-Mobile,SEC-CH-UA-Arch"}],
74
- ["Multiple properties, single header.",
75
- { "SetHeaderBrowserAccept-CH": browserValue, "SetHeaderPlatformAccept-CH": platformValue, "SetHeaderHardwareAccept-CH": hardwareValue},
76
- { "Accept-CH": "SEC-CH-UA,SEC-CH-UA-Full-Version,SEC-CH-UA-Platform,SEC-CH-UA-Platform-Version,SEC-CH-UA-Model,SEC-CH-UA-Mobile,SEC-CH-UA-Arch"}],
77
- ["String value (not aspectproperty).",
78
- { "SetHeaderBrowserAccept-CH": browserValue.value},
79
- { "Accept-CH": browserValue.value}],
80
- ["Undefined value.",
81
- { "SetHeaderBrowserAccept-CH": undefined},
82
- { "Accept-CH": "nil"}],
83
- ["Set multiple headers.",
84
- { "SetHeaderBrowserAccept-CH": browserValue, "SetHeaderHardwareSomeOtherHeader": platformValue},
85
- { "Accept-CH": browserValue.value, "SomeOtherHeader": platformValue.value}],
86
- ["Properties with duplicate values.",
87
- { "SetHeaderPlatformAccept-CH": platformValue, "SetHeaderHardwareAccept-CH": duplicateValue},
88
- { "Accept-CH": "SEC-CH-UA-Platform,SEC-CH-UA-Platform-Version,SEC-CH-UA,SEC-CH-UA-Model"}],
61
+ ['Ignore all unknown values.',
62
+ { 'SetHeaderBrowserAccept-CH': unknownValue, 'SetHeaderPlatformAccept-CH': unknownValue, 'SetHeaderHardwareAccept-CH': unknownValue },
63
+ { 'Accept-CH': 'nil' }],
64
+ ['Ignore unknown values.',
65
+ { 'SetHeaderBrowserAccept-CH': unknownValue, 'SetHeaderPlatformAccept-CH': unknownValue, 'SetHeaderHardwareAccept-CH': testValue },
66
+ { 'Accept-CH': 'test' }],
67
+ ['Single property, single header.',
68
+ { 'SetHeaderBrowserAccept-CH': browserValue },
69
+ { 'Accept-CH': 'SEC-CH-UA,SEC-CH-UA-Full-Version' }],
70
+ ['Two properties, single header.',
71
+ { 'SetHeaderPlatformAccept-CH': platformValue, 'SetHeaderHardwareAccept-CH': hardwareValue },
72
+ { 'Accept-CH': 'SEC-CH-UA-Platform,SEC-CH-UA-Platform-Version,SEC-CH-UA-Model,SEC-CH-UA-Mobile,SEC-CH-UA-Arch' }],
73
+ ['Multiple properties, single header.',
74
+ { 'SetHeaderBrowserAccept-CH': browserValue, 'SetHeaderPlatformAccept-CH': platformValue, 'SetHeaderHardwareAccept-CH': hardwareValue },
75
+ { 'Accept-CH': 'SEC-CH-UA,SEC-CH-UA-Full-Version,SEC-CH-UA-Platform,SEC-CH-UA-Platform-Version,SEC-CH-UA-Model,SEC-CH-UA-Mobile,SEC-CH-UA-Arch' }],
76
+ ['String value (not aspectproperty).',
77
+ { 'SetHeaderBrowserAccept-CH': browserValue.value },
78
+ { 'Accept-CH': browserValue.value }],
79
+ ['Undefined value.',
80
+ { 'SetHeaderBrowserAccept-CH': undefined },
81
+ { 'Accept-CH': 'nil' }],
82
+ ['Set multiple headers.',
83
+ { 'SetHeaderBrowserAccept-CH': browserValue, SetHeaderHardwareSomeOtherHeader: platformValue },
84
+ { 'Accept-CH': browserValue.value, SomeOtherHeader: platformValue.value }],
85
+ ['Properties with duplicate values.',
86
+ { 'SetHeaderPlatformAccept-CH': platformValue, 'SetHeaderHardwareAccept-CH': duplicateValue },
87
+ { 'Accept-CH': 'SEC-CH-UA-Platform,SEC-CH-UA-Platform-Version,SEC-CH-UA,SEC-CH-UA-Model' }]
89
88
  ])
90
- .test('testGetResponseHeaderValue - %s', async (name, device, expectedHeaders) => {
89
+ .test('testGetResponseHeaderValue - %s', async (name, device, expectedHeaders) => {
91
90
  // Set up a mock repsonse object to collect the headers which are
92
91
  // added to it.
93
- var response = httpMocks.createResponse();
94
- setup.device.additionalValues = device;
95
- const flowData = pipeline.createFlowData();
96
- var result = await flowData.process();
97
- // Call the method.
98
- Helpers.setResponseHeaders(response, result);
99
- // Check the correct headers were added to the response.
100
- for (const [key, value] of Object.entries(expectedHeaders)) {
101
- if (value === "nil") {
102
- expect(response.getHeader("Accept-CH")).toBe(undefined)
103
- }
104
- else {
105
- expect(response.getHeader(key)).toBe(value);
92
+ const response = httpMocks.createResponse();
93
+ setup.device.additionalValues = device;
94
+ const flowData = pipeline.createFlowData();
95
+ const result = await flowData.process();
96
+ // Call the method.
97
+ Helpers.setResponseHeaders(response, result);
98
+ // Check the correct headers were added to the response.
99
+ for (const [key, value] of Object.entries(expectedHeaders)) {
100
+ if (value === 'nil') {
101
+ expect(response.getHeader('Accept-CH')).toBe(undefined);
102
+ } else {
103
+ expect(response.getHeader(key)).toBe(value);
104
+ }
106
105
  }
107
- }
108
-
109
- });
106
+ });
110
107
 
111
108
  test('testGetResponseHeaderValue - append to existing header', async () => {
112
109
  // Set up a mock repsonse object to collect the headers which are
113
110
  // added to it.
114
- var response = httpMocks.createResponse();
115
- response.setHeader("Accept-CH", "existing");
116
- setup.device.additionalValues = { "SetHeaderBrowserAccept-CH": browserValue };
111
+ const response = httpMocks.createResponse();
112
+ response.setHeader('Accept-CH', 'existing');
113
+ setup.device.additionalValues = { 'SetHeaderBrowserAccept-CH': browserValue };
117
114
  const flowData = pipeline.createFlowData();
118
- var result = await flowData.process();
115
+ const result = await flowData.process();
119
116
  // Call the method.
120
117
  Helpers.setResponseHeaders(response, result);
121
118
  // Check the correct headers were added to the response.
122
- expect(response.getHeader("Accept-CH")).toBe(`existing,${browserValue.value}`);
123
- });
119
+ expect(response.getHeader('Accept-CH')).toBe(`existing,${browserValue.value}`);
120
+ });
File without changes