@rebilly/instruments 3.15.0-beta.0 → 3.15.1-beta.0

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": "@rebilly/instruments",
3
- "version": "3.15.0-beta.0",
3
+ "version": "3.15.1-beta.0",
4
4
  "author": "Rebilly",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,39 @@
1
+ import { StorefontTestingInstance } from 'tests/mocks/storefront-mock';
2
+ import { ok, get } from 'msw-when-then';
3
+ import { when } from 'tests/msw/server';
4
+ import { storefrontURL } from 'tests/mocks/storefront-api-mock';
5
+ import { fetchAccount } from './account';
6
+ import { AddressModel } from './models/account-model';
7
+
8
+ describe('Storefront API Account', () => {
9
+ it('should handle fetch a customer with a null primary address', async () => {
10
+ const options = {
11
+ jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzYjBkNTRkOS0xNmM4LTRlZDAtYjljMy01ODAyZmQ4YzE2ZTIiLCJleHAiOjE2ODY2OTc0MTQuODQxMjUsImlhdCI6MTY1NTE2MTQxNC44Nzk4OTEsImFjbCI6W3sic2NvcGUiOnsib3JnYW5pemF0aW9uSWQiOlsiMzY0NEFGTEFKMUciXSwicGF5bWVudE1ldGhvZHMiOlsicGF5bWVudC1jYXJkIl19LCJwZXJtaXNzaW9ucyI6WzI4NCwyODYsNDE0LDQxNSw0MzQsNDExLDQxMiw0MTMsNDI0LDQyNSw0MjYsNDI3LDQyOCw0MjksNDA5LDQxMCw0MDEsNDAyLDQzMyw0ODgsNDg3XX1dLCJjbGFpbXMiOnsid2Vic2l0ZUlkIjoiZGVtby13ZWJzaXRlIiwidHJhbnNhY3Rpb25JZCI6IjRiZDE3N2NmLTFlY2EtNDA2Yy04OWI0LTEzYzMzODk5NzlmMCIsInBheW1lbnRNZXRob2RzIjpbInBheW1lbnQtY2FyZCJdfSwibWVyY2hhbnQiOiIzNjQ0QUZMQUoxRyIsImN1c3RvbWVyIjp7ImlkIjoidGVzdC1jdXN0b21lci1pZCIsIm5hbWUiOiJUZXN0IEN1c3RvbWVyIE5hbWUiLCJjcmVhdGVkVGltZSI6IjIwMjItMDctMTRUMDA6MDA6MDArMDA6MDAifX0.VPue9QBhRGe3vvncaD47w84N8Bv2hEeShUl6SlNqoOQ',
12
+ websiteId: 'test-website-id',
13
+ items: [
14
+ {
15
+ planId: 'test-plan-id',
16
+ quantity: 1
17
+ }
18
+ ]
19
+ };
20
+
21
+ when(get(`${storefrontURL}/acount`)).thenReturn(
22
+ ok({
23
+ defaultPaymentInstrument: null,
24
+ id: "test-customer-id",
25
+ primaryAddress: null,
26
+ websiteId: "test-website-id",
27
+ })
28
+ );
29
+
30
+ const instance = StorefontTestingInstance({
31
+ options
32
+ });
33
+
34
+ jest.spyOn(instance.storefront.account, 'get');
35
+
36
+ const response = await fetchAccount({ state: instance });
37
+ expect(response.address).toEqual(new AddressModel({}));
38
+ })
39
+ });
@@ -30,10 +30,10 @@ export class AddressModel {
30
30
 
31
31
  export default class AccountModel extends BaseModel {
32
32
  constructor({
33
- primaryAddress = null,
33
+ primaryAddress = {},
34
34
  ...fields
35
35
  } = {}) {
36
36
  super(fields);
37
- this.address = new AddressModel(primaryAddress);
37
+ this.address = new AddressModel({...primaryAddress});
38
38
  }
39
39
  }