@symbo.ls/sdk 2.33.26 → 2.33.27

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.
@@ -0,0 +1,92 @@
1
+ import test from 'tape'
2
+ import sinon from 'sinon'
3
+ import { PlanService } from '../../PlanService.js'
4
+
5
+ // #region Setup
6
+ const sandbox = sinon.createSandbox()
7
+ // #endregion
8
+
9
+ // #region Tests
10
+ test('deletePlan should return response data', async t => {
11
+ t.plan(1)
12
+
13
+ const planDataStub = {
14
+ success: true,
15
+ data: sandbox.stub()
16
+ }
17
+ const planServiceStub = new PlanService()
18
+ sandbox.stub(planServiceStub, '_request').resolves(planDataStub)
19
+ sandbox.stub(planServiceStub, '_requireReady').resolves()
20
+ const response = await planServiceStub.deletePlan(true)
21
+ t.equal(response, planDataStub.data, 'Response data returned')
22
+
23
+ sandbox.restore()
24
+ t.end()
25
+ })
26
+
27
+ test('deletePlan should return an error - Plan ID required', async t => {
28
+ t.plan(1)
29
+ const planServiceStub = new PlanService()
30
+ sandbox.stub(planServiceStub, '_requireReady').resolves()
31
+
32
+ try {
33
+ await planServiceStub.deletePlan(false)
34
+ t.fail('deletePlan should have failed')
35
+ } catch (err) {
36
+ t.equal(
37
+ err.toString(),
38
+ 'Error: Plan ID is required',
39
+ 'Error correctly returned'
40
+ )
41
+ }
42
+ sandbox.restore()
43
+ t.end()
44
+ })
45
+
46
+ test('deletePlan should return an error - Failed to parse URL', async t => {
47
+ t.plan(1)
48
+ const planServiceStub = new PlanService()
49
+ sandbox.stub(planServiceStub, '_requireReady').resolves()
50
+
51
+ try {
52
+ await planServiceStub.deletePlan(true)
53
+ t.fail('deletePlan should have failed')
54
+ } catch (err) {
55
+ t.equal(
56
+ err.toString(),
57
+ 'Error: Failed to delete plan: Request failed: Failed to parse URL from null/core/admin/plans/true',
58
+ 'Error correctly returned'
59
+ )
60
+ }
61
+ sandbox.restore()
62
+ t.end()
63
+ })
64
+
65
+ test('deletePlan should fail the requireReady', async t => {
66
+ t.plan(1)
67
+ const planServiceStub = new PlanService()
68
+ sandbox
69
+ .stub(planServiceStub, '_requireReady')
70
+ .throws(() => new Error('Service not initialized for method: deletePlan'))
71
+
72
+ try {
73
+ await planServiceStub.deletePlan()
74
+ t.fail('deletePlan should have failed')
75
+ } catch (err) {
76
+ t.equal(
77
+ err.toString(),
78
+ 'Error: Service not initialized for method: deletePlan',
79
+ 'Error correctly returned'
80
+ )
81
+ }
82
+ sandbox.restore()
83
+ t.end()
84
+ })
85
+ // #endregion
86
+
87
+ // #region Cleanup
88
+ test('teardown', t => {
89
+ sandbox.restore()
90
+ t.end()
91
+ })
92
+ // #endregion
@@ -0,0 +1,84 @@
1
+ import test from 'tape'
2
+ import sinon from 'sinon'
3
+ import { PlanService } from '../../PlanService.js'
4
+
5
+ // #region Setup
6
+ const sandbox = sinon.createSandbox()
7
+ // #endregion
8
+
9
+ // #region Tests
10
+ test('getAdminPlans should return response data', async t => {
11
+ t.plan(1)
12
+ const responseStub = {
13
+ success: true,
14
+ data: sandbox.stub()
15
+ }
16
+ const planServiceStub = new PlanService()
17
+ sandbox.stub(planServiceStub, '_request').resolves(responseStub)
18
+ sandbox.stub(planServiceStub, '_requireReady').resolves()
19
+ const response = await planServiceStub.getAdminPlans()
20
+ t.equal(response, responseStub.data, 'Response data returned')
21
+
22
+ sandbox.restore()
23
+ t.end()
24
+ })
25
+
26
+ test('getAdminPlans should return an error', async t => {
27
+ t.plan(1)
28
+ const responseStub = {
29
+ success: false,
30
+ data: sandbox.stub(),
31
+ message: 'Negative getAdminPlans Test'
32
+ }
33
+ const planServiceStub = new PlanService()
34
+ sandbox.stub(planServiceStub, '_request').resolves(responseStub)
35
+ sandbox.stub(planServiceStub, '_requireReady').resolves()
36
+
37
+ try {
38
+ await planServiceStub.getAdminPlans()
39
+ } catch (err) {
40
+ t.ok(
41
+ err
42
+ .toString()
43
+ .includes(`Failed to get admin plans: ${responseStub.message}`),
44
+ 'Error correctly returned'
45
+ )
46
+ }
47
+ sandbox.restore()
48
+ t.end()
49
+ })
50
+
51
+ test('getAdminPlans should fail the requireReady', async t => {
52
+ t.plan(1)
53
+ const responseStub = {
54
+ success: false,
55
+ data: sandbox.stub(),
56
+ message: 'Service not initialized for method: getAdminPlans'
57
+ }
58
+ const planServiceStub = new PlanService()
59
+ sandbox.stub(planServiceStub, '_request').resolves(responseStub)
60
+ sandbox
61
+ .stub(planServiceStub, '_requireReady')
62
+ .throws(() => new Error(responseStub.message))
63
+
64
+ try {
65
+ await planServiceStub.getAdminPlans()
66
+ t.fail('getAdminPlans should have failed')
67
+ } catch (err) {
68
+ t.equal(
69
+ err.toString(),
70
+ `Error: ${responseStub.message}`,
71
+ 'Error correctly returned'
72
+ )
73
+ }
74
+ sandbox.restore()
75
+ t.end()
76
+ })
77
+ // #endregion
78
+
79
+ // #region Cleanup
80
+ test('teardown', t => {
81
+ sandbox.restore()
82
+ t.end()
83
+ })
84
+ // #endregion
@@ -0,0 +1,50 @@
1
+ import test from 'tape'
2
+ import sinon from 'sinon'
3
+ import { PlanService } from '../../PlanService.js'
4
+
5
+ // #region Setup
6
+ const sandbox = sinon.createSandbox()
7
+ // #endregion
8
+
9
+ // #region Tests
10
+ test('getPlan should return response data', async t => {
11
+ t.plan(1)
12
+ const responseStub = {
13
+ success: true,
14
+ data: sandbox.stub()
15
+ }
16
+ const planServiceStub = new PlanService()
17
+ sandbox.stub(planServiceStub, '_request').resolves(responseStub)
18
+ const response = await planServiceStub.getPlan(true)
19
+ t.equal(response, responseStub.data, 'Response data returned')
20
+
21
+ sandbox.restore()
22
+ t.end()
23
+ })
24
+
25
+ test('getPlan should return an error', async t => {
26
+ t.plan(1)
27
+ const responseStub = {
28
+ success: false,
29
+ data: sandbox.stub(),
30
+ message: 'Error: Plan ID is required'
31
+ }
32
+ const planServiceStub = new PlanService()
33
+ sandbox.stub(planServiceStub, '_request').resolves(responseStub)
34
+
35
+ try {
36
+ await planServiceStub.getPlan()
37
+ } catch (err) {
38
+ t.equal(err.toString(), responseStub.message, 'Error correctly returned')
39
+ }
40
+ sandbox.restore()
41
+ t.end()
42
+ })
43
+ // #endregion
44
+
45
+ // #region Cleanup
46
+ test('teardown', t => {
47
+ sandbox.restore()
48
+ t.end()
49
+ })
50
+ // #endregion
@@ -0,0 +1,85 @@
1
+ /* eslint-disable no-undefined */
2
+ import test from 'tape'
3
+ import sinon from 'sinon'
4
+ import { PlanService } from '../../PlanService.js'
5
+
6
+ // #region Setup
7
+ const sandbox = sinon.createSandbox()
8
+ // #endregion
9
+
10
+ // #region Tests
11
+ test('getPlanWithValidation should return response data', async t => {
12
+ t.plan(1)
13
+ const responseStub = [sandbox.stub()]
14
+ const planServiceStub = new PlanService()
15
+ sandbox.stub(planServiceStub, 'getPlan').resolves(responseStub)
16
+ const response = await planServiceStub.getPlanWithValidation(
17
+ 'Plan ID Test String'
18
+ )
19
+ t.equal(response, responseStub, 'Response data returned')
20
+
21
+ sandbox.restore()
22
+ t.end()
23
+ })
24
+
25
+ test('getPlanWithValidation should return an error - null causes Invalid plan data received', async t => {
26
+ t.plan(1)
27
+ const responseStub = null
28
+ const planServiceStub = new PlanService()
29
+ sandbox.stub(planServiceStub, 'getPlan').resolves(responseStub)
30
+
31
+ try {
32
+ await planServiceStub.getPlanWithValidation('Plan ID Test String')
33
+ } catch (err) {
34
+ t.ok(
35
+ err.toString().includes('Invalid plan data received'),
36
+ 'Error correctly returned'
37
+ )
38
+ }
39
+ sandbox.restore()
40
+ t.end()
41
+ })
42
+
43
+ test('getPlanWithValidation should return an error - string causes Invalid plan data received', async t => {
44
+ t.plan(1)
45
+ const responseStub = 'Not an object'
46
+ const planServiceStub = new PlanService()
47
+ sandbox.stub(planServiceStub, 'getPlan').resolves(responseStub)
48
+
49
+ try {
50
+ await planServiceStub.getPlanWithValidation('Plan ID Test String')
51
+ } catch (err) {
52
+ t.ok(
53
+ err.toString().includes('Invalid plan data received'),
54
+ 'Error correctly returned'
55
+ )
56
+ }
57
+ sandbox.restore()
58
+ t.end()
59
+ })
60
+
61
+ test('getPlanWithValidation should return an error - Plan ID must be a valid string', async t => {
62
+ t.plan(1)
63
+ const responseStub = null
64
+ const planServiceStub = new PlanService()
65
+ sandbox.stub(planServiceStub, 'getPlan').resolves(responseStub)
66
+
67
+ try {
68
+ await planServiceStub.getPlanWithValidation(undefined)
69
+ } catch (err) {
70
+ t.ok(
71
+ err.toString().includes('Plan ID must be a valid string'),
72
+ 'Error correctly returned'
73
+ )
74
+ }
75
+ sandbox.restore()
76
+ t.end()
77
+ })
78
+ // #endregion
79
+
80
+ // #region Cleanup
81
+ test('teardown', t => {
82
+ sandbox.restore()
83
+ t.end()
84
+ })
85
+ // #endregion
@@ -0,0 +1,53 @@
1
+ import test from 'tape'
2
+ import sinon from 'sinon'
3
+ import { PlanService } from '../../PlanService.js'
4
+
5
+ // #region Setup
6
+ const sandbox = sinon.createSandbox()
7
+ // #endregion
8
+
9
+ // #region Tests
10
+ test('getPlans should return response data', async t => {
11
+ t.plan(1)
12
+ const responseStub = {
13
+ success: true,
14
+ data: sandbox.stub()
15
+ }
16
+ const planServiceStub = new PlanService()
17
+ sandbox.stub(planServiceStub, '_request').resolves(responseStub)
18
+ const response = await planServiceStub.getPlans()
19
+ t.equal(response, responseStub.data, 'Response data returned')
20
+
21
+ sandbox.restore()
22
+ t.end()
23
+ })
24
+
25
+ test('getPlans should return an error', async t => {
26
+ t.plan(1)
27
+ const responseStub = {
28
+ success: false,
29
+ data: sandbox.stub(),
30
+ message: 'Negative getPlans Test'
31
+ }
32
+ const planServiceStub = new PlanService()
33
+ sandbox.stub(planServiceStub, '_request').resolves(responseStub)
34
+
35
+ try {
36
+ await planServiceStub.getPlans()
37
+ } catch (err) {
38
+ t.ok(
39
+ err.toString().includes(`Failed to get plans: ${responseStub.message}`),
40
+ 'Error correctly returned'
41
+ )
42
+ }
43
+ sandbox.restore()
44
+ t.end()
45
+ })
46
+ // #endregion
47
+
48
+ // #region Cleanup
49
+ test('teardown', t => {
50
+ sandbox.restore()
51
+ t.end()
52
+ })
53
+ // #endregion
@@ -0,0 +1,48 @@
1
+ import test from 'tape'
2
+ import sinon from 'sinon'
3
+ import { PlanService } from '../../PlanService.js'
4
+
5
+ // #region Setup
6
+ const sandbox = sinon.createSandbox()
7
+ // #endregion
8
+
9
+ // #region Tests
10
+ test('getPlansWithValidation should return response data', async t => {
11
+ t.plan(1)
12
+ const responseStub = [sandbox.stub()]
13
+ const planServiceStub = new PlanService()
14
+ sandbox.stub(planServiceStub, 'getPlans').resolves(responseStub)
15
+ const response = await planServiceStub.getPlansWithValidation()
16
+ t.equal(response, responseStub, 'Response data returned')
17
+
18
+ sandbox.restore()
19
+ t.end()
20
+ })
21
+
22
+ test('getPlansWithValidation should return an error - plans should be an array', async t => {
23
+ t.plan(1)
24
+ const responseStub = null
25
+ const planServiceStub = new PlanService()
26
+ sandbox.stub(planServiceStub, 'getPlans').resolves(responseStub)
27
+
28
+ try {
29
+ await planServiceStub.getPlansWithValidation()
30
+ } catch (err) {
31
+ t.ok(
32
+ err
33
+ .toString()
34
+ .includes('Invalid response format: plans should be an array'),
35
+ 'Error correctly returned'
36
+ )
37
+ }
38
+ sandbox.restore()
39
+ t.end()
40
+ })
41
+ // #endregion
42
+
43
+ // #region Cleanup
44
+ test('teardown', t => {
45
+ sandbox.restore()
46
+ t.end()
47
+ })
48
+ // #endregion
@@ -0,0 +1,75 @@
1
+ import test from 'tape'
2
+ import sinon from 'sinon'
3
+ import { PlanService } from '../../PlanService.js'
4
+
5
+ // #region Setup
6
+ const sandbox = sinon.createSandbox()
7
+ // #endregion
8
+
9
+ // #region Tests
10
+ test('initializePlans should return response data', async t => {
11
+ t.plan(1)
12
+
13
+ const planDataStub = {
14
+ success: true,
15
+ data: sandbox.stub()
16
+ }
17
+ const planServiceStub = new PlanService()
18
+ sandbox.stub(planServiceStub, '_request').resolves(planDataStub)
19
+ sandbox.stub(planServiceStub, '_requireReady').resolves()
20
+ const response = await planServiceStub.initializePlans()
21
+ t.equal(response, planDataStub, 'Response data returned')
22
+
23
+ sandbox.restore()
24
+ t.end()
25
+ })
26
+
27
+ test('initializePlans should return an error - Failed to parse URL', async t => {
28
+ t.plan(1)
29
+ const planServiceStub = new PlanService()
30
+ sandbox.stub(planServiceStub, '_requireReady').resolves()
31
+
32
+ try {
33
+ await planServiceStub.initializePlans()
34
+ t.fail('initializePlans should have failed')
35
+ } catch (err) {
36
+ t.equal(
37
+ err.toString(),
38
+ 'Error: Failed to initialize plans: Request failed: Failed to parse URL from null/core/admin/plans/initialize',
39
+ 'Error correctly returned'
40
+ )
41
+ }
42
+ sandbox.restore()
43
+ t.end()
44
+ })
45
+
46
+ test('initializePlans should fail the requireReady', async t => {
47
+ t.plan(1)
48
+ const planServiceStub = new PlanService()
49
+ sandbox
50
+ .stub(planServiceStub, '_requireReady')
51
+ .throws(
52
+ () => new Error('Service not initialized for method: initializePlans')
53
+ )
54
+
55
+ try {
56
+ await planServiceStub.initializePlans()
57
+ t.fail('initializePlans should have failed')
58
+ } catch (err) {
59
+ t.equal(
60
+ err.toString(),
61
+ 'Error: Service not initialized for method: initializePlans',
62
+ 'Error correctly returned'
63
+ )
64
+ }
65
+ sandbox.restore()
66
+ t.end()
67
+ })
68
+ // #endregion
69
+
70
+ // #region Cleanup
71
+ test('teardown', t => {
72
+ sandbox.restore()
73
+ t.end()
74
+ })
75
+ // #endregion
@@ -0,0 +1,111 @@
1
+ import test from 'tape'
2
+ import sinon from 'sinon'
3
+ import { PlanService } from '../../PlanService.js'
4
+
5
+ // #region Setup
6
+ const sandbox = sinon.createSandbox()
7
+ // #endregion
8
+
9
+ // #region Tests
10
+ test('updatePlan should return response data', async t => {
11
+ t.plan(1)
12
+
13
+ const planDataStub = {
14
+ success: true,
15
+ data: sandbox.stub()
16
+ }
17
+ const planServiceStub = new PlanService()
18
+ sandbox.stub(planServiceStub, '_request').resolves(planDataStub)
19
+ sandbox.stub(planServiceStub, '_requireReady').resolves()
20
+ const response = await planServiceStub.updatePlan(true, [])
21
+ t.equal(response, planDataStub.data, 'Response data returned')
22
+
23
+ sandbox.restore()
24
+ t.end()
25
+ })
26
+
27
+ test('updatePlan should return an error - Plan data required', async t => {
28
+ t.plan(1)
29
+ const planServiceStub = new PlanService()
30
+ sandbox.stub(planServiceStub, '_requireReady').resolves()
31
+
32
+ try {
33
+ await planServiceStub.updatePlan(true, false)
34
+ t.fail('createPlan should have failed')
35
+ } catch (err) {
36
+ t.equal(
37
+ err.toString(),
38
+ 'Error: Plan data is required',
39
+ 'Error correctly returned'
40
+ )
41
+ }
42
+ sandbox.restore()
43
+ t.end()
44
+ })
45
+
46
+ test('updatePlan should return an error - Plan ID required', async t => {
47
+ t.plan(1)
48
+ const planServiceStub = new PlanService()
49
+ sandbox.stub(planServiceStub, '_requireReady').resolves()
50
+
51
+ try {
52
+ await planServiceStub.updatePlan(false, [])
53
+ t.fail('updatePlan should have failed')
54
+ } catch (err) {
55
+ t.equal(
56
+ err.toString(),
57
+ 'Error: Plan ID is required',
58
+ 'Error correctly returned'
59
+ )
60
+ }
61
+ sandbox.restore()
62
+ t.end()
63
+ })
64
+
65
+ test('updatePlan should return an error - Failed to parse URL', async t => {
66
+ t.plan(1)
67
+ const planServiceStub = new PlanService()
68
+ sandbox.stub(planServiceStub, '_requireReady').resolves()
69
+
70
+ try {
71
+ await planServiceStub.updatePlan(true, [])
72
+ t.fail('updatePlan should have failed')
73
+ } catch (err) {
74
+ t.equal(
75
+ err.toString(),
76
+ 'Error: Failed to update plan: Request failed: Failed to parse URL from null/core/admin/plans/true',
77
+ 'Error correctly returned'
78
+ )
79
+ }
80
+ sandbox.restore()
81
+ t.end()
82
+ })
83
+
84
+ test('updatePlan should fail the requireReady', async t => {
85
+ t.plan(1)
86
+ const planServiceStub = new PlanService()
87
+ sandbox
88
+ .stub(planServiceStub, '_requireReady')
89
+ .throws(() => new Error('Service not initialized for method: updatePlan'))
90
+
91
+ try {
92
+ await planServiceStub.updatePlan()
93
+ t.fail('updatePlan should have failed')
94
+ } catch (err) {
95
+ t.equal(
96
+ err.toString(),
97
+ 'Error: Service not initialized for method: updatePlan',
98
+ 'Error correctly returned'
99
+ )
100
+ }
101
+ sandbox.restore()
102
+ t.end()
103
+ })
104
+ // #endregion
105
+
106
+ // #region Cleanup
107
+ test('teardown', t => {
108
+ sandbox.restore()
109
+ t.end()
110
+ })
111
+ // #endregion