@friggframework/api-module-hubspot 2.0.0-next.2 → 2.0.0-next.3
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/definition.js +2 -2
- package/package.json +2 -2
- package/tests/definition.test.js +67 -0
package/definition.js
CHANGED
|
@@ -18,7 +18,7 @@ const Definition = {
|
|
|
18
18
|
getEntityDetails: async function (api, callbackParams, tokenResponse, userId) {
|
|
19
19
|
const userDetails = await api.getUserDetails();
|
|
20
20
|
return {
|
|
21
|
-
identifiers: {externalId: userDetails.portalId, userId},
|
|
21
|
+
identifiers: {externalId: String(userDetails.portalId), userId},
|
|
22
22
|
details: {name: userDetails.hub_domain},
|
|
23
23
|
}
|
|
24
24
|
},
|
|
@@ -31,7 +31,7 @@ const Definition = {
|
|
|
31
31
|
getCredentialDetails: async function (api, userId) {
|
|
32
32
|
const userDetails = await api.getUserDetails();
|
|
33
33
|
return {
|
|
34
|
-
identifiers: {externalId: userDetails.portalId, userId},
|
|
34
|
+
identifiers: {externalId: String(userDetails.portalId), userId},
|
|
35
35
|
details: {}
|
|
36
36
|
};
|
|
37
37
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/api-module-hubspot",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.3",
|
|
4
4
|
"prettier": "@friggframework/prettier-config",
|
|
5
5
|
"description": "HubSpot API module that lets the Frigg Framework interact with HubSpot",
|
|
6
6
|
"main": "index.js",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@friggframework/core": "^2.0.0-next.16"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "13f08e689a67d6b3cbaf5774056557d25ce6e5f2"
|
|
26
26
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Definition unit tests — assert the shape of identifiers handed to
|
|
3
|
+
* Frigg core during the auth handshake. The Postgres schema in
|
|
4
|
+
* @friggframework/core ≥ 2.0.0-next types Credential.externalId as
|
|
5
|
+
* String?, so portalId (Int from HubSpot's /access-tokens response)
|
|
6
|
+
* must be stringified at the api-module boundary.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { Definition } = require('../definition');
|
|
10
|
+
|
|
11
|
+
const baseUserDetails = {
|
|
12
|
+
portalId: 111111111, // HubSpot returns this as an integer
|
|
13
|
+
hub_domain: 'Testing Object Things-dev-44613847.com',
|
|
14
|
+
hub_id: 111111111,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function makeStubApi(userDetailsOverride = {}) {
|
|
18
|
+
return {
|
|
19
|
+
getUserDetails: async () =>
|
|
20
|
+
Object.assign({}, baseUserDetails, userDetailsOverride),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe('HubSpot Definition externalId coercion', () => {
|
|
25
|
+
describe('getEntityDetails()', () => {
|
|
26
|
+
it('returns externalId as a string, not an integer', async () => {
|
|
27
|
+
const api = makeStubApi();
|
|
28
|
+
const result =
|
|
29
|
+
await Definition.requiredAuthMethods.getEntityDetails(
|
|
30
|
+
api,
|
|
31
|
+
null,
|
|
32
|
+
null,
|
|
33
|
+
42
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
expect(typeof result.identifiers.externalId).toBe('string');
|
|
37
|
+
expect(result.identifiers.externalId).toBe('111111111');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('stringifies a very large portalId without losing precision', async () => {
|
|
41
|
+
const api = makeStubApi({ portalId: 9999999999 });
|
|
42
|
+
const result =
|
|
43
|
+
await Definition.requiredAuthMethods.getEntityDetails(
|
|
44
|
+
api,
|
|
45
|
+
null,
|
|
46
|
+
null,
|
|
47
|
+
42
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
expect(result.identifiers.externalId).toBe('9999999999');
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('getCredentialDetails()', () => {
|
|
55
|
+
it('returns externalId as a string, not an integer', async () => {
|
|
56
|
+
const api = makeStubApi();
|
|
57
|
+
const result =
|
|
58
|
+
await Definition.requiredAuthMethods.getCredentialDetails(
|
|
59
|
+
api,
|
|
60
|
+
42
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
expect(typeof result.identifiers.externalId).toBe('string');
|
|
64
|
+
expect(result.identifiers.externalId).toBe('111111111');
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|