@autofleet/settings 1.0.6 → 1.0.7
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/dist/index.test.js +17 -4
- package/package.json +1 -1
- package/src/index.test.ts +21 -5
package/dist/index.test.js
CHANGED
|
@@ -183,11 +183,24 @@ describe('Settings', () => {
|
|
|
183
183
|
process.env.NODE_ENV = 'node-common-test';
|
|
184
184
|
}));
|
|
185
185
|
it('can get multiple settings', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
186
|
-
const mock = mockMultipleSettings(['key0', 'key1', 'key2'], [
|
|
186
|
+
const mock = mockMultipleSettings(['key0', 'key1', 'key2'], [
|
|
187
|
+
{
|
|
188
|
+
key: 'key0',
|
|
189
|
+
value: 'value0',
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
key: 'key1',
|
|
193
|
+
value: 'value1',
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
key: 'key2',
|
|
197
|
+
value: 'value2',
|
|
198
|
+
},
|
|
199
|
+
]);
|
|
187
200
|
const settings = new index_1.default({
|
|
188
201
|
serviceUrl: `http://${serviceUrl}/`,
|
|
189
202
|
});
|
|
190
|
-
const
|
|
203
|
+
const settingObjects = yield settings.getMultiple([
|
|
191
204
|
{
|
|
192
205
|
key: 'key0',
|
|
193
206
|
defaultValue: 'defaultValue0',
|
|
@@ -202,8 +215,8 @@ describe('Settings', () => {
|
|
|
202
215
|
},
|
|
203
216
|
], []);
|
|
204
217
|
expect(mock.isDone()).toBeTruthy();
|
|
205
|
-
|
|
206
|
-
expect(
|
|
218
|
+
settingObjects.forEach((obj, index) => {
|
|
219
|
+
expect(obj.value).toEqual(`value${index}`);
|
|
207
220
|
});
|
|
208
221
|
}));
|
|
209
222
|
});
|
package/package.json
CHANGED
package/src/index.test.ts
CHANGED
|
@@ -15,7 +15,7 @@ const mockSetting = (key: string, value: string | boolean | number | never, labe
|
|
|
15
15
|
return n.reply(response, { value });
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
const mockMultipleSettings = (keys: string[], values:
|
|
18
|
+
const mockMultipleSettings = (keys: string[], values: any[], response = 200) => {
|
|
19
19
|
const n = nock(`http://${serviceUrl}`)
|
|
20
20
|
.get('/api/v1/settings')
|
|
21
21
|
.query({
|
|
@@ -210,13 +210,29 @@ describe('Settings', () => {
|
|
|
210
210
|
});
|
|
211
211
|
|
|
212
212
|
it('can get multiple settings', async () => {
|
|
213
|
-
const mock = mockMultipleSettings(
|
|
213
|
+
const mock = mockMultipleSettings(
|
|
214
|
+
['key0', 'key1', 'key2'],
|
|
215
|
+
[
|
|
216
|
+
{
|
|
217
|
+
key: 'key0',
|
|
218
|
+
value: 'value0',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
key: 'key1',
|
|
222
|
+
value: 'value1',
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
key: 'key2',
|
|
226
|
+
value: 'value2',
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
|
+
);
|
|
214
230
|
|
|
215
231
|
const settings = new Settings({
|
|
216
232
|
serviceUrl: `http://${serviceUrl}/`,
|
|
217
233
|
});
|
|
218
234
|
|
|
219
|
-
const
|
|
235
|
+
const settingObjects = await settings.getMultiple([
|
|
220
236
|
{
|
|
221
237
|
key: 'key0',
|
|
222
238
|
defaultValue: 'defaultValue0',
|
|
@@ -232,8 +248,8 @@ describe('Settings', () => {
|
|
|
232
248
|
], []);
|
|
233
249
|
|
|
234
250
|
expect(mock.isDone()).toBeTruthy();
|
|
235
|
-
|
|
236
|
-
expect(
|
|
251
|
+
settingObjects.forEach((obj: any, index: number) => {
|
|
252
|
+
expect(obj.value).toEqual(`value${index}`);
|
|
237
253
|
});
|
|
238
254
|
});
|
|
239
255
|
});
|