@easyflow/javascript-sdk 2.1.8 → 2.1.10

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 (94) hide show
  1. package/README.md +87 -7
  2. package/dist/index.d.ts +421 -0
  3. package/package.json +19 -6
  4. package/.babelrc +0 -5
  5. package/.github/workflows/deploy-sdk-cf.yml +0 -49
  6. package/.github/workflows/release-sdk-cdn.yml +0 -144
  7. package/.github/workflows/release-sdk.yml +0 -112
  8. package/.prettierrc +0 -6
  9. package/CDN-DEPLOYMENT.md +0 -175
  10. package/DEMO.md +0 -258
  11. package/DEPLOYMENT.md +0 -224
  12. package/INTEGRATION-GUIDE.md +0 -521
  13. package/coverage/base.css +0 -224
  14. package/coverage/block-navigation.js +0 -87
  15. package/coverage/easyflow-javascript-sdk/index.html +0 -116
  16. package/coverage/easyflow-javascript-sdk/libs/constants.mjs.html +0 -268
  17. package/coverage/easyflow-javascript-sdk/libs/errors.mjs.html +0 -271
  18. package/coverage/easyflow-javascript-sdk/libs/exception-handler.mjs.html +0 -148
  19. package/coverage/easyflow-javascript-sdk/libs/fingerprint.mjs.html +0 -895
  20. package/coverage/easyflow-javascript-sdk/libs/http.mjs.html +0 -502
  21. package/coverage/easyflow-javascript-sdk/libs/index.html +0 -266
  22. package/coverage/easyflow-javascript-sdk/libs/logger.mjs.html +0 -568
  23. package/coverage/easyflow-javascript-sdk/libs/sanitizer.mjs.html +0 -1099
  24. package/coverage/easyflow-javascript-sdk/libs/security.mjs.html +0 -733
  25. package/coverage/easyflow-javascript-sdk/libs/types.mjs.html +0 -508
  26. package/coverage/easyflow-javascript-sdk/libs/utils.mjs.html +0 -379
  27. package/coverage/easyflow-javascript-sdk/libs/validator.mjs.html +0 -2623
  28. package/coverage/easyflow-javascript-sdk/sdk.mjs.html +0 -2434
  29. package/coverage/favicon.png +0 -0
  30. package/coverage/index.html +0 -131
  31. package/coverage/lcov-report/base.css +0 -224
  32. package/coverage/lcov-report/block-navigation.js +0 -87
  33. package/coverage/lcov-report/easyflow-javascript-sdk/index.html +0 -116
  34. package/coverage/lcov-report/easyflow-javascript-sdk/libs/constants.mjs.html +0 -268
  35. package/coverage/lcov-report/easyflow-javascript-sdk/libs/errors.mjs.html +0 -271
  36. package/coverage/lcov-report/easyflow-javascript-sdk/libs/exception-handler.mjs.html +0 -148
  37. package/coverage/lcov-report/easyflow-javascript-sdk/libs/fingerprint.mjs.html +0 -895
  38. package/coverage/lcov-report/easyflow-javascript-sdk/libs/http.mjs.html +0 -502
  39. package/coverage/lcov-report/easyflow-javascript-sdk/libs/index.html +0 -266
  40. package/coverage/lcov-report/easyflow-javascript-sdk/libs/logger.mjs.html +0 -568
  41. package/coverage/lcov-report/easyflow-javascript-sdk/libs/sanitizer.mjs.html +0 -1099
  42. package/coverage/lcov-report/easyflow-javascript-sdk/libs/security.mjs.html +0 -733
  43. package/coverage/lcov-report/easyflow-javascript-sdk/libs/types.mjs.html +0 -508
  44. package/coverage/lcov-report/easyflow-javascript-sdk/libs/utils.mjs.html +0 -379
  45. package/coverage/lcov-report/easyflow-javascript-sdk/libs/validator.mjs.html +0 -2623
  46. package/coverage/lcov-report/easyflow-javascript-sdk/sdk.mjs.html +0 -2434
  47. package/coverage/lcov-report/favicon.png +0 -0
  48. package/coverage/lcov-report/index.html +0 -131
  49. package/coverage/lcov-report/prettify.css +0 -1
  50. package/coverage/lcov-report/prettify.js +0 -2
  51. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  52. package/coverage/lcov-report/sorter.js +0 -196
  53. package/coverage/lcov.info +0 -1429
  54. package/coverage/prettify.css +0 -1
  55. package/coverage/prettify.js +0 -2
  56. package/coverage/sort-arrow-sprite.png +0 -0
  57. package/coverage/sorter.js +0 -196
  58. package/dist/435.easyflow-sdk.min.js +0 -1
  59. package/dist/easyflow-sdk.min.js +0 -1
  60. package/dist/easyflow-sdk.min.js.LICENSE.txt +0 -1
  61. package/dist/index.html +0 -756
  62. package/docs/index.html +0 -775
  63. package/examples/lovable-integration.html +0 -410
  64. package/index.html +0 -981
  65. package/jest.config.js +0 -37
  66. package/jsdoc.json +0 -42
  67. package/libs/auto-integration.mjs +0 -333
  68. package/libs/constants.mjs +0 -61
  69. package/libs/constants.spec.js +0 -198
  70. package/libs/errors.mjs +0 -62
  71. package/libs/errors.spec.js +0 -178
  72. package/libs/exception-handler.mjs +0 -21
  73. package/libs/exception-handler.spec.js +0 -237
  74. package/libs/fingerprint.mjs +0 -270
  75. package/libs/http.mjs +0 -163
  76. package/libs/http.spec.js +0 -427
  77. package/libs/integration-wrapper.mjs +0 -285
  78. package/libs/logger.mjs +0 -161
  79. package/libs/logger.spec.js +0 -389
  80. package/libs/sanitizer.mjs +0 -340
  81. package/libs/sanitizer.spec.js +0 -583
  82. package/libs/security.mjs +0 -217
  83. package/libs/types.mjs +0 -141
  84. package/libs/utils.mjs +0 -368
  85. package/libs/utils.spec.js +0 -231
  86. package/libs/validator.mjs +0 -952
  87. package/libs/validator.spec.js +0 -615
  88. package/mocks/offer.mock.js +0 -77
  89. package/scripts/publish-npm.sh +0 -82
  90. package/sdk.mjs +0 -945
  91. package/sdk.spec.js +0 -796
  92. package/test-setup.cjs +0 -211
  93. package/test.html +0 -154
  94. package/webpack.config.cjs +0 -41
package/jest.config.js DELETED
@@ -1,37 +0,0 @@
1
- export default {
2
- testEnvironment: 'node',
3
- globals: {
4
- 'ts-jest': {
5
- useESM: true,
6
- },
7
- },
8
- moduleNameMapper: {
9
- '^(\\.{1,2}/.*)\\.js$': '$1',
10
- },
11
- transform: {},
12
- testMatch: [
13
- '**/test.js',
14
- '**/__tests__/**/*.js',
15
- '**/?(*.)+(spec|test).js',
16
- ],
17
- collectCoverageFrom: [
18
- 'sdk.mjs',
19
- 'libs/*.mjs',
20
- '!**/node_modules/**',
21
- '!**/dist/**',
22
- '!**/docs/**',
23
- ],
24
- coverageReporters: ['text', 'lcov', 'html'],
25
- coverageThreshold: {
26
- global: {
27
- branches: 80,
28
- functions: 80,
29
- lines: 80,
30
- statements: 80,
31
- },
32
- },
33
- setupFilesAfterEnv: ['<rootDir>/test-setup.cjs'],
34
- verbose: true,
35
- clearMocks: true,
36
- restoreMocks: true,
37
- }
package/jsdoc.json DELETED
@@ -1,42 +0,0 @@
1
- {
2
- "tags": {
3
- "allowUnknownTags": true,
4
- "dictionaries": [
5
- "jsdoc",
6
- "closure"
7
- ]
8
- },
9
- "source": {
10
- "include": [
11
- "sdk.mjs",
12
- "http.mjs"
13
- ],
14
- "includePattern": "\\.mjs$",
15
- "excludePattern": "(node_modules/|docs)"
16
- },
17
- "plugins": [],
18
- "templates": {
19
- "cleverLinks": false,
20
- "monospaceLinks": false,
21
- "default": {
22
- "outputSourceFiles": true
23
- },
24
- "path": "node_modules/clean-jsdoc-theme",
25
- "theme_opts": {
26
- "title": "Easyflow SDK Documentation",
27
- "menu": {
28
- "GitHub repo": {
29
- "href": "https://github.com/easyflow/sdk-javascript",
30
- "target": "_blank",
31
- "class": "menu-item",
32
- "id": "repository"
33
- }
34
- }
35
- }
36
- },
37
- "opts": {
38
- "destination": "./docs",
39
- "recurse": true,
40
- "readme": "./README.md"
41
- }
42
- }
@@ -1,333 +0,0 @@
1
- /**
2
- * Auto-Integration Script for Easyflow SDK
3
- *
4
- * Este script detecta automaticamente a plataforma e configura
5
- * a integração de forma otimizada para cada ambiente.
6
- */
7
-
8
- import { EasyflowIntegrationWrapper } from './integration-wrapper.mjs'
9
-
10
- /**
11
- * Detector de plataformas
12
- */
13
- class PlatformDetector {
14
- static detect() {
15
- // Detectar Lovable.dev
16
- if (this.isLovable()) {
17
- return {
18
- name: 'Lovable.dev',
19
- type: 'low-code',
20
- features: ['chat-ai', 'visual-editor', 'workflows'],
21
- integration: 'automatic',
22
- }
23
- }
24
-
25
- // Detectar Bubble
26
- if (this.isBubble()) {
27
- return {
28
- name: 'Bubble',
29
- type: 'low-code',
30
- features: ['visual-editor', 'database', 'workflows'],
31
- integration: 'javascript',
32
- }
33
- }
34
-
35
- // Detectar Webflow
36
- if (this.isWebflow()) {
37
- return {
38
- name: 'Webflow',
39
- type: 'design-platform',
40
- features: ['visual-editor', 'cms', 'ecommerce'],
41
- integration: 'javascript',
42
- }
43
- }
44
-
45
- // Detectar Zapier
46
- if (this.isZapier()) {
47
- return {
48
- name: 'Zapier',
49
- type: 'automation',
50
- features: ['webhooks', 'integrations', 'workflows'],
51
- integration: 'webhook',
52
- }
53
- }
54
-
55
- // Detectar Make.com
56
- if (this.isMake()) {
57
- return {
58
- name: 'Make.com',
59
- type: 'automation',
60
- features: ['visual-workflows', 'integrations'],
61
- integration: 'webhook',
62
- }
63
- }
64
-
65
- // Plataforma genérica
66
- return {
67
- name: 'Generic Platform',
68
- type: 'unknown',
69
- features: ['javascript-support'],
70
- integration: 'manual',
71
- }
72
- }
73
-
74
- static isLovable() {
75
- return (
76
- window.location.hostname.includes('lovable') ||
77
- document.querySelector('[data-lovable]') ||
78
- window.lovableConfig
79
- )
80
- }
81
-
82
- static isBubble() {
83
- return (
84
- window.location.hostname.includes('bubble') ||
85
- window.bubble ||
86
- document.querySelector('[data-bubble]')
87
- )
88
- }
89
-
90
- static isWebflow() {
91
- return (
92
- window.location.hostname.includes('webflow') ||
93
- window.Webflow ||
94
- document.querySelector('[data-wf-site]')
95
- )
96
- }
97
-
98
- static isZapier() {
99
- return (
100
- window.location.hostname.includes('zapier') ||
101
- window.zapier ||
102
- document.querySelector('[data-zapier]')
103
- )
104
- }
105
-
106
- static isMake() {
107
- return (
108
- window.location.hostname.includes('make') ||
109
- window.make ||
110
- document.querySelector('[data-make]')
111
- )
112
- }
113
- }
114
-
115
- /**
116
- * Configurador automático de integração
117
- */
118
- class AutoIntegrationConfigurator {
119
- constructor() {
120
- this.platform = PlatformDetector.detect()
121
- this.wrapper = null
122
- this.config = this.getDefaultConfig()
123
- }
124
-
125
- /**
126
- * Obter configuração padrão baseada na plataforma
127
- */
128
- getDefaultConfig() {
129
- const baseConfig = {
130
- autoInitialize: true,
131
- exposeGlobally: true,
132
- enableDebug: false,
133
- }
134
-
135
- switch (this.platform.name) {
136
- case 'Lovable.dev':
137
- return {
138
- ...baseConfig,
139
- globalScope: 'window',
140
- enableDebug: true,
141
- platform: 'lovable',
142
- }
143
-
144
- case 'Bubble':
145
- return {
146
- ...baseConfig,
147
- globalScope: 'window',
148
- enableDebug: false,
149
- platform: 'bubble',
150
- }
151
-
152
- case 'Webflow':
153
- return {
154
- ...baseConfig,
155
- globalScope: 'window',
156
- enableDebug: false,
157
- platform: 'webflow',
158
- }
159
-
160
- case 'Zapier':
161
- case 'Make.com':
162
- return {
163
- ...baseConfig,
164
- globalScope: 'global',
165
- enableDebug: false,
166
- platform: this.platform.name.toLowerCase(),
167
- }
168
-
169
- default:
170
- return {
171
- ...baseConfig,
172
- globalScope: 'window',
173
- enableDebug: false,
174
- platform: 'generic',
175
- }
176
- }
177
- }
178
-
179
- /**
180
- * Configurar integração automaticamente
181
- */
182
- async configure(config = {}) {
183
- try {
184
- // Mesclar configurações
185
- this.config = { ...this.config, ...config }
186
-
187
- // Criar wrapper
188
- this.wrapper = new EasyflowIntegrationWrapper(this.config)
189
-
190
- // Configurar callbacks específicos da plataforma
191
- this.configurePlatformCallbacks()
192
-
193
- // Log de sucesso
194
- if (this.config.enableDebug) {
195
- console.log(
196
- `🚀 Easyflow SDK configurado automaticamente para ${this.platform.name}`
197
- )
198
- console.log(`📋 Configurações:`, this.config)
199
- }
200
-
201
- return this.wrapper
202
- } catch (error) {
203
- console.error('❌ Erro na configuração automática:', error)
204
- throw error
205
- }
206
- }
207
-
208
- /**
209
- * Configurar callbacks específicos da plataforma
210
- */
211
- configurePlatformCallbacks() {
212
- if (!this.wrapper) return
213
-
214
- switch (this.platform.name) {
215
- case 'Lovable.dev':
216
- this.configureLovableCallbacks()
217
- break
218
-
219
- case 'Bubble':
220
- this.configureBubbleCallbacks()
221
- break
222
-
223
- case 'Webflow':
224
- this.configureWebflowCallbacks()
225
- break
226
-
227
- case 'Zapier':
228
- case 'Make.com':
229
- this.configureAutomationCallbacks()
230
- break
231
- }
232
- }
233
-
234
- /**
235
- * Callbacks específicos para Lovable
236
- */
237
- configureLovableCallbacks() {
238
- this.wrapper.on('customerCreated', (customer) => {
239
- console.log('🎉 Cliente criado no Lovable:', customer)
240
- // Aqui você pode adicionar lógica específica do Lovable
241
- })
242
-
243
- this.wrapper.on('paymentProcessed', (result) => {
244
- console.log('💳 Pagamento processado no Lovable:', result)
245
- // Aqui você pode adicionar lógica específica do Lovable
246
- })
247
- }
248
-
249
- /**
250
- * Callbacks específicos para Bubble
251
- */
252
- configureBubbleCallbacks() {
253
- this.wrapper.on('customerCreated', (customer) => {
254
- console.log('🎉 Cliente criado no Bubble:', customer)
255
- // Aqui você pode adicionar lógica específica do Bubble
256
- if (window.bubble_fn_updateCustomer) {
257
- window.bubble_fn_updateCustomer(customer)
258
- }
259
- })
260
-
261
- this.wrapper.on('paymentProcessed', (result) => {
262
- console.log('💳 Pagamento processado no Bubble:', result)
263
- // Aqui você pode adicionar lógica específica do Bubble
264
- if (window.bubble_fn_updatePaymentStatus) {
265
- window.bubble_fn_updatePaymentStatus(result)
266
- }
267
- })
268
- }
269
-
270
- /**
271
- * Callbacks específicos para Webflow
272
- */
273
- configureWebflowCallbacks() {
274
- this.wrapper.on('customerCreated', (customer) => {
275
- console.log('🎉 Cliente criado no Webflow:', customer)
276
- // Aqui você pode adicionar lógica específica do Webflow
277
- })
278
-
279
- this.wrapper.on('paymentProcessed', (result) => {
280
- console.log('💳 Pagamento processado no Webflow:', result)
281
- // Aqui você pode adicionar lógica específica do Webflow
282
- })
283
- }
284
-
285
- /**
286
- * Callbacks para plataformas de automação
287
- */
288
- configureAutomationCallbacks() {
289
- this.wrapper.on('customerCreated', (customer) => {
290
- console.log('🎉 Cliente criado via automação:', customer)
291
- // Aqui você pode adicionar lógica para webhooks
292
- })
293
-
294
- this.wrapper.on('paymentProcessed', (result) => {
295
- console.log('💳 Pagamento processado via automação:', result)
296
- // Aqui você pode adicionar lógica para webhooks
297
- })
298
- }
299
-
300
- /**
301
- * Obter informações da plataforma
302
- */
303
- getPlatformInfo() {
304
- return {
305
- ...this.platform,
306
- config: this.config,
307
- wrapper: this.wrapper,
308
- }
309
- }
310
- }
311
-
312
- /**
313
- * Função de inicialização automática
314
- */
315
- function autoConfigureEasyflow(config = {}) {
316
- const configurator = new AutoIntegrationConfigurator()
317
- return configurator.configure(config)
318
- }
319
-
320
- /**
321
- * Função para obter informações da plataforma
322
- */
323
- function getPlatformInfo() {
324
- const configurator = new AutoIntegrationConfigurator()
325
- return configurator.getPlatformInfo()
326
- }
327
-
328
- export {
329
- PlatformDetector,
330
- AutoIntegrationConfigurator,
331
- autoConfigureEasyflow,
332
- getPlatformInfo,
333
- }
@@ -1,61 +0,0 @@
1
- /**
2
- * Default configuration for Easyflow SDK
3
- */
4
- export const DEFAULT_CONFIG = {
5
- baseUrl: 'https://pay.easyflow.digital',
6
- timeout: 30000,
7
- headers: {},
8
- }
9
-
10
- /**
11
- * Payment method constants
12
- */
13
- export const PAYMENT_METHODS = {
14
- CREDIT_CARD: 'credit-card',
15
- PIX: 'pix',
16
- BANK_BILLET: 'bank-billet',
17
- }
18
-
19
- /**
20
- * API target constants
21
- */
22
- export const TARGETS = {
23
- CHARGE: 'charge',
24
- PLACE_ORDER: 'place-order',
25
- ENCRYPT: 'encrypt',
26
- GET_OFFER: 'get-offer',
27
- GET_ORDER: 'get-order',
28
- CREATE_CUSTOMER: 'create-customer',
29
- GET_CUSTOMER: 'get-customer',
30
- UPDATE_CUSTOMER: 'update-customer',
31
- ADD_CREDIT_CARD: 'add-credit-card',
32
- REMOVE_CREDIT_CARD: 'delete-credit-card',
33
- GET_CREDIT_CARD: 'get-credit-card',
34
- }
35
-
36
- /**
37
- * HTTP status codes used in the SDK
38
- * @type {{OK: number, CREATED: number, NO_CONTENT: number, BAD_REQUEST: number, UNAUTHORIZED: number, FORBIDDEN: number, NOT_FOUND: number, INTERNAL_SERVER_ERROR: number}}
39
- */
40
- export const HTTP_STATUS_CODES = {
41
- OK: 200,
42
- CREATED: 201,
43
- NO_CONTENT: 204,
44
- BAD_REQUEST: 400,
45
- UNAUTHORIZED: 401,
46
- FORBIDDEN: 403,
47
- NOT_FOUND: 404,
48
- INTERNAL_SERVER_ERROR: 500,
49
- }
50
-
51
- /**
52
- * HTTP request methods used in the SDK
53
- * @type {{GET: string, POST: string, PATCH: string, DELETE: string, PUT: string}}
54
- */
55
- export const HTTP_REQUEST_METHODS = {
56
- GET: 'GET',
57
- POST: 'POST',
58
- PATCH: 'PATCH',
59
- DELETE: 'DELETE',
60
- PUT: 'PUT',
61
- }
@@ -1,198 +0,0 @@
1
- import { describe, expect, test } from '@jest/globals'
2
- import {
3
- DEFAULT_CONFIG,
4
- HTTP_REQUEST_METHODS,
5
- HTTP_STATUS_CODES,
6
- PAYMENT_METHODS,
7
- TARGETS,
8
- } from './constants.mjs'
9
-
10
- describe('Constants', () => {
11
- describe('DEFAULT_CONFIG', () => {
12
- test('should have correct default configuration', () => {
13
- expect(DEFAULT_CONFIG).toEqual({
14
- baseUrl: 'https://pay.easyflow.digital',
15
- timeout: 30000,
16
- headers: {},
17
- })
18
- })
19
-
20
- test('should have baseUrl property', () => {
21
- expect(DEFAULT_CONFIG.baseUrl).toBe('https://pay.easyflow.digital')
22
- })
23
-
24
- test('should have timeout property', () => {
25
- expect(DEFAULT_CONFIG.timeout).toBe(30000)
26
- })
27
-
28
- test('should have headers property', () => {
29
- expect(DEFAULT_CONFIG.headers).toEqual({})
30
- })
31
- })
32
-
33
- describe('PAYMENT_METHODS', () => {
34
- test('should contain all expected payment methods', () => {
35
- expect(PAYMENT_METHODS).toEqual({
36
- CREDIT_CARD: 'credit-card',
37
- PIX: 'pix',
38
- BANK_BILLET: 'bank-billet',
39
- })
40
- })
41
-
42
- test('should have CREDIT_CARD method', () => {
43
- expect(PAYMENT_METHODS.CREDIT_CARD).toBe('credit-card')
44
- })
45
-
46
- test('should have PIX method', () => {
47
- expect(PAYMENT_METHODS.PIX).toBe('pix')
48
- })
49
-
50
- test('should have BANK_BILLET method', () => {
51
- expect(PAYMENT_METHODS.BANK_BILLET).toBe('bank-billet')
52
- })
53
- })
54
-
55
- describe('TARGETS', () => {
56
- test('should contain all expected API targets', () => {
57
- expect(TARGETS).toEqual({
58
- CHARGE: 'charge',
59
- PLACE_ORDER: 'place-order',
60
- ENCRYPT: 'encrypt',
61
- GET_OFFER: 'get-offer',
62
- GET_ORDER: 'get-order',
63
- CREATE_CUSTOMER: 'create-customer',
64
- GET_CUSTOMER: 'get-customer',
65
- UPDATE_CUSTOMER: 'update-customer',
66
- ADD_CREDIT_CARD: 'add-credit-card',
67
- REMOVE_CREDIT_CARD: 'delete-credit-card',
68
- GET_CREDIT_CARD: 'get-credit-card',
69
- })
70
- })
71
-
72
- test('should have CHARGE target', () => {
73
- expect(TARGETS.CHARGE).toBe('charge')
74
- })
75
-
76
- test('should have PLACE_ORDER target', () => {
77
- expect(TARGETS.PLACE_ORDER).toBe('place-order')
78
- })
79
-
80
- test('should have ENCRYPT target', () => {
81
- expect(TARGETS.ENCRYPT).toBe('encrypt')
82
- })
83
-
84
- test('should have GET_OFFER target', () => {
85
- expect(TARGETS.GET_OFFER).toBe('get-offer')
86
- })
87
-
88
- test('should have GET_ORDER target', () => {
89
- expect(TARGETS.GET_ORDER).toBe('get-order')
90
- })
91
- })
92
-
93
- describe('HTTP_STATUS_CODES', () => {
94
- test('should contain all expected HTTP status codes', () => {
95
- expect(HTTP_STATUS_CODES).toEqual({
96
- OK: 200,
97
- CREATED: 201,
98
- NO_CONTENT: 204,
99
- BAD_REQUEST: 400,
100
- UNAUTHORIZED: 401,
101
- FORBIDDEN: 403,
102
- NOT_FOUND: 404,
103
- INTERNAL_SERVER_ERROR: 500,
104
- })
105
- })
106
-
107
- test('should have correct status code values', () => {
108
- expect(HTTP_STATUS_CODES.OK).toBe(200)
109
- expect(HTTP_STATUS_CODES.CREATED).toBe(201)
110
- expect(HTTP_STATUS_CODES.NO_CONTENT).toBe(204)
111
- expect(HTTP_STATUS_CODES.BAD_REQUEST).toBe(400)
112
- expect(HTTP_STATUS_CODES.UNAUTHORIZED).toBe(401)
113
- expect(HTTP_STATUS_CODES.FORBIDDEN).toBe(403)
114
- expect(HTTP_STATUS_CODES.NOT_FOUND).toBe(404)
115
- expect(HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR).toBe(500)
116
- })
117
- })
118
-
119
- describe('HTTP_REQUEST_METHODS', () => {
120
- test('should contain all expected HTTP request methods', () => {
121
- expect(HTTP_REQUEST_METHODS).toEqual({
122
- GET: 'GET',
123
- POST: 'POST',
124
- PATCH: 'PATCH',
125
- DELETE: 'DELETE',
126
- PUT: 'PUT',
127
- })
128
- })
129
-
130
- test('should have correct HTTP method values', () => {
131
- expect(HTTP_REQUEST_METHODS.GET).toBe('GET')
132
- expect(HTTP_REQUEST_METHODS.POST).toBe('POST')
133
- expect(HTTP_REQUEST_METHODS.PATCH).toBe('PATCH')
134
- expect(HTTP_REQUEST_METHODS.DELETE).toBe('DELETE')
135
- expect(HTTP_REQUEST_METHODS.PUT).toBe('PUT')
136
- })
137
- })
138
-
139
- describe('Constants Structure', () => {
140
- test('all constants should be objects', () => {
141
- expect(typeof DEFAULT_CONFIG).toBe('object')
142
- expect(typeof PAYMENT_METHODS).toBe('object')
143
- expect(typeof TARGETS).toBe('object')
144
- expect(typeof HTTP_STATUS_CODES).toBe('object')
145
- expect(typeof HTTP_REQUEST_METHODS).toBe('object')
146
- })
147
-
148
- test('all constants should not be null', () => {
149
- expect(DEFAULT_CONFIG).not.toBeNull()
150
- expect(PAYMENT_METHODS).not.toBeNull()
151
- expect(TARGETS).not.toBeNull()
152
- expect(HTTP_STATUS_CODES).not.toBeNull()
153
- expect(HTTP_REQUEST_METHODS).not.toBeNull()
154
- })
155
-
156
- test('all constants should be defined', () => {
157
- expect(DEFAULT_CONFIG).toBeDefined()
158
- expect(PAYMENT_METHODS).toBeDefined()
159
- expect(TARGETS).toBeDefined()
160
- expect(HTTP_STATUS_CODES).toBeDefined()
161
- expect(HTTP_REQUEST_METHODS).toBeDefined()
162
- })
163
- })
164
-
165
- describe('Constants Values', () => {
166
- test('DEFAULT_CONFIG should have valid URL', () => {
167
- expect(DEFAULT_CONFIG.baseUrl).toMatch(/^https?:\/\/.+/)
168
- })
169
-
170
- test('DEFAULT_CONFIG timeout should be positive number', () => {
171
- expect(DEFAULT_CONFIG.timeout).toBeGreaterThan(0)
172
- })
173
-
174
- test('PAYMENT_METHODS should have string values', () => {
175
- Object.values(PAYMENT_METHODS).forEach((value) => {
176
- expect(typeof value).toBe('string')
177
- })
178
- })
179
-
180
- test('TARGETS should have string values', () => {
181
- Object.values(TARGETS).forEach((value) => {
182
- expect(typeof value).toBe('string')
183
- })
184
- })
185
-
186
- test('HTTP_STATUS_CODES should have number values', () => {
187
- Object.values(HTTP_STATUS_CODES).forEach((value) => {
188
- expect(typeof value).toBe('number')
189
- })
190
- })
191
-
192
- test('HTTP_REQUEST_METHODS should have string values', () => {
193
- Object.values(HTTP_REQUEST_METHODS).forEach((value) => {
194
- expect(typeof value).toBe('string')
195
- })
196
- })
197
- })
198
- })