cozy-client 46.10.0 → 46.10.1

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.
@@ -2782,7 +2782,7 @@ var CozyClient = /*#__PURE__*/function () {
2782
2782
  CozyClient.hooks = CozyClient.hooks || {};
2783
2783
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2784
2784
 
2785
- CozyClient.version = "46.10.0";
2785
+ CozyClient.version = "46.10.1";
2786
2786
 
2787
2787
  _microee.default.mixin(CozyClient);
2788
2788
 
@@ -22,7 +22,7 @@ exports.CONTACTS_DOCTYPE = CONTACTS_DOCTYPE;
22
22
 
23
23
  var getPrimaryOrFirst = function getPrimaryOrFirst(property) {
24
24
  return function (obj) {
25
- return !obj[property] || obj[property].length === 0 ? '' : obj[property].find(function (property) {
25
+ return !obj || !obj[property] || obj[property].length === 0 || !obj[property][0] ? '' : obj[property].find(function (property) {
26
26
  return property.primary;
27
27
  }) || obj[property][0];
28
28
  };
@@ -15,6 +15,12 @@ import {
15
15
  } from './contact'
16
16
 
17
17
  describe('getPrimaryOrFirst', () => {
18
+ it('should not crash if array is undefined, or contents null/undefined', () => {
19
+ expect(getPrimaryOrFirst('email')({ email: undefined })).toEqual('')
20
+ expect(getPrimaryOrFirst('email')({ email: [null] })).toEqual('')
21
+ expect(getPrimaryOrFirst('email')({ email: [undefined] })).toEqual('')
22
+ })
23
+
18
24
  it("should return the first contact's email address if no primary", () => {
19
25
  const contact = {
20
26
  email: [
@@ -136,6 +142,12 @@ describe('getInitials', () => {
136
142
  })
137
143
 
138
144
  describe('getPrimaryCozy', () => {
145
+ it('should not crash if array is undefined, or contents null/undefined', () => {
146
+ expect(getPrimaryCozy({ cozy: undefined })).toEqual(undefined)
147
+ expect(getPrimaryCozy({ cozy: [null] })).toEqual('')
148
+ expect(getPrimaryCozy({ cozy: [undefined] })).toEqual('')
149
+ })
150
+
139
151
  it('should return the main cozy', () => {
140
152
  const contact = {
141
153
  cozy: [
@@ -178,6 +190,12 @@ describe('getPrimaryCozy', () => {
178
190
  })
179
191
 
180
192
  describe('getPrimaryPhone', () => {
193
+ it('should not crash if array is undefined, or contents null/undefined', () => {
194
+ expect(getPrimaryPhone({ phone: undefined })).toEqual('')
195
+ expect(getPrimaryPhone({ phone: [null] })).toEqual('')
196
+ expect(getPrimaryPhone({ phone: [undefined] })).toEqual('')
197
+ })
198
+
181
199
  it('should return the main phone number', () => {
182
200
  const contact = {
183
201
  phone: [
@@ -192,6 +210,12 @@ describe('getPrimaryPhone', () => {
192
210
  })
193
211
 
194
212
  describe('getPrimaryAddress', () => {
213
+ it('should not crash if array is undefined, or contents null/undefined', () => {
214
+ expect(getPrimaryAddress({ address: undefined })).toEqual('')
215
+ expect(getPrimaryAddress({ address: [null] })).toEqual('')
216
+ expect(getPrimaryAddress({ address: [undefined] })).toEqual('')
217
+ })
218
+
195
219
  it('should return the main address', () => {
196
220
  const contact = {
197
221
  name: {
@@ -438,6 +462,12 @@ describe('makeDisplayName', () => {
438
462
  })
439
463
 
440
464
  describe('getPrimaryEmail', () => {
465
+ it('should not crash if array is undefined, or contents null/undefined', () => {
466
+ expect(getPrimaryEmail({ email: undefined })).toEqual(undefined)
467
+ expect(getPrimaryEmail({ email: [null] })).toEqual('')
468
+ expect(getPrimaryEmail({ email: [undefined] })).toEqual('')
469
+ })
470
+
441
471
  it('should return the main email', () => {
442
472
  const contact = {
443
473
  email: [
@@ -609,6 +639,12 @@ describe('makeDefaultSortIndexValue', () => {
609
639
  })
610
640
 
611
641
  describe('getPrimaryCozyDomain', () => {
642
+ it('should not crash if array is undefined, or contents null/undefined', () => {
643
+ expect(getPrimaryCozyDomain({ cozy: undefined })).toEqual(undefined)
644
+ expect(getPrimaryCozyDomain({ cozy: [null] })).toEqual('')
645
+ expect(getPrimaryCozyDomain({ cozy: [undefined] })).toEqual('')
646
+ })
647
+
612
648
  it('should returns empty string if no cozy url', () => {
613
649
  const contact = {
614
650
  cozy: [{ url: '' }]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "46.10.0",
3
+ "version": "46.10.1",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.node.js",
6
6
  "browser": "dist/index.js",
@@ -75,5 +75,5 @@
75
75
  "react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
76
76
  },
77
77
  "sideEffects": false,
78
- "gitHead": "97faf6da325ae1051675f67dd455090cdc88f17c"
78
+ "gitHead": "68d9fab92251c68a202c3eed18f479a0eca1a945"
79
79
  }