@sphereon/ssi-sdk.data-store 0.18.2-next.9 → 0.18.2-next.94

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.
Files changed (55) hide show
  1. package/dist/contact/AbstractContactStore.d.ts +11 -1
  2. package/dist/contact/AbstractContactStore.d.ts.map +1 -1
  3. package/dist/contact/AbstractContactStore.js.map +1 -1
  4. package/dist/contact/ContactStore.d.ts +27 -15
  5. package/dist/contact/ContactStore.d.ts.map +1 -1
  6. package/dist/contact/ContactStore.js +201 -32
  7. package/dist/contact/ContactStore.js.map +1 -1
  8. package/dist/entities/contact/ElectronicAddressEntity.d.ts +1 -0
  9. package/dist/entities/contact/ElectronicAddressEntity.d.ts.map +1 -1
  10. package/dist/entities/contact/ElectronicAddressEntity.js +4 -0
  11. package/dist/entities/contact/ElectronicAddressEntity.js.map +1 -1
  12. package/dist/entities/contact/IdentityEntity.d.ts +1 -1
  13. package/dist/entities/contact/IdentityEntity.d.ts.map +1 -1
  14. package/dist/entities/contact/PartyEntity.d.ts +2 -0
  15. package/dist/entities/contact/PartyEntity.d.ts.map +1 -1
  16. package/dist/entities/contact/PartyEntity.js +12 -1
  17. package/dist/entities/contact/PartyEntity.js.map +1 -1
  18. package/dist/entities/contact/PhysicalAddressEntity.d.ts +21 -0
  19. package/dist/entities/contact/PhysicalAddressEntity.d.ts.map +1 -0
  20. package/dist/entities/contact/PhysicalAddressEntity.js +126 -0
  21. package/dist/entities/contact/PhysicalAddressEntity.js.map +1 -0
  22. package/dist/index.d.ts +2 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +4 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/issuanceBranding/IssuanceBrandingStore.d.ts.map +1 -1
  27. package/dist/issuanceBranding/IssuanceBrandingStore.js +76 -60
  28. package/dist/issuanceBranding/IssuanceBrandingStore.js.map +1 -1
  29. package/dist/migrations/sqlite/1690925872693-CreateContacts.d.ts.map +1 -1
  30. package/dist/migrations/sqlite/1690925872693-CreateContacts.js +3 -6
  31. package/dist/migrations/sqlite/1690925872693-CreateContacts.js.map +1 -1
  32. package/dist/types/contact/IAbstractContactStore.d.ts +36 -1
  33. package/dist/types/contact/IAbstractContactStore.d.ts.map +1 -1
  34. package/dist/types/contact/contact.d.ts +27 -4
  35. package/dist/types/contact/contact.d.ts.map +1 -1
  36. package/dist/types/contact/contact.js.map +1 -1
  37. package/dist/utils/contact/MappingUtils.d.ts +4 -1
  38. package/dist/utils/contact/MappingUtils.d.ts.map +1 -1
  39. package/dist/utils/contact/MappingUtils.js +37 -1
  40. package/dist/utils/contact/MappingUtils.js.map +1 -1
  41. package/package.json +4 -4
  42. package/src/__tests__/contact.entities.test.ts +340 -23
  43. package/src/__tests__/contact.store.test.ts +629 -10
  44. package/src/contact/AbstractContactStore.ts +38 -16
  45. package/src/contact/ContactStore.ts +278 -58
  46. package/src/entities/contact/ElectronicAddressEntity.ts +3 -0
  47. package/src/entities/contact/IdentityEntity.ts +1 -1
  48. package/src/entities/contact/PartyEntity.ts +11 -1
  49. package/src/entities/contact/PhysicalAddressEntity.ts +87 -0
  50. package/src/index.ts +3 -0
  51. package/src/issuanceBranding/IssuanceBrandingStore.ts +83 -69
  52. package/src/migrations/sqlite/1690925872693-CreateContacts.ts +3 -8
  53. package/src/types/contact/IAbstractContactStore.ts +58 -8
  54. package/src/types/contact/contact.ts +40 -4
  55. package/src/utils/contact/MappingUtils.ts +39 -0
@@ -1,37 +1,41 @@
1
1
  import { DataSource, FindOptionsWhere } from 'typeorm'
2
-
3
2
  import { DataStoreContactEntities, DataStoreMigrations } from '../index'
3
+ import { BaseContactEntity } from '../entities/contact/BaseContactEntity'
4
+ import { ConnectionEntity } from '../entities/contact/ConnectionEntity'
5
+ import { CorrelationIdentifierEntity } from '../entities/contact/CorrelationIdentifierEntity'
6
+ import { DidAuthConfigEntity } from '../entities/contact/DidAuthConfigEntity'
7
+ import { ElectronicAddressEntity } from '../entities/contact/ElectronicAddressEntity'
8
+ import { IdentityEntity } from '../entities/contact/IdentityEntity'
9
+ import { IdentityMetadataItemEntity } from '../entities/contact/IdentityMetadataItemEntity'
4
10
  import { NaturalPersonEntity } from '../entities/contact/NaturalPersonEntity'
11
+ import { OpenIdConfigEntity } from '../entities/contact/OpenIdConfigEntity'
5
12
  import { OrganizationEntity } from '../entities/contact/OrganizationEntity'
13
+ import { PartyEntity } from '../entities/contact/PartyEntity'
6
14
  import { PartyRelationshipEntity } from '../entities/contact/PartyRelationshipEntity'
7
15
  import { PartyTypeEntity } from '../entities/contact/PartyTypeEntity'
8
- import { PartyEntity } from '../entities/contact/PartyEntity'
9
- import { IdentityEntity } from '../entities/contact/IdentityEntity'
10
- import { OpenIdConfigEntity } from '../entities/contact/OpenIdConfigEntity'
11
- import { DidAuthConfigEntity } from '../entities/contact/DidAuthConfigEntity'
12
- import { ConnectionEntity } from '../entities/contact/ConnectionEntity'
13
- import { CorrelationIdentifierEntity } from '../entities/contact/CorrelationIdentifierEntity'
14
- import { IdentityMetadataItemEntity } from '../entities/contact/IdentityMetadataItemEntity'
15
- import { BaseContactEntity } from '../entities/contact/BaseContactEntity'
16
+ import { PhysicalAddressEntity } from '../entities/contact/PhysicalAddressEntity'
16
17
  import {
17
- NonPersistedParty,
18
- PartyTypeEnum,
19
- NaturalPerson,
20
- Organization,
21
- IdentityRoleEnum,
22
- CorrelationIdentifierEnum,
23
18
  ConnectionTypeEnum,
24
- NonPersistedPartyType,
25
- NonPersistedOrganization,
26
- NonPersistedNaturalPerson,
19
+ CorrelationIdentifierEnum,
20
+ IdentityRoleEnum,
21
+ NaturalPerson,
27
22
  NonPersistedConnection,
28
- NonPersistedIdentity,
29
23
  NonPersistedDidAuthConfig,
24
+ NonPersistedElectronicAddress,
25
+ NonPersistedIdentity,
26
+ NonPersistedNaturalPerson,
30
27
  NonPersistedOpenIdConfig,
28
+ NonPersistedOrganization,
29
+ NonPersistedParty,
30
+ NonPersistedPartyType,
31
+ NonPersistedPhysicalAddress,
32
+ Organization,
33
+ PartyTypeEnum,
31
34
  } from '../types'
32
35
  import {
33
36
  connectionEntityFrom,
34
37
  didAuthConfigEntityFrom,
38
+ electronicAddressEntityFrom,
35
39
  identityEntityFrom,
36
40
  naturalPersonEntityFrom,
37
41
  openIdConfigEntityFrom,
@@ -39,6 +43,7 @@ import {
39
43
  partyEntityFrom,
40
44
  partyRelationshipEntityFrom,
41
45
  partyTypeEntityFrom,
46
+ physicalAddressEntityFrom,
42
47
  } from '../utils/contact/MappingUtils'
43
48
 
44
49
  // TODO write test adding two contacts reusing the same contactType
@@ -81,12 +86,12 @@ describe('Database entities tests', (): void => {
81
86
  }
82
87
 
83
88
  const partyEntity: PartyEntity = partyEntityFrom(party)
84
- await dbConnection.getRepository(PartyEntity).save(partyEntity, {
89
+ const savedParty: PartyEntity = await dbConnection.getRepository(PartyEntity).save(partyEntity, {
85
90
  transaction: true,
86
91
  })
87
92
 
88
93
  const fromDb: PartyEntity | null = await dbConnection.getRepository(PartyEntity).findOne({
89
- where: { id: partyEntity.id },
94
+ where: { id: savedParty.id },
90
95
  })
91
96
 
92
97
  expect(fromDb).toBeDefined()
@@ -118,12 +123,12 @@ describe('Database entities tests', (): void => {
118
123
  }
119
124
 
120
125
  const partyEntity: PartyEntity = partyEntityFrom(party)
121
- await dbConnection.getRepository(PartyEntity).save(partyEntity, {
126
+ const savedParty: PartyEntity = await dbConnection.getRepository(PartyEntity).save(partyEntity, {
122
127
  transaction: true,
123
128
  })
124
129
 
125
130
  const fromDb: PartyEntity | null = await dbConnection.getRepository(PartyEntity).findOne({
126
- where: { id: partyEntity.id },
131
+ where: { id: savedParty.id },
127
132
  })
128
133
 
129
134
  expect(fromDb).toBeDefined()
@@ -838,6 +843,19 @@ describe('Database entities tests', (): void => {
838
843
 
839
844
  expect(savedIdentity).toBeDefined()
840
845
 
846
+ const electronicAddress: NonPersistedElectronicAddress = {
847
+ type: 'email',
848
+ electronicAddress: 'example_electronic_address',
849
+ }
850
+ const electronicAddressEntity: ElectronicAddressEntity = electronicAddressEntityFrom(electronicAddress)
851
+ electronicAddressEntity.party = savedParty1
852
+
853
+ const savedElectronicAddress: ElectronicAddressEntity | null = await dbConnection
854
+ .getRepository(ElectronicAddressEntity)
855
+ .save(electronicAddressEntity)
856
+
857
+ expect(savedElectronicAddress).toBeDefined()
858
+
841
859
  const relationship: PartyRelationshipEntity = partyRelationshipEntityFrom({
842
860
  leftId: savedParty1.id,
843
861
  rightId: savedParty2.id,
@@ -899,6 +917,13 @@ describe('Database entities tests', (): void => {
899
917
  })
900
918
  ).toBeNull()
901
919
 
920
+ // check electronic address
921
+ expect(
922
+ await dbConnection.getRepository(ElectronicAddressEntity).findOne({
923
+ where: { id: savedParty1.id },
924
+ })
925
+ ).toBeNull()
926
+
902
927
  // check contact
903
928
  expect(
904
929
  await dbConnection.getRepository(BaseContactEntity).findOne({
@@ -2172,4 +2197,296 @@ describe('Database entities tests', (): void => {
2172
2197
  expect(fromDb).toBeDefined()
2173
2198
  expect(fromDb?.createdAt).toEqual(savedPartyType?.createdAt)
2174
2199
  })
2200
+
2201
+ it('Should save email electronic address to database', async (): Promise<void> => {
2202
+ const electronicAddress: NonPersistedElectronicAddress = {
2203
+ type: 'email',
2204
+ electronicAddress: 'example_email_address',
2205
+ }
2206
+
2207
+ const electronicAddressEntity: ElectronicAddressEntity = electronicAddressEntityFrom(electronicAddress)
2208
+ const savedElectronicAddress: ElectronicAddressEntity = await dbConnection.getRepository(ElectronicAddressEntity).save(electronicAddressEntity, {
2209
+ transaction: true,
2210
+ })
2211
+
2212
+ const fromDb: ElectronicAddressEntity | null = await dbConnection.getRepository(ElectronicAddressEntity).findOne({
2213
+ where: { id: savedElectronicAddress.id },
2214
+ })
2215
+
2216
+ expect(fromDb).toBeDefined()
2217
+ expect(fromDb?.type).toEqual(electronicAddress.type)
2218
+ expect(fromDb?.electronicAddress).toEqual(electronicAddress.electronicAddress)
2219
+ expect(fromDb?.createdAt).toBeDefined()
2220
+ expect(fromDb?.lastUpdatedAt).toBeDefined()
2221
+ })
2222
+
2223
+ it('Should save phone electronic address to database', async (): Promise<void> => {
2224
+ const electronicAddress: NonPersistedElectronicAddress = {
2225
+ type: 'phone',
2226
+ electronicAddress: 'example_phone_number',
2227
+ }
2228
+
2229
+ const electronicAddressEntity: ElectronicAddressEntity = electronicAddressEntityFrom(electronicAddress)
2230
+ const savedElectronicAddress: ElectronicAddressEntity = await dbConnection.getRepository(ElectronicAddressEntity).save(electronicAddressEntity, {
2231
+ transaction: true,
2232
+ })
2233
+
2234
+ const fromDb: ElectronicAddressEntity | null = await dbConnection.getRepository(ElectronicAddressEntity).findOne({
2235
+ where: { id: savedElectronicAddress.id },
2236
+ })
2237
+
2238
+ expect(fromDb).toBeDefined()
2239
+ expect(fromDb?.type).toEqual(electronicAddress.type)
2240
+ expect(fromDb?.electronicAddress).toEqual(electronicAddress.electronicAddress)
2241
+ expect(fromDb?.createdAt).toBeDefined()
2242
+ expect(fromDb?.lastUpdatedAt).toBeDefined()
2243
+ })
2244
+
2245
+ it('should throw error when saving electronic address with blank electronic address', async (): Promise<void> => {
2246
+ const electronicAddress: NonPersistedElectronicAddress = {
2247
+ type: 'email',
2248
+ electronicAddress: '',
2249
+ }
2250
+
2251
+ const electronicAddressEntity: ElectronicAddressEntity = electronicAddressEntityFrom(electronicAddress)
2252
+
2253
+ await expect(dbConnection.getRepository(ElectronicAddressEntity).save(electronicAddressEntity)).rejects.toThrowError(
2254
+ 'Blank electronic addresses are not allowed'
2255
+ )
2256
+ })
2257
+
2258
+ it('Should save home physical address to database', async (): Promise<void> => {
2259
+ const physicalAddress: NonPersistedPhysicalAddress = {
2260
+ type: 'home',
2261
+ streetName: 'example_street_name',
2262
+ streetNumber: 'example_street_number',
2263
+ buildingName: 'example_building_name',
2264
+ postalCode: 'example_postal_code',
2265
+ cityName: 'example_city_name',
2266
+ provinceName: 'example_province_name',
2267
+ countryCode: 'example_country_code',
2268
+ }
2269
+
2270
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2271
+ const savedPhysicalAddress: PhysicalAddressEntity = await dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity, {
2272
+ transaction: true,
2273
+ })
2274
+
2275
+ const fromDb: PhysicalAddressEntity | null = await dbConnection.getRepository(PhysicalAddressEntity).findOne({
2276
+ where: { id: savedPhysicalAddress.id },
2277
+ })
2278
+
2279
+ expect(fromDb).toBeDefined()
2280
+ expect(fromDb?.type).toEqual(physicalAddress.type)
2281
+ expect(fromDb?.streetName).toEqual(physicalAddress.streetName)
2282
+ expect(fromDb?.streetNumber).toEqual(physicalAddress.streetNumber)
2283
+ expect(fromDb?.buildingName).toEqual(physicalAddress.buildingName)
2284
+ expect(fromDb?.postalCode).toEqual(physicalAddress.postalCode)
2285
+ expect(fromDb?.cityName).toEqual(physicalAddress.cityName)
2286
+ expect(fromDb?.provinceName).toEqual(physicalAddress.provinceName)
2287
+ expect(fromDb?.countryCode).toEqual(physicalAddress.countryCode)
2288
+ expect(fromDb?.createdAt).toBeDefined()
2289
+ expect(fromDb?.lastUpdatedAt).toBeDefined()
2290
+ })
2291
+
2292
+ it('Should save visit physical address to database', async (): Promise<void> => {
2293
+ const physicalAddress: NonPersistedPhysicalAddress = {
2294
+ type: 'visit',
2295
+ streetName: 'example_street_name',
2296
+ streetNumber: 'example_street_number',
2297
+ buildingName: 'example_building_name',
2298
+ postalCode: 'example_postal_code',
2299
+ cityName: 'example_city_name',
2300
+ provinceName: 'example_province_name',
2301
+ countryCode: 'example_country_code',
2302
+ }
2303
+
2304
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2305
+ const savedPhysicalAddress: PhysicalAddressEntity = await dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity, {
2306
+ transaction: true,
2307
+ })
2308
+
2309
+ const fromDb: PhysicalAddressEntity | null = await dbConnection.getRepository(PhysicalAddressEntity).findOne({
2310
+ where: { id: savedPhysicalAddress.id },
2311
+ })
2312
+
2313
+ expect(fromDb).toBeDefined()
2314
+ expect(fromDb?.type).toEqual(physicalAddress.type)
2315
+ expect(fromDb?.streetName).toEqual(physicalAddress.streetName)
2316
+ expect(fromDb?.streetNumber).toEqual(physicalAddress.streetNumber)
2317
+ expect(fromDb?.buildingName).toEqual(physicalAddress.buildingName)
2318
+ expect(fromDb?.postalCode).toEqual(physicalAddress.postalCode)
2319
+ expect(fromDb?.cityName).toEqual(physicalAddress.cityName)
2320
+ expect(fromDb?.provinceName).toEqual(physicalAddress.provinceName)
2321
+ expect(fromDb?.countryCode).toEqual(physicalAddress.countryCode)
2322
+ expect(fromDb?.createdAt).toBeDefined()
2323
+ expect(fromDb?.lastUpdatedAt).toBeDefined()
2324
+ })
2325
+
2326
+ it('Should save postal physical address to database', async (): Promise<void> => {
2327
+ const physicalAddress: NonPersistedPhysicalAddress = {
2328
+ type: 'postal',
2329
+ streetName: 'example_street_name',
2330
+ streetNumber: 'example_street_number',
2331
+ buildingName: 'example_building_name',
2332
+ postalCode: 'example_postal_code',
2333
+ cityName: 'example_city_name',
2334
+ provinceName: 'example_province_name',
2335
+ countryCode: 'example_country_code',
2336
+ }
2337
+
2338
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2339
+ const savedPhysicalAddress: PhysicalAddressEntity = await dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity, {
2340
+ transaction: true,
2341
+ })
2342
+
2343
+ const fromDb: PhysicalAddressEntity | null = await dbConnection.getRepository(PhysicalAddressEntity).findOne({
2344
+ where: { id: savedPhysicalAddress.id },
2345
+ })
2346
+
2347
+ expect(fromDb).toBeDefined()
2348
+ expect(fromDb?.type).toEqual(physicalAddress.type)
2349
+ expect(fromDb?.streetName).toEqual(physicalAddress.streetName)
2350
+ expect(fromDb?.streetNumber).toEqual(physicalAddress.streetNumber)
2351
+ expect(fromDb?.buildingName).toEqual(physicalAddress.buildingName)
2352
+ expect(fromDb?.postalCode).toEqual(physicalAddress.postalCode)
2353
+ expect(fromDb?.cityName).toEqual(physicalAddress.cityName)
2354
+ expect(fromDb?.provinceName).toEqual(physicalAddress.provinceName)
2355
+ expect(fromDb?.countryCode).toEqual(physicalAddress.countryCode)
2356
+ expect(fromDb?.createdAt).toBeDefined()
2357
+ expect(fromDb?.lastUpdatedAt).toBeDefined()
2358
+ })
2359
+
2360
+ it('should throw error when saving physical address with blank street name', async (): Promise<void> => {
2361
+ const physicalAddress: NonPersistedPhysicalAddress = {
2362
+ type: 'home',
2363
+ streetName: '',
2364
+ streetNumber: 'example_street_number',
2365
+ buildingName: 'example_building_name',
2366
+ postalCode: 'example_postal_code',
2367
+ cityName: 'example_city_name',
2368
+ provinceName: 'example_province_name',
2369
+ countryCode: 'example_country_code',
2370
+ }
2371
+
2372
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2373
+
2374
+ await expect(dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity)).rejects.toThrowError(
2375
+ 'Blank street names are not allowed'
2376
+ )
2377
+ })
2378
+
2379
+ it('should throw error when saving physical address with blank street number', async (): Promise<void> => {
2380
+ const physicalAddress: NonPersistedPhysicalAddress = {
2381
+ type: 'home',
2382
+ streetName: 'example_street_name',
2383
+ streetNumber: '',
2384
+ buildingName: 'example_building_name',
2385
+ postalCode: 'example_postal_code',
2386
+ cityName: 'example_city_name',
2387
+ provinceName: 'example_province_name',
2388
+ countryCode: 'example_country_code',
2389
+ }
2390
+
2391
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2392
+
2393
+ await expect(dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity)).rejects.toThrowError(
2394
+ 'Blank street numbers are not allowed'
2395
+ )
2396
+ })
2397
+
2398
+ it('should throw error when saving physical address with blank building name', async (): Promise<void> => {
2399
+ const physicalAddress: NonPersistedPhysicalAddress = {
2400
+ type: 'home',
2401
+ streetName: 'example_street_name',
2402
+ streetNumber: 'example_street_number',
2403
+ buildingName: '',
2404
+ postalCode: 'example_postal_code',
2405
+ cityName: 'example_city_name',
2406
+ provinceName: 'example_province_name',
2407
+ countryCode: 'example_country_code',
2408
+ }
2409
+
2410
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2411
+
2412
+ await expect(dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity)).rejects.toThrowError(
2413
+ 'Blank building names are not allowed'
2414
+ )
2415
+ })
2416
+
2417
+ it('should throw error when saving physical address with blank postal code', async (): Promise<void> => {
2418
+ const physicalAddress: NonPersistedPhysicalAddress = {
2419
+ type: 'home',
2420
+ streetName: 'example_street_name',
2421
+ streetNumber: 'example_street_number',
2422
+ buildingName: 'example_building_name',
2423
+ postalCode: '',
2424
+ cityName: 'example_city_name',
2425
+ provinceName: 'example_province_name',
2426
+ countryCode: 'example_country_code',
2427
+ }
2428
+
2429
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2430
+
2431
+ await expect(dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity)).rejects.toThrowError(
2432
+ 'Blank postal codes are not allowed'
2433
+ )
2434
+ })
2435
+
2436
+ it('should throw error when saving physical address with blank city name', async (): Promise<void> => {
2437
+ const physicalAddress: NonPersistedPhysicalAddress = {
2438
+ type: 'home',
2439
+ streetName: 'example_street_name',
2440
+ streetNumber: 'example_street_number',
2441
+ buildingName: 'example_building_name',
2442
+ postalCode: 'example_postal_code',
2443
+ cityName: '',
2444
+ provinceName: 'example_province_name',
2445
+ countryCode: 'example_country_code',
2446
+ }
2447
+
2448
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2449
+
2450
+ await expect(dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity)).rejects.toThrowError(
2451
+ 'Blank city names are not allowed'
2452
+ )
2453
+ })
2454
+
2455
+ it('should throw error when saving physical address with blank province name', async (): Promise<void> => {
2456
+ const physicalAddress: NonPersistedPhysicalAddress = {
2457
+ type: 'home',
2458
+ streetName: 'example_street_name',
2459
+ streetNumber: 'example_street_number',
2460
+ buildingName: 'example_building_name',
2461
+ postalCode: 'example_postal_code',
2462
+ cityName: 'example_city_name',
2463
+ provinceName: '',
2464
+ countryCode: 'example_country_code',
2465
+ }
2466
+
2467
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2468
+
2469
+ await expect(dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity)).rejects.toThrowError(
2470
+ 'Blank province names are not allowed'
2471
+ )
2472
+ })
2473
+
2474
+ it('should throw error when saving physical address with blank country code', async (): Promise<void> => {
2475
+ const physicalAddress: NonPersistedPhysicalAddress = {
2476
+ type: 'home',
2477
+ streetName: 'example_street_name',
2478
+ streetNumber: 'example_street_number',
2479
+ buildingName: 'example_building_name',
2480
+ postalCode: 'example_postal_code',
2481
+ cityName: 'example_city_name',
2482
+ provinceName: 'example_province_name',
2483
+ countryCode: '',
2484
+ }
2485
+
2486
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2487
+
2488
+ await expect(dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity)).rejects.toThrowError(
2489
+ 'Blank country codes are not allowed'
2490
+ )
2491
+ })
2175
2492
  })