@autofleet/node-common 1.1.11 → 1.1.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/node-common",
3
- "version": "1.1.11",
3
+ "version": "1.1.12",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "coverage": "jest --coverage --forceExit --runInBand",
package/settings/index.js CHANGED
@@ -23,7 +23,7 @@ module.exports = class SettingsManager {
23
23
  }
24
24
 
25
25
  async get(key, defaultValue, labels = []) {
26
- if (!defaultValue) {
26
+ if (typeof defaultValue === 'undefined') {
27
27
  throw new Error('Can\'t get a key without defaultValue');
28
28
  }
29
29
 
@@ -18,6 +18,22 @@ describe('Settings', () => {
18
18
  .rejects.toEqual(new Error('Can\'t get a key without defaultValue'));
19
19
  });
20
20
 
21
+ it('Can get 0 as default value', async () => {
22
+ const settings = new Settings({
23
+ serviceUrl: `http://${serviceUrl}/`,
24
+ });
25
+
26
+ expect(await settings.get('key1', 0)).toBe(0);
27
+ });
28
+
29
+ it('Can get false as default value', async () => {
30
+ const settings = new Settings({
31
+ serviceUrl: `http://${serviceUrl}/`,
32
+ });
33
+
34
+ expect(await settings.get('key1', false)).toBe(false);
35
+ });
36
+
21
37
  it('Uses env.SETTING_MS_SERVICE_HOST as serivce host if no one defind', async () => {
22
38
  const m = mockSetting('key1', 'value1');
23
39
  process.env.SETTING_MS_SERVICE_HOST = serviceUrl;