@insignia-education/api-sdk-js 0.9.12

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.
Files changed (87) hide show
  1. package/.github/hooks/pre-commit +13 -0
  2. package/.github/workflows/npm-publish-github-packages.yml +30 -0
  3. package/Cart.js +40 -0
  4. package/LICENSE +21 -0
  5. package/README.md +444 -0
  6. package/babel.config.cjs +1 -0
  7. package/coverage/clover.xml +703 -0
  8. package/coverage/coverage-final.json +30 -0
  9. package/coverage/lcov-report/base.css +224 -0
  10. package/coverage/lcov-report/block-navigation.js +87 -0
  11. package/coverage/lcov-report/favicon.png +0 -0
  12. package/coverage/lcov-report/index.html +131 -0
  13. package/coverage/lcov-report/prettify.css +1 -0
  14. package/coverage/lcov-report/prettify.js +2 -0
  15. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  16. package/coverage/lcov-report/sorter.js +210 -0
  17. package/coverage/lcov-report/src/Client.js.html +202 -0
  18. package/coverage/lcov-report/src/api/v1/Accounts.js.html +151 -0
  19. package/coverage/lcov-report/src/api/v1/Auth.js.html +130 -0
  20. package/coverage/lcov-report/src/api/v1/Categories.js.html +121 -0
  21. package/coverage/lcov-report/src/api/v1/Changelogs.js.html +118 -0
  22. package/coverage/lcov-report/src/api/v1/Configs.js.html +121 -0
  23. package/coverage/lcov-report/src/api/v1/ContactForms.js.html +121 -0
  24. package/coverage/lcov-report/src/api/v1/ConversationalTopics.js.html +121 -0
  25. package/coverage/lcov-report/src/api/v1/Countries.js.html +112 -0
  26. package/coverage/lcov-report/src/api/v1/Coupons.js.html +121 -0
  27. package/coverage/lcov-report/src/api/v1/Courses.js.html +328 -0
  28. package/coverage/lcov-report/src/api/v1/Currencies.js.html +115 -0
  29. package/coverage/lcov-report/src/api/v1/Files.js.html +115 -0
  30. package/coverage/lcov-report/src/api/v1/Forums.js.html +157 -0
  31. package/coverage/lcov-report/src/api/v1/Hashes.js.html +118 -0
  32. package/coverage/lcov-report/src/api/v1/Insignias.js.html +121 -0
  33. package/coverage/lcov-report/src/api/v1/Languages.js.html +121 -0
  34. package/coverage/lcov-report/src/api/v1/MailBlacklist.js.html +118 -0
  35. package/coverage/lcov-report/src/api/v1/Organizations.js.html +118 -0
  36. package/coverage/lcov-report/src/api/v1/Quizzes.js.html +181 -0
  37. package/coverage/lcov-report/src/api/v1/ShortLinks.js.html +121 -0
  38. package/coverage/lcov-report/src/api/v1/Surveys.js.html +181 -0
  39. package/coverage/lcov-report/src/api/v1/Tags.js.html +121 -0
  40. package/coverage/lcov-report/src/api/v1/Taxes.js.html +121 -0
  41. package/coverage/lcov-report/src/api/v1/Teacher.js.html +196 -0
  42. package/coverage/lcov-report/src/api/v1/Translations.js.html +121 -0
  43. package/coverage/lcov-report/src/api/v1/UserTypes.js.html +121 -0
  44. package/coverage/lcov-report/src/api/v1/Users.js.html +331 -0
  45. package/coverage/lcov-report/src/api/v1/Zoom.js.html +154 -0
  46. package/coverage/lcov-report/src/api/v1/index.html +521 -0
  47. package/coverage/lcov-report/src/index.html +116 -0
  48. package/coverage/lcov.info +1822 -0
  49. package/index.js +4 -0
  50. package/jest.config.mjs +201 -0
  51. package/package.json +36 -0
  52. package/scss/Services/_notification.scss +0 -0
  53. package/scss/index.scss +2 -0
  54. package/src/Client.js +39 -0
  55. package/src/api/index.js +20 -0
  56. package/src/api/v1/Accounts.js +22 -0
  57. package/src/api/v1/Auth.js +15 -0
  58. package/src/api/v1/Categories.js +12 -0
  59. package/src/api/v1/Changelogs.js +11 -0
  60. package/src/api/v1/Configs.js +12 -0
  61. package/src/api/v1/ContactForms.js +12 -0
  62. package/src/api/v1/ConversationalTopics.js +12 -0
  63. package/src/api/v1/Countries.js +9 -0
  64. package/src/api/v1/Coupons.js +12 -0
  65. package/src/api/v1/Courses.js +81 -0
  66. package/src/api/v1/Currencies.js +10 -0
  67. package/src/api/v1/Files.js +10 -0
  68. package/src/api/v1/Forums.js +24 -0
  69. package/src/api/v1/Hashes.js +11 -0
  70. package/src/api/v1/Insignias.js +12 -0
  71. package/src/api/v1/Languages.js +12 -0
  72. package/src/api/v1/MailBlacklist.js +11 -0
  73. package/src/api/v1/Organizations.js +11 -0
  74. package/src/api/v1/Quizzes.js +32 -0
  75. package/src/api/v1/ShortLinks.js +12 -0
  76. package/src/api/v1/Surveys.js +32 -0
  77. package/src/api/v1/Tags.js +12 -0
  78. package/src/api/v1/Taxes.js +12 -0
  79. package/src/api/v1/Teacher.js +37 -0
  80. package/src/api/v1/Translations.js +12 -0
  81. package/src/api/v1/UserTypes.js +12 -0
  82. package/src/api/v1/Users.js +82 -0
  83. package/src/api/v1/Zoom.js +23 -0
  84. package/src/api/v1/index.js +74 -0
  85. package/src/index.js +21 -0
  86. package/tests/api/v1.test.js +480 -0
  87. package/tests/client.test.js +214 -0
@@ -0,0 +1,480 @@
1
+ import Auth from '../../src/api/v1/Auth.js';
2
+ import Accounts from '../../src/api/v1/Accounts.js';
3
+ import Categories from '../../src/api/v1/Categories.js';
4
+ import Changelogs from '../../src/api/v1/Changelogs.js';
5
+ import Configs from '../../src/api/v1/Configs.js';
6
+ import ContactForms from '../../src/api/v1/ContactForms.js';
7
+ import ConversationalTopics from '../../src/api/v1/ConversationalTopics.js';
8
+ import Countries from '../../src/api/v1/Countries.js';
9
+ import Coupons from '../../src/api/v1/Coupons.js';
10
+ import Courses from '../../src/api/v1/Courses.js';
11
+ import Currencies from '../../src/api/v1/Currencies.js';
12
+ import Files from '../../src/api/v1/Files.js';
13
+ import Forums from '../../src/api/v1/Forums.js';
14
+ import Hashes from '../../src/api/v1/Hashes.js';
15
+ import Insignias from '../../src/api/v1/Insignias.js';
16
+ import Languages from '../../src/api/v1/Languages.js';
17
+ import MailBlacklist from '../../src/api/v1/MailBlacklist.js';
18
+ import Organizations from '../../src/api/v1/Organizations.js';
19
+ import Quizzes from '../../src/api/v1/Quizzes.js';
20
+ import ShortLinks from '../../src/api/v1/ShortLinks.js';
21
+ import Surveys from '../../src/api/v1/Surveys.js';
22
+ import Tags from '../../src/api/v1/Tags.js';
23
+ import Taxes from '../../src/api/v1/Taxes.js';
24
+ import Teacher from '../../src/api/v1/Teacher.js';
25
+ import Translations from '../../src/api/v1/Translations.js';
26
+ import UserTypes from '../../src/api/v1/UserTypes.js';
27
+ import Users from '../../src/api/v1/Users.js';
28
+ import Zoom from '../../src/api/v1/Zoom.js';
29
+
30
+ function mockClient() {
31
+ return {
32
+ get: jest.fn(),
33
+ post: jest.fn(),
34
+ put: jest.fn(),
35
+ patch: jest.fn(),
36
+ del: jest.fn(),
37
+ };
38
+ }
39
+
40
+ // ─── Auth ─────────────────────────────────────────────────────────────────────
41
+
42
+ describe('Auth', () => {
43
+ let c, r;
44
+ beforeEach(() => { c = mockClient(); r = new Auth(c); });
45
+
46
+ test('loginOrRegister', () => { r.loginOrRegister('a@b.com'); expect(c.get).toHaveBeenCalledWith('/auth/login-register-check?email=a%40b.com'); });
47
+ test('register', () => { r.register({}); expect(c.put).toHaveBeenCalledWith('/auth/register', {}); });
48
+ test('login', () => { r.login({}); expect(c.post).toHaveBeenCalledWith('/auth/login', {}); });
49
+ test('googleLogin', () => { r.googleLogin({}); expect(c.post).toHaveBeenCalledWith('/auth/google', {}); });
50
+ test('refresh', () => { r.refresh(); expect(c.post).toHaveBeenCalledWith('/auth/refresh'); });
51
+ test('logout', () => { r.logout(); expect(c.post).toHaveBeenCalledWith('/auth/logout'); });
52
+ test('user', () => { r.user(); expect(c.get).toHaveBeenCalledWith('/auth/user'); });
53
+ });
54
+
55
+ // ─── Accounts ────────────────────────────────────────────────────────────────
56
+
57
+ describe('Accounts', () => {
58
+ let c, r;
59
+ beforeEach(() => { c = mockClient(); r = new Accounts(c); });
60
+
61
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/accounts'); });
62
+ test('get by id', () => { r.get(5); expect(c.get).toHaveBeenCalledWith('/accounts/5'); });
63
+ test('create', () => { r.create({}); expect(c.put).toHaveBeenCalledWith('/accounts', {}); });
64
+ test('edit', () => { r.edit(5, {}); expect(c.patch).toHaveBeenCalledWith('/accounts/5', {}); });
65
+ test('delete', () => { r.delete(5); expect(c.del).toHaveBeenCalledWith('/accounts/5'); });
66
+
67
+ describe('moves()', () => {
68
+ test('get all', () => { r.moves(3).get(); expect(c.get).toHaveBeenCalledWith('/accounts/3/moves'); });
69
+ test('get by id', () => { r.moves(3).get(7); expect(c.get).toHaveBeenCalledWith('/accounts/3/moves/7'); });
70
+ test('create', () => { r.moves(3).create({}); expect(c.put).toHaveBeenCalledWith('/accounts/3/moves', {}); });
71
+ test('edit', () => { r.moves(3).edit(7, {}); expect(c.patch).toHaveBeenCalledWith('/accounts/3/moves/7', {}); });
72
+ test('delete', () => { r.moves(3).delete(7); expect(c.del).toHaveBeenCalledWith('/accounts/3/moves/7'); });
73
+ });
74
+ });
75
+
76
+ // ─── Simple CRUD resources ────────────────────────────────────────────────────
77
+
78
+ const crudCases = [
79
+ ['Categories', Categories, '/categories'],
80
+ ['Configs', Configs, '/configs'],
81
+ ['ConversationalTopics',ConversationalTopics,'/conversational-topics'],
82
+ ['Coupons', Coupons, '/coupons'],
83
+ ['Insignias', Insignias, '/insignias'],
84
+ ['Languages', Languages, '/languages'],
85
+ ['ShortLinks', ShortLinks, '/short-links'],
86
+ ['Tags', Tags, '/tags'],
87
+ ['Taxes', Taxes, '/taxes'],
88
+ ['UserTypes', UserTypes, '/user-types'],
89
+ ];
90
+
91
+ crudCases.forEach(([name, Class, base]) => {
92
+ describe(name, () => {
93
+ let c, r;
94
+ beforeEach(() => { c = mockClient(); r = new Class(c); });
95
+
96
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith(base); });
97
+ test('get by id', () => { r.get(1); expect(c.get).toHaveBeenCalledWith(`${base}/1`); });
98
+ test('create', () => { r.create({}); expect(c.put).toHaveBeenCalledWith(base, {}); });
99
+ test('edit', () => { r.edit(1, {}); expect(c.patch).toHaveBeenCalledWith(`${base}/1`, {}); });
100
+ test('delete', () => { r.delete(1); expect(c.del).toHaveBeenCalledWith(`${base}/1`); });
101
+ });
102
+ });
103
+
104
+ // ─── Changelogs ───────────────────────────────────────────────────────────────
105
+
106
+ describe('Changelogs', () => {
107
+ let c, r;
108
+ beforeEach(() => { c = mockClient(); r = new Changelogs(c); });
109
+
110
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/changelogs'); });
111
+ test('get by id',() => { r.get(1); expect(c.get).toHaveBeenCalledWith('/changelogs/1'); });
112
+ test('approve', () => { r.approve(1); expect(c.post).toHaveBeenCalledWith('/changelogs/1/approve'); });
113
+ test('reject', () => { r.reject(1, {}); expect(c.post).toHaveBeenCalledWith('/changelogs/1/reject', {}); });
114
+ });
115
+
116
+ // ─── ContactForms ─────────────────────────────────────────────────────────────
117
+
118
+ describe('ContactForms', () => {
119
+ let c, r;
120
+ beforeEach(() => { c = mockClient(); r = new ContactForms(c); });
121
+
122
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/contact-forms'); });
123
+ test('get by id',() => { r.get(1); expect(c.get).toHaveBeenCalledWith('/contact-forms/1'); });
124
+ test('create', () => { r.create({}); expect(c.put).toHaveBeenCalledWith('/contact-forms', {}); });
125
+ test('answer', () => { r.answer(1, {}); expect(c.post).toHaveBeenCalledWith('/contact-forms/1/answer', {}); });
126
+ test('delete', () => { r.delete(1); expect(c.del).toHaveBeenCalledWith('/contact-forms/1'); });
127
+ });
128
+
129
+ // ─── Countries ────────────────────────────────────────────────────────────────
130
+
131
+ describe('Countries', () => {
132
+ let c, r;
133
+ beforeEach(() => { c = mockClient(); r = new Countries(c); });
134
+
135
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/countries'); });
136
+ test('get by id', () => { r.get(1); expect(c.get).toHaveBeenCalledWith('/countries/1'); });
137
+ });
138
+
139
+ // ─── Currencies ───────────────────────────────────────────────────────────────
140
+
141
+ describe('Currencies', () => {
142
+ let c, r;
143
+ beforeEach(() => { c = mockClient(); r = new Currencies(c); });
144
+
145
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/currencies'); });
146
+ test('get by id', () => { r.get(1); expect(c.get).toHaveBeenCalledWith('/currencies/1'); });
147
+ test('getValues', () => { r.getValues();expect(c.get).toHaveBeenCalledWith('/currencies/values'); });
148
+ });
149
+
150
+ // ─── Files ────────────────────────────────────────────────────────────────────
151
+
152
+ describe('Files', () => {
153
+ let c, r;
154
+ beforeEach(() => { c = mockClient(); r = new Files(c); });
155
+
156
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/files'); });
157
+ test('get by id', () => { r.get(1); expect(c.get).toHaveBeenCalledWith('/files/1'); });
158
+ test('delete', () => { r.delete(1);expect(c.del).toHaveBeenCalledWith('/files/1'); });
159
+ });
160
+
161
+ // ─── Forums ───────────────────────────────────────────────────────────────────
162
+
163
+ describe('Forums', () => {
164
+ let c, r;
165
+ beforeEach(() => { c = mockClient(); r = new Forums(c); });
166
+
167
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/forums'); });
168
+ test('get by id',() => { r.get(1); expect(c.get).toHaveBeenCalledWith('/forums/1'); });
169
+ test('create', () => { r.create({}); expect(c.put).toHaveBeenCalledWith('/forums', {}); });
170
+ test('edit', () => { r.edit(1, {}); expect(c.patch).toHaveBeenCalledWith('/forums/1', {}); });
171
+ test('delete', () => { r.delete(1); expect(c.del).toHaveBeenCalledWith('/forums/1'); });
172
+ test('approve', () => { r.approve(1); expect(c.post).toHaveBeenCalledWith('/forums/1/approve'); });
173
+
174
+ describe('responses()', () => {
175
+ test('get all', () => { r.responses(2).get(); expect(c.get).toHaveBeenCalledWith('/forums/2/responses'); });
176
+ test('get by id', () => { r.responses(2).get(5); expect(c.get).toHaveBeenCalledWith('/forums/2/responses/5'); });
177
+ test('create', () => { r.responses(2).create({}); expect(c.put).toHaveBeenCalledWith('/forums/2/responses', {}); });
178
+ test('edit', () => { r.responses(2).edit(5, {}); expect(c.patch).toHaveBeenCalledWith('/forums/2/responses/5', {}); });
179
+ test('delete', () => { r.responses(2).delete(5); expect(c.del).toHaveBeenCalledWith('/forums/2/responses/5'); });
180
+ test('approve', () => { r.responses(2).approve(5); expect(c.post).toHaveBeenCalledWith('/forums/2/responses/5/approve'); });
181
+ });
182
+ });
183
+
184
+ // ─── Hashes ───────────────────────────────────────────────────────────────────
185
+
186
+ describe('Hashes', () => {
187
+ let c, r;
188
+ beforeEach(() => { c = mockClient(); r = new Hashes(c); });
189
+
190
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/hashes'); });
191
+ test('get by id', () => { r.get(1); expect(c.get).toHaveBeenCalledWith('/hashes/1'); });
192
+ test('generate', () => { r.generate({}); expect(c.put).toHaveBeenCalledWith('/hashes/generate', {}); });
193
+ test('delete', () => { r.delete(1); expect(c.del).toHaveBeenCalledWith('/hashes/1'); });
194
+ });
195
+
196
+ // ─── MailBlacklist ────────────────────────────────────────────────────────────
197
+
198
+ describe('MailBlacklist', () => {
199
+ let c, r;
200
+ beforeEach(() => { c = mockClient(); r = new MailBlacklist(c); });
201
+
202
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/mail-blacklist'); });
203
+ test('get by id', () => { r.get(1); expect(c.get).toHaveBeenCalledWith('/mail-blacklist/1'); });
204
+ test('create', () => { r.create({}); expect(c.put).toHaveBeenCalledWith('/mail-blacklist', {}); });
205
+ test('delete', () => { r.delete(1); expect(c.del).toHaveBeenCalledWith('/mail-blacklist/1'); });
206
+ });
207
+
208
+ // ─── Organizations ────────────────────────────────────────────────────────────
209
+
210
+ describe('Organizations', () => {
211
+ let c, r;
212
+ beforeEach(() => { c = mockClient(); r = new Organizations(c); });
213
+
214
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/organizations'); });
215
+ test('get by id', () => { r.get(1); expect(c.get).toHaveBeenCalledWith('/organizations/1'); });
216
+ test('create', () => { r.create({}); expect(c.put).toHaveBeenCalledWith('/organizations', {}); });
217
+ test('edit', () => { r.edit(1, {}); expect(c.patch).toHaveBeenCalledWith('/organizations/1', {}); });
218
+ });
219
+
220
+ // ─── Translations ─────────────────────────────────────────────────────────────
221
+
222
+ describe('Translations', () => {
223
+ let c, r;
224
+ beforeEach(() => { c = mockClient(); r = new Translations(c); });
225
+
226
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/translations'); });
227
+ test('get by id', () => { r.get(1); expect(c.get).toHaveBeenCalledWith('/translations/1'); });
228
+ test('create', () => { r.create({}); expect(c.put).toHaveBeenCalledWith('/translations', {}); });
229
+ test('delete', () => { r.delete(1); expect(c.del).toHaveBeenCalledWith('/translations/1'); });
230
+ test('editText', () => { r.editText(1, {}); expect(c.patch).toHaveBeenCalledWith('/translations/1/text', {}); });
231
+ });
232
+
233
+ // ─── Courses (nested) ─────────────────────────────────────────────────────────
234
+
235
+ describe('Courses', () => {
236
+ let c, r;
237
+ beforeEach(() => { c = mockClient(); r = new Courses(c); });
238
+
239
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/courses'); });
240
+ test('get by id', () => { r.get(1); expect(c.get).toHaveBeenCalledWith('/courses/1'); });
241
+ test('create', () => { r.create({}); expect(c.put).toHaveBeenCalledWith('/courses', {}); });
242
+ test('edit', () => { r.edit(1, {}); expect(c.patch).toHaveBeenCalledWith('/courses/1', {}); });
243
+ test('delete', () => { r.delete(1); expect(c.del).toHaveBeenCalledWith('/courses/1'); });
244
+
245
+ describe('dates()', () => {
246
+ test('get all', () => { r.dates(1).get(); expect(c.get).toHaveBeenCalledWith('/courses/1/dates'); });
247
+ test('get by id', () => { r.dates(1).get(2); expect(c.get).toHaveBeenCalledWith('/courses/1/dates/2'); });
248
+ test('create', () => { r.dates(1).create({}); expect(c.put).toHaveBeenCalledWith('/courses/1/dates', {}); });
249
+ test('edit', () => { r.dates(1).edit(2, {}); expect(c.patch).toHaveBeenCalledWith('/courses/1/dates/2', {}); });
250
+ test('delete', () => { r.dates(1).delete(2); expect(c.del).toHaveBeenCalledWith('/courses/1/dates/2'); });
251
+ });
252
+
253
+ describe('sessions()', () => {
254
+ test('get all', () => { r.sessions(1).get(); expect(c.get).toHaveBeenCalledWith('/courses/1/sessions'); });
255
+ test('get by id', () => { r.sessions(1).get(2); expect(c.get).toHaveBeenCalledWith('/courses/1/sessions/2'); });
256
+ test('create', () => { r.sessions(1).create({}); expect(c.put).toHaveBeenCalledWith('/courses/1/sessions', {}); });
257
+ test('edit', () => { r.sessions(1).edit(2, {}); expect(c.patch).toHaveBeenCalledWith('/courses/1/sessions/2', {}); });
258
+ test('delete', () => { r.sessions(1).delete(2); expect(c.del).toHaveBeenCalledWith('/courses/1/sessions/2'); });
259
+ });
260
+
261
+ describe('premiums()', () => {
262
+ test('get all', () => { r.premiums(1).get(); expect(c.get).toHaveBeenCalledWith('/courses/1/premiums'); });
263
+ test('get by id', () => { r.premiums(1).get(2); expect(c.get).toHaveBeenCalledWith('/courses/1/premiums/2'); });
264
+ test('create', () => { r.premiums(1).create({}); expect(c.put).toHaveBeenCalledWith('/courses/1/premiums', {}); });
265
+ test('edit', () => { r.premiums(1).edit(2, {}); expect(c.patch).toHaveBeenCalledWith('/courses/1/premiums/2', {}); });
266
+ test('delete', () => { r.premiums(1).delete(2); expect(c.del).toHaveBeenCalledWith('/courses/1/premiums/2'); });
267
+
268
+ describe('items()', () => {
269
+ test('get all', () => { r.premiums(1).items(2).get(); expect(c.get).toHaveBeenCalledWith('/courses/1/premiums/2/items'); });
270
+ test('get by id', () => { r.premiums(1).items(2).get(3); expect(c.get).toHaveBeenCalledWith('/courses/1/premiums/2/items/3'); });
271
+ test('create', () => { r.premiums(1).items(2).create({}); expect(c.put).toHaveBeenCalledWith('/courses/1/premiums/2/items', {}); });
272
+ test('edit', () => { r.premiums(1).items(2).edit(3, {}); expect(c.patch).toHaveBeenCalledWith('/courses/1/premiums/2/items/3', {}); });
273
+ test('delete', () => { r.premiums(1).items(2).delete(3); expect(c.del).toHaveBeenCalledWith('/courses/1/premiums/2/items/3'); });
274
+ });
275
+ });
276
+
277
+ describe('levels()', () => {
278
+ test('get all', () => { r.levels(1).get(); expect(c.get).toHaveBeenCalledWith('/courses/1/levels'); });
279
+ test('get by id', () => { r.levels(1).get(2); expect(c.get).toHaveBeenCalledWith('/courses/1/levels/2'); });
280
+ test('create', () => { r.levels(1).create({}); expect(c.put).toHaveBeenCalledWith('/courses/1/levels', {}); });
281
+ test('edit', () => { r.levels(1).edit(2, {}); expect(c.patch).toHaveBeenCalledWith('/courses/1/levels/2', {}); });
282
+ test('delete', () => { r.levels(1).delete(2); expect(c.del).toHaveBeenCalledWith('/courses/1/levels/2'); });
283
+
284
+ describe('lessons()', () => {
285
+ test('get all', () => { r.levels(1).lessons(2).get(); expect(c.get).toHaveBeenCalledWith('/courses/1/levels/2/lessons'); });
286
+ test('get by id', () => { r.levels(1).lessons(2).get(3); expect(c.get).toHaveBeenCalledWith('/courses/1/levels/2/lessons/3'); });
287
+ test('create', () => { r.levels(1).lessons(2).create({}); expect(c.put).toHaveBeenCalledWith('/courses/1/levels/2/lessons', {}); });
288
+ test('edit', () => { r.levels(1).lessons(2).edit(3, {}); expect(c.patch).toHaveBeenCalledWith('/courses/1/levels/2/lessons/3', {}); });
289
+ test('delete', () => { r.levels(1).lessons(2).delete(3); expect(c.del).toHaveBeenCalledWith('/courses/1/levels/2/lessons/3'); });
290
+
291
+ describe('materials()', () => {
292
+ test('get all', () => { r.levels(1).lessons(2).materials(3).get(); expect(c.get).toHaveBeenCalledWith('/courses/1/levels/2/lessons/3/materials'); });
293
+ test('get by id', () => { r.levels(1).lessons(2).materials(3).get(4); expect(c.get).toHaveBeenCalledWith('/courses/1/levels/2/lessons/3/materials/4'); });
294
+ test('create', () => { r.levels(1).lessons(2).materials(3).create({}); expect(c.put).toHaveBeenCalledWith('/courses/1/levels/2/lessons/3/materials', {}); });
295
+ test('edit', () => { r.levels(1).lessons(2).materials(3).edit(4, {}); expect(c.patch).toHaveBeenCalledWith('/courses/1/levels/2/lessons/3/materials/4', {}); });
296
+ test('delete', () => { r.levels(1).lessons(2).materials(3).delete(4); expect(c.del).toHaveBeenCalledWith('/courses/1/levels/2/lessons/3/materials/4'); });
297
+ });
298
+ });
299
+ });
300
+ });
301
+
302
+ // ─── Quizzes (nested) ─────────────────────────────────────────────────────────
303
+
304
+ describe('Quizzes', () => {
305
+ let c, r;
306
+ beforeEach(() => { c = mockClient(); r = new Quizzes(c); });
307
+
308
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/quizzes'); });
309
+ test('get by id', () => { r.get(1); expect(c.get).toHaveBeenCalledWith('/quizzes/1'); });
310
+ test('create', () => { r.create({}); expect(c.put).toHaveBeenCalledWith('/quizzes', {}); });
311
+ test('edit', () => { r.edit(1, {}); expect(c.patch).toHaveBeenCalledWith('/quizzes/1', {}); });
312
+ test('delete', () => { r.delete(1); expect(c.del).toHaveBeenCalledWith('/quizzes/1'); });
313
+
314
+ describe('questions()', () => {
315
+ test('get all', () => { r.questions(1).get(); expect(c.get).toHaveBeenCalledWith('/quizzes/1/questions'); });
316
+ test('get by id', () => { r.questions(1).get(2); expect(c.get).toHaveBeenCalledWith('/quizzes/1/questions/2'); });
317
+ test('create', () => { r.questions(1).create({}); expect(c.put).toHaveBeenCalledWith('/quizzes/1/questions', {}); });
318
+ test('edit', () => { r.questions(1).edit(2, {}); expect(c.patch).toHaveBeenCalledWith('/quizzes/1/questions/2', {}); });
319
+ test('delete', () => { r.questions(1).delete(2); expect(c.del).toHaveBeenCalledWith('/quizzes/1/questions/2'); });
320
+
321
+ describe('answers()', () => {
322
+ test('get all', () => { r.questions(1).answers(2).get(); expect(c.get).toHaveBeenCalledWith('/quizzes/1/questions/2/answers'); });
323
+ test('get by id', () => { r.questions(1).answers(2).get(3); expect(c.get).toHaveBeenCalledWith('/quizzes/1/questions/2/answers/3'); });
324
+ test('create', () => { r.questions(1).answers(2).create({}); expect(c.put).toHaveBeenCalledWith('/quizzes/1/questions/2/answers', {}); });
325
+ test('edit', () => { r.questions(1).answers(2).edit(3, {}); expect(c.patch).toHaveBeenCalledWith('/quizzes/1/questions/2/answers/3', {}); });
326
+ test('delete', () => { r.questions(1).answers(2).delete(3); expect(c.del).toHaveBeenCalledWith('/quizzes/1/questions/2/answers/3'); });
327
+ });
328
+ });
329
+ });
330
+
331
+ // ─── Surveys (nested) ─────────────────────────────────────────────────────────
332
+
333
+ describe('Surveys', () => {
334
+ let c, r;
335
+ beforeEach(() => { c = mockClient(); r = new Surveys(c); });
336
+
337
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/surveys'); });
338
+ test('get by id', () => { r.get(1); expect(c.get).toHaveBeenCalledWith('/surveys/1'); });
339
+ test('create', () => { r.create({}); expect(c.put).toHaveBeenCalledWith('/surveys', {}); });
340
+ test('edit', () => { r.edit(1, {}); expect(c.patch).toHaveBeenCalledWith('/surveys/1', {}); });
341
+ test('delete', () => { r.delete(1); expect(c.del).toHaveBeenCalledWith('/surveys/1'); });
342
+
343
+ describe('questions()', () => {
344
+ test('get all', () => { r.questions(1).get(); expect(c.get).toHaveBeenCalledWith('/surveys/1/questions'); });
345
+ test('get by id', () => { r.questions(1).get(2); expect(c.get).toHaveBeenCalledWith('/surveys/1/questions/2'); });
346
+ test('create', () => { r.questions(1).create({}); expect(c.put).toHaveBeenCalledWith('/surveys/1/questions', {}); });
347
+ test('edit', () => { r.questions(1).edit(2, {}); expect(c.patch).toHaveBeenCalledWith('/surveys/1/questions/2', {}); });
348
+ test('delete', () => { r.questions(1).delete(2); expect(c.del).toHaveBeenCalledWith('/surveys/1/questions/2'); });
349
+
350
+ describe('answers()', () => {
351
+ test('get all', () => { r.questions(1).answers(2).get(); expect(c.get).toHaveBeenCalledWith('/surveys/1/questions/2/answers'); });
352
+ test('get by id', () => { r.questions(1).answers(2).get(3); expect(c.get).toHaveBeenCalledWith('/surveys/1/questions/2/answers/3'); });
353
+ test('create', () => { r.questions(1).answers(2).create({}); expect(c.put).toHaveBeenCalledWith('/surveys/1/questions/2/answers', {}); });
354
+ test('edit', () => { r.questions(1).answers(2).edit(3, {}); expect(c.patch).toHaveBeenCalledWith('/surveys/1/questions/2/answers/3', {}); });
355
+ test('delete', () => { r.questions(1).answers(2).delete(3); expect(c.del).toHaveBeenCalledWith('/surveys/1/questions/2/answers/3'); });
356
+ });
357
+ });
358
+ });
359
+
360
+ // ─── Teacher ─────────────────────────────────────────────────────────────────
361
+
362
+ describe('Teacher', () => {
363
+ let c, r;
364
+ beforeEach(() => { c = mockClient(); r = new Teacher(c); });
365
+
366
+ describe('absences()', () => {
367
+ test('get all', () => { r.absences().get(); expect(c.get).toHaveBeenCalledWith('/teacher/absences'); });
368
+ test('get by id', () => { r.absences().get(1); expect(c.get).toHaveBeenCalledWith('/teacher/absences/1'); });
369
+ test('create', () => { r.absences().create({}); expect(c.put).toHaveBeenCalledWith('/teacher/absences', {}); });
370
+ test('edit', () => { r.absences().edit(1, {}); expect(c.patch).toHaveBeenCalledWith('/teacher/absences/1', {}); });
371
+ test('delete', () => { r.absences().delete(1); expect(c.del).toHaveBeenCalledWith('/teacher/absences/1'); });
372
+ });
373
+
374
+ describe('configSets()', () => {
375
+ test('get all', () => { r.configSets().get(); expect(c.get).toHaveBeenCalledWith('/teacher/config-sets'); });
376
+ test('get by id', () => { r.configSets().get(1); expect(c.get).toHaveBeenCalledWith('/teacher/config-sets/1'); });
377
+ test('create', () => { r.configSets().create({}); expect(c.put).toHaveBeenCalledWith('/teacher/config-sets', {}); });
378
+ test('edit', () => { r.configSets().edit(1, {}); expect(c.patch).toHaveBeenCalledWith('/teacher/config-sets/1', {}); });
379
+ test('delete', () => { r.configSets().delete(1); expect(c.del).toHaveBeenCalledWith('/teacher/config-sets/1'); });
380
+ });
381
+
382
+ describe('configs()', () => {
383
+ test('get all', () => { r.configs().get(); expect(c.get).toHaveBeenCalledWith('/teacher/configs'); });
384
+ test('get by id', () => { r.configs().get(1); expect(c.get).toHaveBeenCalledWith('/teacher/configs/1'); });
385
+ test('create', () => { r.configs().create({}); expect(c.put).toHaveBeenCalledWith('/teacher/configs', {}); });
386
+ test('edit', () => { r.configs().edit(1, {}); expect(c.patch).toHaveBeenCalledWith('/teacher/configs/1', {}); });
387
+ test('delete', () => { r.configs().delete(1); expect(c.del).toHaveBeenCalledWith('/teacher/configs/1'); });
388
+ });
389
+ });
390
+
391
+ // ─── Users (nested) ───────────────────────────────────────────────────────────
392
+
393
+ describe('Users', () => {
394
+ let c, r;
395
+ beforeEach(() => { c = mockClient(); r = new Users(c); });
396
+
397
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/users'); });
398
+ test('get by id', () => { r.get(1); expect(c.get).toHaveBeenCalledWith('/users/1'); });
399
+ test('edit', () => { r.edit(1, {}); expect(c.patch).toHaveBeenCalledWith('/users/1', {}); });
400
+
401
+ const nestedPaths = [
402
+ ['courses', 'courses'],
403
+ ['courseNotes','course-notes'],
404
+ ['quizzes', 'quizzes'],
405
+ ['sessions', 'sessions'],
406
+ ['surveys', 'surveys'],
407
+ ['cart', 'cart'],
408
+ ];
409
+
410
+ nestedPaths.forEach(([method, path]) => {
411
+ describe(`${method}()`, () => {
412
+ test('get all', () => { r[method](1).get(); expect(c.get).toHaveBeenCalledWith(`/users/1/${path}`); });
413
+ test('get by id', () => { r[method](1).get(2); expect(c.get).toHaveBeenCalledWith(`/users/1/${path}/2`); });
414
+ test('create', () => { r[method](1).create({}); expect(c.put).toHaveBeenCalledWith(`/users/1/${path}`, {}); });
415
+ test('edit', () => { r[method](1).edit(2, {}); expect(c.patch).toHaveBeenCalledWith(`/users/1/${path}/2`, {}); });
416
+ test('delete', () => { r[method](1).delete(2); expect(c.del).toHaveBeenCalledWith(`/users/1/${path}/2`); });
417
+ });
418
+ });
419
+
420
+ describe('payments()', () => {
421
+ test('get all', () => { r.payments(1).get(); expect(c.get).toHaveBeenCalledWith('/users/1/payments'); });
422
+ test('get by id', () => { r.payments(1).get(2); expect(c.get).toHaveBeenCalledWith('/users/1/payments/2'); });
423
+ test('create', () => { r.payments(1).create({}); expect(c.put).toHaveBeenCalledWith('/users/1/payments', {}); });
424
+ test('edit', () => { r.payments(1).edit(2, {}); expect(c.patch).toHaveBeenCalledWith('/users/1/payments/2', {}); });
425
+ test('delete', () => { r.payments(1).delete(2); expect(c.del).toHaveBeenCalledWith('/users/1/payments/2'); });
426
+ test('verify', () => { r.payments(1).verify(2); expect(c.post).toHaveBeenCalledWith('/users/1/payments/2/verify'); });
427
+ test('reject', () => { r.payments(1).reject(2, {}); expect(c.post).toHaveBeenCalledWith('/users/1/payments/2/reject', {}); });
428
+ });
429
+
430
+ describe('points()', () => {
431
+ test('get all', () => { r.points(1).get(); expect(c.get).toHaveBeenCalledWith('/users/1/points'); });
432
+ test('get by id', () => { r.points(1).get(2); expect(c.get).toHaveBeenCalledWith('/users/1/points/2'); });
433
+ test('create', () => { r.points(1).create({}); expect(c.put).toHaveBeenCalledWith('/users/1/points', {}); });
434
+ test('delete', () => { r.points(1).delete(2); expect(c.del).toHaveBeenCalledWith('/users/1/points/2'); });
435
+ });
436
+
437
+ describe('moneyMoves()', () => {
438
+ test('get all', () => { r.moneyMoves(1).get(); expect(c.get).toHaveBeenCalledWith('/users/1/money-moves'); });
439
+ test('get by id', () => { r.moneyMoves(1).get(2); expect(c.get).toHaveBeenCalledWith('/users/1/money-moves/2'); });
440
+ test('create', () => { r.moneyMoves(1).create({}); expect(c.put).toHaveBeenCalledWith('/users/1/money-moves', {}); });
441
+ });
442
+
443
+ describe('statistics()', () => {
444
+ test('get', () => { r.statistics(1).get(); expect(c.get).toHaveBeenCalledWith('/users/1/statistics'); });
445
+ });
446
+
447
+ describe('organizations()', () => {
448
+ test('get all', () => { r.organizations(1).get(); expect(c.get).toHaveBeenCalledWith('/users/1/organizations'); });
449
+ test('get by id', () => { r.organizations(1).get(2); expect(c.get).toHaveBeenCalledWith('/users/1/organizations/2'); });
450
+ test('create', () => { r.organizations(1).create({}); expect(c.put).toHaveBeenCalledWith('/users/1/organizations', {}); });
451
+ test('delete', () => { r.organizations(1).delete(2); expect(c.del).toHaveBeenCalledWith('/users/1/organizations/2'); });
452
+ });
453
+
454
+ describe('pushEndpoints()', () => {
455
+ test('get all', () => { r.pushEndpoints(1).get(); expect(c.get).toHaveBeenCalledWith('/users/1/push-endpoints'); });
456
+ test('get by id', () => { r.pushEndpoints(1).get(2); expect(c.get).toHaveBeenCalledWith('/users/1/push-endpoints/2'); });
457
+ test('create', () => { r.pushEndpoints(1).create({}); expect(c.put).toHaveBeenCalledWith('/users/1/push-endpoints', {}); });
458
+ test('delete', () => { r.pushEndpoints(1).delete(2); expect(c.del).toHaveBeenCalledWith('/users/1/push-endpoints/2'); });
459
+ });
460
+ });
461
+
462
+ // ─── Zoom ─────────────────────────────────────────────────────────────────────
463
+
464
+ describe('Zoom', () => {
465
+ let c, r;
466
+ beforeEach(() => { c = mockClient(); r = new Zoom(c); });
467
+
468
+ describe('meetings()', () => {
469
+ test('get all', () => { r.meetings().get(); expect(c.get).toHaveBeenCalledWith('/zoom/meetings'); });
470
+ test('get by id', () => { r.meetings().get(1); expect(c.get).toHaveBeenCalledWith('/zoom/meetings/1'); });
471
+ });
472
+
473
+ describe('tokens()', () => {
474
+ test('get all', () => { r.tokens().get(); expect(c.get).toHaveBeenCalledWith('/zoom/tokens'); });
475
+ test('get by id', () => { r.tokens().get(1); expect(c.get).toHaveBeenCalledWith('/zoom/tokens/1'); });
476
+ test('create', () => { r.tokens().create({}); expect(c.put).toHaveBeenCalledWith('/zoom/tokens', {}); });
477
+ test('edit', () => { r.tokens().edit(1, {}); expect(c.patch).toHaveBeenCalledWith('/zoom/tokens/1', {}); });
478
+ test('delete', () => { r.tokens().delete(1); expect(c.del).toHaveBeenCalledWith('/zoom/tokens/1'); });
479
+ });
480
+ });