@adobe/exc-app 1.0.2 → 1.0.4-beta2
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/RuntimeConfiguration.d.ts +8 -0
- package/appapi.d.ts +1 -0
- package/appapi.js +1 -0
- package/appapi.js.map +1 -1
- package/cache.d.ts +132 -0
- package/cache.js +132 -0
- package/cache.js.map +1 -0
- package/capabilityapi.d.ts +2 -0
- package/capabilityapi.js +2 -0
- package/capabilityapi.js.map +1 -1
- package/docs/README.md +1 -0
- package/docs/enums/capabilityapi.capabilityids.md +7 -0
- package/docs/enums/capabilityapi.capabilitynames.md +7 -0
- package/docs/interfaces/cache.cacheapi.md +81 -0
- package/docs/interfaces/cache.cacheparameters.md +36 -0
- package/docs/interfaces/cache.cachesetparameters.md +65 -0
- package/docs/interfaces/network.apolloclientoptions.md +7 -0
- package/docs/interfaces/root.modules.md +7 -0
- package/docs/interfaces/root.runtimeconfiguration.md +9 -0
- package/docs/modules/cache.md +85 -0
- package/network/DataContract.d.ts +35 -0
- package/network/DataContract.js +3 -0
- package/network/DataContract.js.map +1 -0
- package/network/DataPrefetchContract.d.ts +110 -0
- package/network/DataPrefetchContract.js +3 -0
- package/network/DataPrefetchContract.js.map +1 -0
- package/network.d.ts +21 -0
- package/network.js +14 -1
- package/network.js.map +1 -1
- package/package.json +1 -1
- package/settings.js +2 -6
- package/settings.js.map +1 -1
- package/shell.d.ts +2 -0
- package/shell.js.map +1 -1
- package/src/Global.d.ts +2 -0
- package/src/Global.js.map +1 -1
- package/tests/cache.test.d.ts +1 -0
- package/tests/cache.test.js +66 -0
- package/tests/cache.test.js.map +1 -0
- package/tests/network.test.d.ts +1 -0
- package/tests/network.test.js +77 -0
- package/tests/network.test.js.map +1 -0
- package/tests/permissions.test.js +1 -5
- package/tests/permissions.test.js.map +1 -1
- package/tests/pulse.test.js +23 -11
- package/tests/pulse.test.js.map +1 -1
- package/tests/session.test.d.ts +1 -0
- package/tests/session.test.js +64 -0
- package/tests/session.test.js.map +1 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
**[@adobe/exc-app](../README.md)**
|
|
2
|
+
|
|
3
|
+
> [Globals](../README.md) / cache
|
|
4
|
+
|
|
5
|
+
# Module: cache
|
|
6
|
+
|
|
7
|
+
APIs for managing a client side persisted cache.
|
|
8
|
+
Unified Shell will store the data against its own domain, which allows data caching
|
|
9
|
+
even when the actual app runs on a domain which is 3rd party to Unified Shell's.
|
|
10
|
+
|
|
11
|
+
For example, the API will work in Chrome incognito when Unified Shell runs on an adobe.com domain
|
|
12
|
+
and the embedded applications run on the adobe.net domain.
|
|
13
|
+
|
|
14
|
+
These APIs utilizes the [Browser Cache API](https://developer.mozilla.org/en-US/docs/Web/API/Cache) under the hood and are all run asynchronously.
|
|
15
|
+
|
|
16
|
+
If migrating from Local Storage to Cache API, make sure all the app logic is async first.
|
|
17
|
+
|
|
18
|
+
NOTE: This API should not be used to cache any PII data to comply with Adobe privacy policies.
|
|
19
|
+
|
|
20
|
+
To consume this API, add the following import to your code.
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import cache from '@adobe/exc-app/cache';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The default export is an object of type [CacheAPI](../interfaces/_cache_.cacheapi.md)
|
|
27
|
+
|
|
28
|
+
API reference: [scroll down](#index)
|
|
29
|
+
|
|
30
|
+
### Sample code
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import cache, {CacheTTL, CacheScope} from '@adobe/exc-app/cache';
|
|
34
|
+
|
|
35
|
+
// By default, cached data is tied to the user and cached for a week.
|
|
36
|
+
await cache.set<MyType>({key: 'some-cache-key', value: myTypeInstance});
|
|
37
|
+
|
|
38
|
+
// Both scope and expiry can be adjusted.
|
|
39
|
+
await cache.set<MyType>({key: 'some-cache-key', value: myTypeInstance, expiry: CacheTTL.DAY, scope: CacheScope.ORG});
|
|
40
|
+
|
|
41
|
+
// It is also possible to bind cache data to the current IMS session, it will expire when the user logs out.
|
|
42
|
+
await cache.set<MyType>({key: 'some-cache-key', value: myTypeInstance, expiry: CacheTTL.IMS_SESSION});
|
|
43
|
+
|
|
44
|
+
// Cache get
|
|
45
|
+
const myData: MyType = await cache.get<MyType>({key: 'some-cache-key'});
|
|
46
|
+
|
|
47
|
+
// Get scope must be identical to the scope used for set - Always use the same scope for both.
|
|
48
|
+
const myData2: MyType = await cache.get<MyType>({key: 'some-cache-key', scope: CacheScope.ORG});
|
|
49
|
+
|
|
50
|
+
// Cache delete.
|
|
51
|
+
await cache.delete({key: 'some-cache-key'});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Index
|
|
55
|
+
|
|
56
|
+
### Interfaces
|
|
57
|
+
|
|
58
|
+
* [CacheApi](../interfaces/cache.cacheapi.md)
|
|
59
|
+
* [CacheParameters](../interfaces/cache.cacheparameters.md)
|
|
60
|
+
* [CacheSetParameters](../interfaces/cache.cachesetparameters.md)
|
|
61
|
+
|
|
62
|
+
### Type aliases
|
|
63
|
+
|
|
64
|
+
* [CacheEntry](cache.md#cacheentry)
|
|
65
|
+
* [CacheExpiry](cache.md#cacheexpiry)
|
|
66
|
+
|
|
67
|
+
## Type aliases
|
|
68
|
+
|
|
69
|
+
### CacheEntry
|
|
70
|
+
|
|
71
|
+
Ƭ **CacheEntry**<T\>: { createdAt: number ; key: string ; value: T } & { expiresAt: number } \| { expireBySession: true }
|
|
72
|
+
|
|
73
|
+
Cache entry (Returned by the get API).
|
|
74
|
+
|
|
75
|
+
#### Type parameters:
|
|
76
|
+
|
|
77
|
+
Name |
|
|
78
|
+
------ |
|
|
79
|
+
`T` |
|
|
80
|
+
|
|
81
|
+
___
|
|
82
|
+
|
|
83
|
+
### CacheExpiry
|
|
84
|
+
|
|
85
|
+
Ƭ **CacheExpiry**: CacheTTL \| number
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*************************************************************************
|
|
2
|
+
* Copyright 2022 Adobe
|
|
3
|
+
* All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
6
|
+
* accordance with the terms of the Adobe license agreement accompanying
|
|
7
|
+
* it. If you have received this file from a source other than Adobe,
|
|
8
|
+
* then your use, modification, or distribution of it requires the prior
|
|
9
|
+
* written permission of Adobe.
|
|
10
|
+
**************************************************************************/
|
|
11
|
+
import { CacheExpiry, CacheScope } from '../cache';
|
|
12
|
+
import { FetchScope } from '../network';
|
|
13
|
+
export interface FetchCondition {
|
|
14
|
+
serviceCodes?: string | string[];
|
|
15
|
+
}
|
|
16
|
+
export interface QueryContract<V> {
|
|
17
|
+
fetchScope: FetchScope;
|
|
18
|
+
ignoreErrorsOnPaths?: string[];
|
|
19
|
+
query: string;
|
|
20
|
+
root?: string;
|
|
21
|
+
variables: V;
|
|
22
|
+
}
|
|
23
|
+
interface DataContract<T, V = undefined> {
|
|
24
|
+
defaultValue: T;
|
|
25
|
+
expiry: CacheExpiry;
|
|
26
|
+
fetchWhen?: FetchCondition;
|
|
27
|
+
gql?: QueryContract<V>;
|
|
28
|
+
isSensitive: boolean;
|
|
29
|
+
key: string;
|
|
30
|
+
revalidate: boolean;
|
|
31
|
+
revalidateAfterSec?: number;
|
|
32
|
+
scope: CacheScope;
|
|
33
|
+
shared: boolean;
|
|
34
|
+
}
|
|
35
|
+
export default DataContract;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataContract.js","sourceRoot":"","sources":["DataContract.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/*************************************************************************
|
|
2
|
+
* Copyright 2022 Adobe
|
|
3
|
+
* All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
6
|
+
* accordance with the terms of the Adobe license agreement accompanying
|
|
7
|
+
* it. If you have received this file from a source other than Adobe,
|
|
8
|
+
* then your use, modification, or distribution of it requires the prior
|
|
9
|
+
* written permission of Adobe.
|
|
10
|
+
**************************************************************************/
|
|
11
|
+
import { CacheExpiry, CacheScope } from '../cache';
|
|
12
|
+
import { FetchScope } from '../network';
|
|
13
|
+
/**
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
* @module network
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Defines the conditions when certain data can be fetched.
|
|
19
|
+
* When conditions are not met, default data will be returned but not cached.
|
|
20
|
+
*/
|
|
21
|
+
export interface FetchCondition {
|
|
22
|
+
/**
|
|
23
|
+
* Service Codes that needs to be present (For the current org) in order to execute the query.
|
|
24
|
+
* This is useful when a query only makes sense if a certain product is provisioned for the current user.
|
|
25
|
+
*/
|
|
26
|
+
serviceCodes?: string | string[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Defines a GraphQL query that will be executed to fetch the data exposed by this contract.
|
|
30
|
+
*/
|
|
31
|
+
export interface QueryDefinition<V> {
|
|
32
|
+
/**
|
|
33
|
+
* When provided, the data at the certain path will be returned.
|
|
34
|
+
* If not provided, the entire GraphQL response will be returned.
|
|
35
|
+
*/
|
|
36
|
+
dataPath?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Fetch scope. Controls which headers are sent with the query.
|
|
39
|
+
* See fetch documentation for more info.
|
|
40
|
+
*/
|
|
41
|
+
fetchScope: FetchScope;
|
|
42
|
+
/**
|
|
43
|
+
* Do not fail (throw) when encountering errors while processing the query if the errors
|
|
44
|
+
* happened on certain paths.
|
|
45
|
+
*/
|
|
46
|
+
ignoreErrorsOnPaths?: string[];
|
|
47
|
+
/**
|
|
48
|
+
* GraphQL Query to execute.
|
|
49
|
+
*/
|
|
50
|
+
query: string;
|
|
51
|
+
/**
|
|
52
|
+
* GraphQL Query Variables (Key/value map).
|
|
53
|
+
*/
|
|
54
|
+
variables: V;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Defines a data contract which will be executed by Unified Shell on behalf ot the requesting application.
|
|
58
|
+
*/
|
|
59
|
+
export default interface DataPrefetchContract<T, V = undefined> {
|
|
60
|
+
/**
|
|
61
|
+
* Default value to return if the data execution is skipped.
|
|
62
|
+
*/
|
|
63
|
+
defaultValue: T;
|
|
64
|
+
/**
|
|
65
|
+
* Cache expiry. Can be one of the set values defined by the Cache API, or a numeric cache ttl (in seconds).
|
|
66
|
+
*/
|
|
67
|
+
expiry: CacheExpiry;
|
|
68
|
+
/**
|
|
69
|
+
* Defines the conditions when certain data can be fetched.
|
|
70
|
+
* When conditions are not met, the default value above will be returned (But not cached).
|
|
71
|
+
*/
|
|
72
|
+
fetchWhen?: FetchCondition;
|
|
73
|
+
/**
|
|
74
|
+
* GraphQL used to fulfill this data contract.
|
|
75
|
+
* Note: Currently GraphQL is the only supported method for data contracts.
|
|
76
|
+
*/
|
|
77
|
+
gql?: QueryDefinition<V>;
|
|
78
|
+
/**
|
|
79
|
+
* Is the data sensitive? (PII or other sensitive data).
|
|
80
|
+
* Sensitive data can only be cached in the browser's session storage
|
|
81
|
+
* Non-sensitive data can be cached in the standard Cache storage.
|
|
82
|
+
*/
|
|
83
|
+
isSensitive: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Unique key associated with this contract.
|
|
86
|
+
* Will be used by the calling application to get access to the data.
|
|
87
|
+
*/
|
|
88
|
+
key: string;
|
|
89
|
+
/**
|
|
90
|
+
* When true, data will be fetched even when a cache is available.
|
|
91
|
+
* In this case, the query will return the cached data and at the same time fetch fresh data from the network.
|
|
92
|
+
* (stale-while-revalidate strategy)
|
|
93
|
+
*/
|
|
94
|
+
revalidate: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Used in conjunction with revalidate = true. Threshold for revalidating data from the network.
|
|
97
|
+
* When set the query will return the cached data and if the cache is older than the set threshold,
|
|
98
|
+
* fetch fresh data from the network.
|
|
99
|
+
*/
|
|
100
|
+
revalidateAfterSec?: number;
|
|
101
|
+
/**
|
|
102
|
+
* Cache scope as defined by the Cache API.
|
|
103
|
+
*/
|
|
104
|
+
scope: CacheScope;
|
|
105
|
+
/**
|
|
106
|
+
* If true, this data will be accessible to all experience cloud applications.
|
|
107
|
+
* Otherwise, data will be cached against the requesting application.
|
|
108
|
+
*/
|
|
109
|
+
shared: boolean;
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataPrefetchContract.js","sourceRoot":"","sources":["DataPrefetchContract.ts"],"names":[],"mappings":""}
|
package/network.d.ts
CHANGED
|
@@ -371,6 +371,7 @@ export interface ApolloClientOptions {
|
|
|
371
371
|
connectToDevTools?: boolean;
|
|
372
372
|
inputApolloLink?: ApolloLink;
|
|
373
373
|
cacheOptions?: InMemoryCacheConfig;
|
|
374
|
+
xql?: boolean;
|
|
374
375
|
}
|
|
375
376
|
export interface NetworkApi {
|
|
376
377
|
/**
|
|
@@ -399,6 +400,16 @@ export interface NetworkApi {
|
|
|
399
400
|
* @returns The promise for the response to the fetch operation.
|
|
400
401
|
*/
|
|
401
402
|
fetch(input: RequestInfo, init?: FetchInit): Promise<Response>;
|
|
403
|
+
/**
|
|
404
|
+
* Provides an interface for querying known data.
|
|
405
|
+
* Data querying and caching are managed in Unified Shell in advance.
|
|
406
|
+
*
|
|
407
|
+
* This is an experimental feature.
|
|
408
|
+
* @template T
|
|
409
|
+
* @param key - Data Contract key
|
|
410
|
+
* @returns Promise for the contract execution response
|
|
411
|
+
*/
|
|
412
|
+
getPrefetched<T>(key: string): Promise<T>;
|
|
402
413
|
/**
|
|
403
414
|
* Provides an interface for querying resources via GraphqQL.
|
|
404
415
|
* In order to consume query, please make sure the respective query resolver is
|
|
@@ -485,6 +496,16 @@ export interface NetworkApi {
|
|
|
485
496
|
* @returns The promise for the response to the fetch operation.
|
|
486
497
|
*/
|
|
487
498
|
export declare function fetch(input: RequestInfo, init?: FetchInit): Promise<Response>;
|
|
499
|
+
/**
|
|
500
|
+
* Provides an interface for querying known data.
|
|
501
|
+
* Data querying and caching are managed in Unified Shell in advance.
|
|
502
|
+
*
|
|
503
|
+
* This is an experimental feature.
|
|
504
|
+
* @template T
|
|
505
|
+
* @param key - Data Contract key
|
|
506
|
+
* @returns Promise for the contract execution response
|
|
507
|
+
*/
|
|
508
|
+
export declare function getPrefetched<T>(key: string): Promise<T>;
|
|
488
509
|
/**
|
|
489
510
|
* Provides an interface for querying resources via GraphqQL.
|
|
490
511
|
* In order to consume query, please make sure the respective query resolver is
|
package/network.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* written permission of Adobe.
|
|
11
11
|
**************************************************************************/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.getApolloClient = exports.query = exports.fetch = exports.FetchScope = exports.ROUTING = exports.DEFAULT_STATUS_CODES_TO_RETRY = void 0;
|
|
13
|
+
exports.getApolloClient = exports.query = exports.getPrefetched = exports.fetch = exports.FetchScope = exports.ROUTING = exports.DEFAULT_STATUS_CODES_TO_RETRY = void 0;
|
|
14
14
|
const Global_1 = require("./src/Global");
|
|
15
15
|
/**
|
|
16
16
|
* Default status codes which imply a transient error and can be retried.
|
|
@@ -102,6 +102,19 @@ function fetch(input, init) {
|
|
|
102
102
|
return Global_1.getImpl('network').fetch(input, init);
|
|
103
103
|
}
|
|
104
104
|
exports.fetch = fetch;
|
|
105
|
+
/**
|
|
106
|
+
* Provides an interface for querying known data.
|
|
107
|
+
* Data querying and caching are managed in Unified Shell in advance.
|
|
108
|
+
*
|
|
109
|
+
* This is an experimental feature.
|
|
110
|
+
* @template T
|
|
111
|
+
* @param key - Data Contract key
|
|
112
|
+
* @returns Promise for the contract execution response
|
|
113
|
+
*/
|
|
114
|
+
function getPrefetched(key) {
|
|
115
|
+
return Global_1.getImpl('network').getPrefetched(key);
|
|
116
|
+
}
|
|
117
|
+
exports.getPrefetched = getPrefetched;
|
|
105
118
|
/**
|
|
106
119
|
* Provides an interface for querying resources via GraphqQL.
|
|
107
120
|
* In order to consume query, please make sure the respective query resolver is
|
package/network.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.js","sourceRoot":"","sources":["network.ts"],"names":[],"mappings":";AAAA;;;;;;;;;4EAS4E;;;AA+C5E,yCAAqC;AAGrC;;GAEG;AACU,QAAA,6BAA6B,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAuKlE,IAAY,OAaX;AAbD,WAAY,OAAO;IACjB;;OAEG;IACH,+DAAiB,CAAA;IACjB;;OAEG;IACH,2CAAO,CAAA;IACP;;OAEG;IACH,yEAAsB,CAAA;AACxB,CAAC,EAbW,OAAO,GAAP,eAAO,KAAP,eAAO,QAalB;AAqFD;;GAEG;AACH,IAAY,UAqCX;AArCD,WAAY,UAAU;IACpB;;;OAGG;IACH,
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["network.ts"],"names":[],"mappings":";AAAA;;;;;;;;;4EAS4E;;;AA+C5E,yCAAqC;AAGrC;;GAEG;AACU,QAAA,6BAA6B,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAuKlE,IAAY,OAaX;AAbD,WAAY,OAAO;IACjB;;OAEG;IACH,+DAAiB,CAAA;IACjB;;OAEG;IACH,2CAAO,CAAA;IACP;;OAEG;IACH,yEAAsB,CAAA;AACxB,CAAC,EAbW,OAAO,GAAP,eAAO,KAAP,eAAO,QAalB;AAqFD;;GAEG;AACH,IAAY,UAqCX;AArCD,WAAY,UAAU;IACpB;;;OAGG;IACH,2BAAa,CAAA;IACb;;;;OAIG;IACH,2BAAa,CAAA;IACb;;;;;OAKG;IACH,yBAAW,CAAA;IACX;;;;;;OAMG;IACH,iCAAmB,CAAA;IACnB;;;;;;;;OAQG;IACH,2CAA6B,CAAA;AAC/B,CAAC,EArCW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAqCrB;AA0HD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,KAAK,CAAC,KAAkB,EAAE,IAAgB;IACxD,OAAO,gBAAO,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC/C,CAAC;AAFD,sBAEC;AAED;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAAI,GAAW;IAC1C,OAAO,gBAAO,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;AAC/C,CAAC;AAFD,sCAEC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAgB,KAAK,CAAC,KAAmB;IACvC,OAAO,gBAAO,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAFD,sBAEC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,eAAe,CAC7B,OAA6B;IAK7B,OAAO,gBAAO,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AACrD,CAAC;AAPD,0CAOC"}
|
package/package.json
CHANGED
package/settings.js
CHANGED
|
@@ -76,12 +76,8 @@ const Global_1 = require("./src/Global");
|
|
|
76
76
|
const SettingsLevel_1 = require("./settings/SettingsLevel");
|
|
77
77
|
Object.defineProperty(exports, "SettingsLevel", { enumerable: true, get: function () { return SettingsLevel_1.SettingsLevel; } });
|
|
78
78
|
const settings = {
|
|
79
|
-
get: params =>
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
set: params => {
|
|
83
|
-
return Global_1.getImpl('settings')().set(params);
|
|
84
|
-
}
|
|
79
|
+
get: params => Global_1.getImpl('settings')().get(params),
|
|
80
|
+
set: params => Global_1.getImpl('settings')().set(params)
|
|
85
81
|
};
|
|
86
82
|
exports.default = settings;
|
|
87
83
|
//# sourceMappingURL=settings.js.map
|
package/settings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["settings.ts"],"names":[],"mappings":";AAAA;;;;;;;;;4EAS4E;;;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,yCAAqC;AACrC,4DAAuD;
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["settings.ts"],"names":[],"mappings":";AAAA;;;;;;;;;4EAS4E;;;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,yCAAqC;AACrC,4DAAuD;AAmE/C,8FAnEA,6BAAa,OAmEA;AALrB,MAAM,QAAQ,GAAgB;IAC5B,GAAG,EAAE,MAAM,CAAC,EAAE,CAAC,gBAAO,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC;IAChD,GAAG,EAAE,MAAM,CAAC,EAAE,CAAC,gBAAO,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC;CACjD,CAAC;AAGF,kBAAe,QAAQ,CAAC"}
|
package/shell.d.ts
CHANGED
|
@@ -66,11 +66,13 @@
|
|
|
66
66
|
*/
|
|
67
67
|
import EventEmitter from './src/EventEmitter';
|
|
68
68
|
export interface ShellInfo {
|
|
69
|
+
cdn: string;
|
|
69
70
|
environment: string;
|
|
70
71
|
imsEnvironment: string;
|
|
71
72
|
shellInfo: Record<string, any>;
|
|
72
73
|
}
|
|
73
74
|
interface ShellInfoEvent {
|
|
75
|
+
'change:cdn': string;
|
|
74
76
|
'change:environment': string;
|
|
75
77
|
'change:imsEnvironment': string;
|
|
76
78
|
'change:shellInfo': Record<string, any>;
|
package/shell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","sourceRoot":"","sources":["shell.ts"],"names":[],"mappings":";AAAA;;;;;;;;;4EAS4E;;AA4D5E,yCAAqC;
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["shell.ts"],"names":[],"mappings":";AAAA;;;;;;;;;4EAS4E;;AA4D5E,yCAAqC;AAwBrC,MAAM,KAAK,GAAG;IACZ,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QAClB,OAAO,gBAAO,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC5C,CAAC;IACD,GAAG,EAAE,MAAM,CAAC,EAAE;QACZ,OAAO,gBAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IACD,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;QACrB,OAAO,gBAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IACD,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;QACpB,OAAO,gBAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;CACU,CAAC;AAEd,kBAAe,KAAK,CAAC"}
|
package/src/Global.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* @module "index"
|
|
14
14
|
*/
|
|
15
15
|
import { AppApi } from '../appapi';
|
|
16
|
+
import { CacheApi } from '../cache';
|
|
16
17
|
import { CapabilityApi } from '../capabilityapi';
|
|
17
18
|
import { HelpCenterApi } from '../helpcenter';
|
|
18
19
|
import { InternalApi } from '../internal';
|
|
@@ -34,6 +35,7 @@ import { UserApi } from '../user';
|
|
|
34
35
|
import { UserProfileApi } from '../userprofile';
|
|
35
36
|
export interface Modules {
|
|
36
37
|
readonly appApi: () => AppApi;
|
|
38
|
+
readonly cache: () => CacheApi;
|
|
37
39
|
readonly capabilityApi: () => CapabilityApi;
|
|
38
40
|
readonly default: (options?: any) => Runtime;
|
|
39
41
|
readonly helpCenter: HelpCenterApi;
|
package/src/Global.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Global.js","sourceRoot":"","sources":["Global.ts"],"names":[],"mappings":";AAAA;;;;;;;;;4EAS4E;;;
|
|
1
|
+
{"version":3,"file":"Global.js","sourceRoot":"","sources":["Global.ts"],"names":[],"mappings":";AAAA;;;;;;;;;4EAS4E;;;AA4D5E;;;;;GAKG;AACH,SAAgB,OAAO,CAA0B,UAAa;IAC5D,MAAM,GAAG,GAAI,MAAiB,CAAC,oBAAoB,CAAC,CAAC;IACrD,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;KACvD;IACD,OAAO,GAAG,CAAC,UAAU,CAAC,CAAC;AACzB,CAAC;AAND,0BAMC;AAED;;;;;;GAMG;AACH,SAAgB,OAAO,CAA0B,OAAU,EAAE,UAA0C;IACrG,MAAM,GAAG,GAAG,EAAgB,CAAC;IAC7B,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC3B,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC/B,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;YACd,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE;gBACrC,OAAQ,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAS,CAAC,GAAG,IAAI,CAAC,CAAC;YACzD,CAAC,CAAQ,CAAC;SACX;aAAM;YACL,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,WAAW,EAAE;gBACtC,GAAG,EAAE,GAAG,EAAE;oBACR,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC;gBACvC,CAAC;gBACD,GAAG,EAAE,KAAK,CAAC,EAAE;oBACX,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;gBACxC,CAAC;aACF,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACb,CAAC;AApBD,0BAoBC;AAED,kBAAgB,MAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
/*************************************************************************
|
|
16
|
+
* Copyright 2022 Adobe
|
|
17
|
+
* All Rights Reserved.
|
|
18
|
+
*
|
|
19
|
+
* NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
20
|
+
* accordance with the terms of the Adobe license agreement accompanying
|
|
21
|
+
* it. If you have received this file from a source other than Adobe,
|
|
22
|
+
* then your use, modification, or distribution of it requires the prior
|
|
23
|
+
* written permission of Adobe.
|
|
24
|
+
**************************************************************************/
|
|
25
|
+
const cache_1 = __importDefault(require("../cache"));
|
|
26
|
+
const Global_1 = __importDefault(require("../src/Global"));
|
|
27
|
+
describe('cache.ts', () => {
|
|
28
|
+
const getMock = jest.fn();
|
|
29
|
+
const setMock = jest.fn();
|
|
30
|
+
const deleteMock = jest.fn();
|
|
31
|
+
const cacheMock = {
|
|
32
|
+
delete: deleteMock,
|
|
33
|
+
get: getMock,
|
|
34
|
+
set: setMock
|
|
35
|
+
};
|
|
36
|
+
beforeAll(() => {
|
|
37
|
+
Global_1.default['exc-module-runtime'] = {
|
|
38
|
+
cache: () => cacheMock
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
afterEach(() => jest.clearAllMocks());
|
|
42
|
+
const cachedItem = {
|
|
43
|
+
createdAt: 1641861111243,
|
|
44
|
+
expiresAt: 1642465911243,
|
|
45
|
+
key: 'key',
|
|
46
|
+
value: { hello: 'world' }
|
|
47
|
+
};
|
|
48
|
+
test('get', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
getMock.mockResolvedValue(cachedItem);
|
|
50
|
+
const entry = yield cache_1.default.get({ key: 'key' });
|
|
51
|
+
expect(entry).toEqual(cachedItem);
|
|
52
|
+
expect(getMock).toHaveBeenCalledTimes(1);
|
|
53
|
+
expect(getMock).toHaveBeenCalledWith({ key: 'key' });
|
|
54
|
+
}));
|
|
55
|
+
test('delete', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
+
yield cache_1.default.delete({ key: 'key' });
|
|
57
|
+
expect(deleteMock).toHaveBeenCalledTimes(1);
|
|
58
|
+
expect(deleteMock).toHaveBeenCalledWith({ key: 'key' });
|
|
59
|
+
}));
|
|
60
|
+
test('set', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
yield cache_1.default.set({ key: 'key', value: { hello: 'world' } });
|
|
62
|
+
expect(setMock).toHaveBeenCalledTimes(1);
|
|
63
|
+
expect(setMock).toHaveBeenCalledWith({ key: 'key', value: { hello: 'world' } });
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=cache.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.test.js","sourceRoot":"","sources":["cache.test.ts"],"names":[],"mappings":";;;;;;;;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AAE,GAAS,EAAE;QACxB,MAAM,eAAQ,CAAC,MAAM,CAAC,EAAC,GAAG,EAAE,KAAK,EAAC,CAAC,CAAC;QACpC,MAAM,CAAC,UAAU,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAC5C,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC,EAAC,GAAG,EAAE,KAAK,EAAC,CAAC,CAAC;IACxD,CAAC,CAAA,CAAC,CAAC;IAEH,IAAI,CAAC,KAAK,EAAE,GAAS,EAAE;QACrB,MAAM,eAAQ,CAAC,GAAG,CAAC,EAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,EAAC,KAAK,EAAE,OAAO,EAAC,EAAC,CAAC,CAAC;QAC1D,MAAM,CAAC,OAAO,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACzC,MAAM,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,EAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,EAAC,KAAK,EAAE,OAAO,EAAC,EAAC,CAAC,CAAC;IAC9E,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
/*************************************************************************
|
|
16
|
+
* Copyright 2022 Adobe
|
|
17
|
+
* All Rights Reserved.
|
|
18
|
+
*
|
|
19
|
+
* NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
20
|
+
* accordance with the terms of the Adobe license agreement accompanying
|
|
21
|
+
* it. If you have received this file from a source other than Adobe,
|
|
22
|
+
* then your use, modification, or distribution of it requires the prior
|
|
23
|
+
* written permission of Adobe.
|
|
24
|
+
**************************************************************************/
|
|
25
|
+
const network_1 = require("../network");
|
|
26
|
+
const Global_1 = __importDefault(require("../src/Global"));
|
|
27
|
+
describe('network.ts', () => {
|
|
28
|
+
const fetchMock = jest.fn();
|
|
29
|
+
const getPrefetchedMock = jest.fn();
|
|
30
|
+
const queryMock = jest.fn();
|
|
31
|
+
const getApolloClientMock = jest.fn();
|
|
32
|
+
const networkMock = {
|
|
33
|
+
fetch: fetchMock,
|
|
34
|
+
getApolloClient: getApolloClientMock,
|
|
35
|
+
getPrefetched: getPrefetchedMock,
|
|
36
|
+
query: queryMock
|
|
37
|
+
};
|
|
38
|
+
beforeAll(() => {
|
|
39
|
+
Global_1.default['exc-module-runtime'] = {
|
|
40
|
+
network: networkMock
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
afterEach(() => jest.clearAllMocks());
|
|
44
|
+
test('fetch', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
const res = { status: 'ok' };
|
|
46
|
+
fetchMock.mockResolvedValue(res);
|
|
47
|
+
const result = yield network_1.fetch('url', { auth: 'Header' });
|
|
48
|
+
expect(result).toEqual(res);
|
|
49
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
50
|
+
expect(fetchMock).toHaveBeenCalledWith('url', { auth: 'Header' });
|
|
51
|
+
}));
|
|
52
|
+
test('getPrefetched', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
const res = { status: 'ok' };
|
|
54
|
+
getPrefetchedMock.mockResolvedValue(res);
|
|
55
|
+
const result = yield network_1.getPrefetched('key');
|
|
56
|
+
expect(result).toEqual(res);
|
|
57
|
+
expect(getPrefetchedMock).toHaveBeenCalledTimes(1);
|
|
58
|
+
expect(getPrefetchedMock).toHaveBeenCalledWith('key');
|
|
59
|
+
}));
|
|
60
|
+
test('query', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
const res = { status: 'ok' };
|
|
62
|
+
queryMock.mockResolvedValue(res);
|
|
63
|
+
const result = yield network_1.query({ data: { query: 'query' } });
|
|
64
|
+
expect(result).toEqual(res);
|
|
65
|
+
expect(queryMock).toHaveBeenCalledTimes(1);
|
|
66
|
+
expect(queryMock).toHaveBeenCalledWith({ data: { query: 'query' } });
|
|
67
|
+
}));
|
|
68
|
+
test('getApolloClient', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
+
const res = { status: 'ok' };
|
|
70
|
+
getApolloClientMock.mockResolvedValue(res);
|
|
71
|
+
const result = yield network_1.getApolloClient({ xql: true });
|
|
72
|
+
expect(result).toEqual(res);
|
|
73
|
+
expect(getApolloClientMock).toHaveBeenCalledTimes(1);
|
|
74
|
+
expect(getApolloClientMock).toHaveBeenCalledWith({ xql: true });
|
|
75
|
+
}));
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=network.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.test.js","sourceRoot":"","sources":["network.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;4EAS4E;AAC5E,wCAAoF;AACpF,2DAA8C;AAE9C,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAC5B,MAAM,iBAAiB,GAAG,IAAI,CAAC,EAAE,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AC,CAAC;IAChE,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -28,11 +28,7 @@ describe('permissions.ts', () => {
|
|
|
28
28
|
let getSpy;
|
|
29
29
|
beforeAll(() => {
|
|
30
30
|
const permissionsMock = { get: jest.fn() };
|
|
31
|
-
Global_1.default['exc-module-runtime'] = {
|
|
32
|
-
permissions: () => {
|
|
33
|
-
return permissionsMock;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
31
|
+
Global_1.default['exc-module-runtime'] = { permissions: () => permissionsMock };
|
|
36
32
|
getSpy = jest.spyOn(permissionsMock, 'get');
|
|
37
33
|
});
|
|
38
34
|
afterEach(() => jest.clearAllMocks());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.test.js","sourceRoot":"","sources":["permissions.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;4EAS4E;AAC5E,2DAA8C;AAC9C,iEAKwB;AAExB,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,IAAI,MAAW,CAAC;IAEhB,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,eAAe,GAAG,EAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,EAAmB,CAAC;QAC1D,gBAAM,CAAC,oBAAoB,CAAa,GAAG
|
|
1
|
+
{"version":3,"file":"permissions.test.js","sourceRoot":"","sources":["permissions.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;4EAS4E;AAC5E,2DAA8C;AAC9C,iEAKwB;AAExB,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,IAAI,MAAW,CAAC;IAEhB,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,eAAe,GAAG,EAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,EAAmB,CAAC;QAC1D,gBAAM,CAAC,oBAAoB,CAAa,GAAG,EAAC,WAAW,EAAE,GAAG,EAAE,CAAC,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C;QACH,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;YAClB,WAAW,EAAE;gBACX,WAAW,EAAE,CAAC,GAAG,CAAC;gBAClB,WAAW,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;aAC/B;YACD,aAAa,EAAE;gBACb,WAAW,EAAE,CAAC,GAAG,CAAC;gBAClB,WAAW,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;aAC/B;SACF,CAAC,CAAC;IACL,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/tests/pulse.test.js
CHANGED
|
@@ -16,18 +16,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
const Global_1 = __importDefault(require("../src/Global"));
|
|
17
17
|
const pulse_1 = __importDefault(require("../pulse"));
|
|
18
18
|
describe('pulse.ts', () => {
|
|
19
|
+
// setup
|
|
20
|
+
const pulseMock = {
|
|
21
|
+
send: () => Promise.resolve({ notifications: { notification: [] } }),
|
|
22
|
+
setButton: () => { },
|
|
23
|
+
setCount: () => { }
|
|
24
|
+
};
|
|
25
|
+
Global_1.default['exc-module-runtime'] = {
|
|
26
|
+
pulse: () => {
|
|
27
|
+
return pulseMock;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
19
30
|
it('correctly sets up the connection with module-runtime', () => {
|
|
20
|
-
// setup
|
|
21
|
-
const pulseMock = {
|
|
22
|
-
send: () => Promise.resolve({ notifications: { notification: [] } }),
|
|
23
|
-
setButton: () => { },
|
|
24
|
-
setCount: () => { }
|
|
25
|
-
};
|
|
26
|
-
Global_1.default['exc-module-runtime'] = {
|
|
27
|
-
pulse: () => {
|
|
28
|
-
return pulseMock;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
31
|
const sendSpy = jest.spyOn(pulseMock, 'send');
|
|
32
32
|
const expected = [{}];
|
|
33
33
|
// action
|
|
@@ -36,5 +36,17 @@ describe('pulse.ts', () => {
|
|
|
36
36
|
expect(sendSpy).toBeCalledTimes(1);
|
|
37
37
|
expect(sendSpy).toBeCalledWith(expected);
|
|
38
38
|
});
|
|
39
|
+
it('set button', () => {
|
|
40
|
+
const setButtonSpy = jest.spyOn(pulseMock, 'setButton');
|
|
41
|
+
pulse_1.default.setButton({ label: 'label' });
|
|
42
|
+
expect(setButtonSpy).toHaveBeenCalledTimes(1);
|
|
43
|
+
expect(setButtonSpy).toHaveBeenCalledWith({ label: 'label' });
|
|
44
|
+
});
|
|
45
|
+
it('set count', () => {
|
|
46
|
+
const setCountSpy = jest.spyOn(pulseMock, 'setCount');
|
|
47
|
+
pulse_1.default.setCount(5);
|
|
48
|
+
expect(setCountSpy).toHaveBeenCalledTimes(1);
|
|
49
|
+
expect(setCountSpy).toHaveBeenCalledWith(5);
|
|
50
|
+
});
|
|
39
51
|
});
|
|
40
52
|
//# sourceMappingURL=pulse.test.js.map
|