@learncard/claimable-boosts-plugin 1.1.30 → 1.1.31
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 +7 -11
- package/src/test/index.test.ts +29 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@learncard/claimable-boosts-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.31",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "node ./scripts/build.mjs && shx cp ./scripts/mixedEntypoint.js ./dist/index.cjs && tsc --p tsconfig.json && shx cp ./dist/index.d.ts ./dist/index.d.cts",
|
|
27
|
-
"test": "
|
|
28
|
-
"test:watch": "
|
|
29
|
-
"test:coverage": "
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest",
|
|
29
|
+
"test:coverage": "vitest run --coverage"
|
|
30
30
|
},
|
|
31
31
|
"author": "Learning Economy Foundation (www.learningeconomy.io)",
|
|
32
32
|
"license": "MIT",
|
|
@@ -39,20 +39,16 @@
|
|
|
39
39
|
"url": "https://github.com/learningeconomy/LearnCard/issues"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@types/jest": "^29.2.2",
|
|
43
42
|
"@types/node": "^17.0.31",
|
|
44
43
|
"aqu": "0.4.3",
|
|
45
44
|
"esbuild": "^0.27.1",
|
|
46
|
-
"esbuild-jest": "^0.5.0",
|
|
47
45
|
"esbuild-plugin-copy": "^1.3.0",
|
|
48
|
-
"
|
|
49
|
-
"shx": "^0.3.4",
|
|
50
|
-
"ts-jest": "^29.0.3"
|
|
46
|
+
"shx": "^0.3.4"
|
|
51
47
|
},
|
|
52
48
|
"types": "./dist/index.d.ts",
|
|
53
49
|
"dependencies": {
|
|
54
|
-
"@learncard/core": "9.4.
|
|
55
|
-
"@learncard/types": "5.18.
|
|
50
|
+
"@learncard/core": "9.4.31",
|
|
51
|
+
"@learncard/types": "5.18.2"
|
|
56
52
|
},
|
|
57
53
|
"sideEffects": false
|
|
58
54
|
}
|
package/src/test/index.test.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { vi } from 'vitest';
|
|
1
2
|
import { getClaimableBoostsPlugin } from '../';
|
|
2
3
|
|
|
3
4
|
describe('Claimable Boosts Plugin', () => {
|
|
@@ -8,8 +9,8 @@ describe('Claimable Boosts Plugin', () => {
|
|
|
8
9
|
it('returns a plugin', () => {
|
|
9
10
|
const plugin = getClaimableBoostsPlugin({
|
|
10
11
|
invoke: {
|
|
11
|
-
generateClaimLink:
|
|
12
|
-
getRegisteredSigningAuthorities:
|
|
12
|
+
generateClaimLink: vi.fn(),
|
|
13
|
+
getRegisteredSigningAuthorities: vi.fn(),
|
|
13
14
|
},
|
|
14
15
|
} as any);
|
|
15
16
|
expect(plugin).toBeDefined();
|
|
@@ -18,22 +19,24 @@ describe('Claimable Boosts Plugin', () => {
|
|
|
18
19
|
it('returns a plugin with the correct name', () => {
|
|
19
20
|
const plugin = getClaimableBoostsPlugin({
|
|
20
21
|
invoke: {
|
|
21
|
-
generateClaimLink:
|
|
22
|
-
getRegisteredSigningAuthorities:
|
|
22
|
+
generateClaimLink: vi.fn(),
|
|
23
|
+
getRegisteredSigningAuthorities: vi.fn(),
|
|
23
24
|
},
|
|
24
25
|
} as any);
|
|
25
26
|
expect(plugin.name).toBe('ClaimableBoosts');
|
|
26
27
|
});
|
|
27
28
|
|
|
28
29
|
it('generates a claim link for a boost', async () => {
|
|
29
|
-
const mockGenerateClaimLink =
|
|
30
|
+
const mockGenerateClaimLink = vi.fn().mockResolvedValue({
|
|
30
31
|
boostUri: 'test-uri',
|
|
31
|
-
challenge: 'test-challenge'
|
|
32
|
+
challenge: 'test-challenge',
|
|
32
33
|
});
|
|
33
|
-
const mockGetRegisteredSigningAuthorities =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const mockGetRegisteredSigningAuthorities = vi.fn().mockResolvedValue([
|
|
35
|
+
{
|
|
36
|
+
relationship: { name: 'test-name' },
|
|
37
|
+
signingAuthority: { endpoint: 'test-endpoint' },
|
|
38
|
+
},
|
|
39
|
+
]);
|
|
37
40
|
|
|
38
41
|
const mockLearnCard = {
|
|
39
42
|
invoke: {
|
|
@@ -44,13 +47,22 @@ describe('Claimable Boosts Plugin', () => {
|
|
|
44
47
|
|
|
45
48
|
const plugin = getClaimableBoostsPlugin(mockLearnCard as any);
|
|
46
49
|
|
|
47
|
-
const result = await plugin.methods.generateBoostClaimLink(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
const result = await plugin.methods.generateBoostClaimLink(
|
|
51
|
+
mockLearnCard as any,
|
|
52
|
+
'test-boost-uri'
|
|
53
|
+
);
|
|
54
|
+
expect(result).toBe(
|
|
55
|
+
'https://learncard.app/claim/boost?claim=true&boostUri=test-uri&challenge=test-challenge'
|
|
56
|
+
);
|
|
57
|
+
|
|
50
58
|
expect(mockGetRegisteredSigningAuthorities).toHaveBeenCalled();
|
|
51
|
-
expect(mockGenerateClaimLink).toHaveBeenCalledWith(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
expect(mockGenerateClaimLink).toHaveBeenCalledWith(
|
|
60
|
+
'test-boost-uri',
|
|
61
|
+
{
|
|
62
|
+
name: 'test-name',
|
|
63
|
+
endpoint: 'test-endpoint',
|
|
64
|
+
},
|
|
65
|
+
undefined
|
|
66
|
+
);
|
|
55
67
|
});
|
|
56
68
|
});
|