@solytude/listmonk 1.0.0
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/LICENSE +21 -0
- package/README.md +542 -0
- package/dist/chunk-saezhne8.js +14 -0
- package/dist/chunk-saezhne8.js.map +9 -0
- package/dist/client.d.ts +430 -0
- package/dist/errors/api.d.ts +178 -0
- package/dist/errors/base.d.ts +47 -0
- package/dist/errors/configuration.d.ts +49 -0
- package/dist/errors/index.d.ts +13 -0
- package/dist/errors/network.d.ts +69 -0
- package/dist/errors/validation.d.ts +57 -0
- package/dist/http/auth.d.ts +39 -0
- package/dist/http/client.d.ts +149 -0
- package/dist/http/hooks.d.ts +90 -0
- package/dist/http/index.d.ts +10 -0
- package/dist/http/resource.d.ts +100 -0
- package/dist/http/sse.d.ts +36 -0
- package/dist/http/url.d.ts +51 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +16039 -0
- package/dist/index.js.map +120 -0
- package/dist/resources/admin/admin.d.ts +92 -0
- package/dist/resources/admin/index.d.ts +10 -0
- package/dist/resources/admin/schemas.d.ts +23 -0
- package/dist/resources/admin/types.d.ts +29 -0
- package/dist/resources/bounces/bounces.d.ts +262 -0
- package/dist/resources/bounces/index.d.ts +10 -0
- package/dist/resources/bounces/schemas.d.ts +86 -0
- package/dist/resources/bounces/types.d.ts +37 -0
- package/dist/resources/campaigns/campaigns.d.ts +339 -0
- package/dist/resources/campaigns/index.d.ts +10 -0
- package/dist/resources/campaigns/schemas.d.ts +374 -0
- package/dist/resources/campaigns/types.d.ts +111 -0
- package/dist/resources/dashboard/dashboard.d.ts +73 -0
- package/dist/resources/dashboard/index.d.ts +10 -0
- package/dist/resources/dashboard/schemas.d.ts +55 -0
- package/dist/resources/dashboard/types.d.ts +22 -0
- package/dist/resources/import/import.d.ts +215 -0
- package/dist/resources/import/index.d.ts +10 -0
- package/dist/resources/import/schemas.d.ts +109 -0
- package/dist/resources/import/types.d.ts +72 -0
- package/dist/resources/lists/index.d.ts +10 -0
- package/dist/resources/lists/lists.d.ts +180 -0
- package/dist/resources/lists/schemas.d.ts +176 -0
- package/dist/resources/lists/types.d.ts +56 -0
- package/dist/resources/maintenance/index.d.ts +10 -0
- package/dist/resources/maintenance/maintenance.d.ts +92 -0
- package/dist/resources/maintenance/schemas.d.ts +36 -0
- package/dist/resources/maintenance/types.d.ts +31 -0
- package/dist/resources/media/index.d.ts +10 -0
- package/dist/resources/media/media.d.ts +198 -0
- package/dist/resources/media/schemas.d.ts +48 -0
- package/dist/resources/media/types.d.ts +48 -0
- package/dist/resources/public/index.d.ts +10 -0
- package/dist/resources/public/public.d.ts +111 -0
- package/dist/resources/public/schemas.d.ts +52 -0
- package/dist/resources/public/types.d.ts +30 -0
- package/dist/resources/settings/index.d.ts +10 -0
- package/dist/resources/settings/schemas.d.ts +374 -0
- package/dist/resources/settings/settings.d.ts +106 -0
- package/dist/resources/settings/types.d.ts +78 -0
- package/dist/resources/subscribers/index.d.ts +10 -0
- package/dist/resources/subscribers/schemas.d.ts +360 -0
- package/dist/resources/subscribers/subscribers.d.ts +308 -0
- package/dist/resources/subscribers/types.d.ts +113 -0
- package/dist/resources/templates/index.d.ts +10 -0
- package/dist/resources/templates/schemas.d.ts +110 -0
- package/dist/resources/templates/templates.d.ts +225 -0
- package/dist/resources/templates/types.d.ts +45 -0
- package/dist/resources/tx/index.d.ts +10 -0
- package/dist/resources/tx/schemas.d.ts +67 -0
- package/dist/resources/tx/tx.d.ts +167 -0
- package/dist/resources/tx/types.d.ts +88 -0
- package/dist/schemas/common.d.ts +48 -0
- package/dist/schemas/index.d.ts +6 -0
- package/dist/testing/errors.d.ts +25 -0
- package/dist/testing/factories/bounce.d.ts +43 -0
- package/dist/testing/factories/campaign.d.ts +43 -0
- package/dist/testing/factories/common.d.ts +54 -0
- package/dist/testing/factories/index.d.ts +12 -0
- package/dist/testing/factories/list.d.ts +43 -0
- package/dist/testing/factories/media.d.ts +40 -0
- package/dist/testing/factories/subscriber.d.ts +43 -0
- package/dist/testing/factories/template.d.ts +40 -0
- package/dist/testing/index.d.ts +39 -0
- package/dist/testing/index.js +573 -0
- package/dist/testing/index.js.map +32 -0
- package/dist/testing/mock-client.d.ts +119 -0
- package/dist/testing/mock-function.d.ts +28 -0
- package/dist/testing/resources/admin.d.ts +20 -0
- package/dist/testing/resources/bounces.d.ts +22 -0
- package/dist/testing/resources/campaigns.d.ts +31 -0
- package/dist/testing/resources/dashboard.d.ts +17 -0
- package/dist/testing/resources/import.d.ts +19 -0
- package/dist/testing/resources/index.d.ts +18 -0
- package/dist/testing/resources/lists.d.ts +24 -0
- package/dist/testing/resources/maintenance.d.ts +18 -0
- package/dist/testing/resources/media.d.ts +21 -0
- package/dist/testing/resources/public.d.ts +18 -0
- package/dist/testing/resources/settings.d.ts +19 -0
- package/dist/testing/resources/subscribers.d.ts +33 -0
- package/dist/testing/resources/templates.d.ts +24 -0
- package/dist/testing/resources/tx.d.ts +16 -0
- package/dist/testing/types.d.ts +138 -0
- package/dist/types/config.d.ts +59 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/pagination.d.ts +37 -0
- package/package.json +97 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/testing/errors.ts", "../src/testing/mock-function.ts", "../src/testing/resources/subscribers.ts", "../src/testing/resources/lists.ts", "../src/testing/resources/campaigns.ts", "../src/testing/resources/templates.ts", "../src/testing/resources/tx.ts", "../src/testing/resources/media.ts", "../src/testing/resources/import.ts", "../src/testing/resources/bounces.ts", "../src/testing/resources/settings.ts", "../src/testing/resources/dashboard.ts", "../src/testing/resources/admin.ts", "../src/testing/resources/maintenance.ts", "../src/testing/resources/public.ts", "../src/testing/mock-client.ts", "../src/testing/factories/common.ts", "../src/testing/factories/subscriber.ts", "../src/testing/factories/list.ts", "../src/testing/factories/campaign.ts", "../src/testing/factories/template.ts", "../src/testing/factories/media.ts", "../src/testing/factories/bounce.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Error thrown when an unconfigured mock function is called.\n *\n * @example\n * ```typescript\n * const mockClient = new MockListmonkClient();\n *\n * // This throws MockNotConfiguredError\n * await mockClient.subscribers.get(1);\n * // Error: Mock method 'subscribers.get' was called but not configured.\n * // Configure with: mockClient.subscribers.get.mockResolvedValue(...)\n * ```\n */\nexport class MockNotConfiguredError extends Error {\n\toverride readonly name = \"MockNotConfiguredError\" as const;\n\n\t/**\n\t * The name of the method that was called without configuration.\n\t */\n\treadonly methodName: string;\n\n\t/**\n\t * The resource name (e.g., 'subscribers', 'campaigns').\n\t */\n\treadonly resourceName: string;\n\n\tconstructor(resourceName: string, methodName: string) {\n\t\tconst fullPath = `${resourceName}.${methodName}`;\n\t\tsuper(\n\t\t\t`Mock method '${fullPath}' was called but not configured.\\n` +\n\t\t\t\t`Configure with: mockClient.${fullPath}.mockResolvedValue(...)`,\n\t\t);\n\t\tthis.resourceName = resourceName;\n\t\tthis.methodName = methodName;\n\t}\n}\n",
|
|
6
|
+
"/**\n * Mock function implementation for test-runner-agnostic testing.\n *\n * @module testing/mock-function\n */\n\nimport { MockNotConfiguredError } from \"./errors\";\nimport type { MockFunction, MockState } from \"./types\";\n\n/**\n * Creates a mock function with call tracking and configurable return values.\n *\n * @param resourceName - The resource name for error messages (e.g., 'subscribers')\n * @param methodName - The method name for error messages (e.g., 'get')\n * @returns A mock function that can be configured and tracked\n *\n * @example\n * ```typescript\n * const mockGet = createMockFunction<[number], Promise<Subscriber>>(\n * 'subscribers',\n * 'get'\n * );\n *\n * mockGet.mockResolvedValue({ id: 1, email: 'test@example.com' });\n *\n * const result = await mockGet(1);\n * console.log(mockGet.mock.callCount); // 1\n * console.log(mockGet.mock.calls[0]); // [1]\n * ```\n */\nexport function createMockFunction<TArgs extends unknown[], TReturn>(\n\tresourceName: string,\n\tmethodName: string,\n): MockFunction<TArgs, TReturn> {\n\tlet implementation: ((...args: TArgs) => TReturn) | undefined;\n\tlet isConfigured = false;\n\n\tconst state: MockState<TArgs, Awaited<TReturn>> = {\n\t\tcalls: [],\n\t\tresults: [],\n\t\tlastCall: undefined,\n\t\tcallCount: 0,\n\t};\n\n\tconst mockFn = ((...args: TArgs): TReturn => {\n\t\tstate.calls.push(args);\n\t\tstate.lastCall = args;\n\t\tstate.callCount++;\n\n\t\tif (!isConfigured) {\n\t\t\tconst error = new MockNotConfiguredError(resourceName, methodName);\n\t\t\tstate.results.push({ type: \"throw\", value: error });\n\t\t\tthrow error;\n\t\t}\n\n\t\ttry {\n\t\t\t// implementation is guaranteed to exist after isConfigured check\n\t\t\tconst result = implementation!(...args);\n\n\t\t\t// Handle promise results\n\t\t\tif (result instanceof Promise) {\n\t\t\t\treturn result\n\t\t\t\t\t.then((value) => {\n\t\t\t\t\t\tstate.results.push({\n\t\t\t\t\t\t\ttype: \"return\",\n\t\t\t\t\t\t\tvalue: value as Awaited<TReturn>,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error) => {\n\t\t\t\t\t\tstate.results.push({ type: \"throw\", value: error });\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}) as TReturn;\n\t\t\t}\n\n\t\t\tstate.results.push({\n\t\t\t\ttype: \"return\",\n\t\t\t\tvalue: result as Awaited<TReturn>,\n\t\t\t});\n\t\t\treturn result as TReturn;\n\t\t} catch (error) {\n\t\t\tstate.results.push({\n\t\t\t\ttype: \"throw\",\n\t\t\t\tvalue: error instanceof Error ? error : new Error(String(error)),\n\t\t\t});\n\t\t\tthrow error;\n\t\t}\n\t}) as MockFunction<TArgs, TReturn>;\n\n\tmockFn.mock = state;\n\n\tmockFn.mockResolvedValue = function (value: Awaited<TReturn>) {\n\t\tisConfigured = true;\n\t\timplementation = () => Promise.resolve(value) as TReturn;\n\t\treturn this;\n\t};\n\n\tmockFn.mockRejectedValue = function (error: Error) {\n\t\tisConfigured = true;\n\t\timplementation = () => Promise.reject(error) as TReturn;\n\t\treturn this;\n\t};\n\n\tmockFn.mockImplementation = function (fn: (...args: TArgs) => TReturn) {\n\t\tisConfigured = true;\n\t\timplementation = fn;\n\t\treturn this;\n\t};\n\n\tmockFn.mockReturnValue = function (value: TReturn) {\n\t\tisConfigured = true;\n\t\timplementation = () => value;\n\t\treturn this;\n\t};\n\n\tmockFn.mockAsyncIterator = function <T>(values: T[]) {\n\t\tisConfigured = true;\n\t\timplementation = (() => {\n\t\t\tlet index = 0;\n\t\t\treturn {\n\t\t\t\t[Symbol.asyncIterator]() {\n\t\t\t\t\treturn this;\n\t\t\t\t},\n\t\t\t\tasync next() {\n\t\t\t\t\tif (index < values.length) {\n\t\t\t\t\t\treturn { done: false, value: values[index++] };\n\t\t\t\t\t}\n\t\t\t\t\treturn { done: true, value: undefined };\n\t\t\t\t},\n\t\t\t};\n\t\t}) as unknown as (...args: TArgs) => TReturn;\n\t\treturn this;\n\t};\n\n\tmockFn.mockClear = function () {\n\t\tstate.calls = [];\n\t\tstate.results = [];\n\t\tstate.lastCall = undefined;\n\t\tstate.callCount = 0;\n\t\treturn this;\n\t};\n\n\tmockFn.mockReset = function () {\n\t\tthis.mockClear();\n\t\timplementation = undefined;\n\t\tisConfigured = false;\n\t\treturn this;\n\t};\n\n\treturn mockFn;\n}\n",
|
|
7
|
+
"/**\n * Mock subscribers resource.\n *\n * @module testing/resources/subscribers\n */\n\nimport { createMockFunction } from \"../mock-function\";\nimport type { MockFunction } from \"../types\";\n\n/**\n * Mock subscribers resource with all methods as mock functions.\n */\nexport interface MockSubscribersResource {\n\tcreate: MockFunction<[unknown], Promise<unknown>>;\n\tretrieve: MockFunction<[number], Promise<unknown>>;\n\tupdate: MockFunction<[number, unknown], Promise<unknown>>;\n\tremove: MockFunction<[number], Promise<void>>;\n\tlist: MockFunction<[unknown?], Promise<unknown>>;\n\tlistAll: MockFunction<[unknown?], AsyncIterableIterator<unknown>>;\n\tmodifyLists: MockFunction<[unknown], Promise<void>>;\n\tmodifyListsForList: MockFunction<[number, unknown], Promise<void>>;\n\tblocklist: MockFunction<[number], Promise<void>>;\n\tblocklistMany: MockFunction<[number[]], Promise<void>>;\n\tblocklistByQuery: MockFunction<[string], Promise<void>>;\n\tdeleteMany: MockFunction<[number[]], Promise<void>>;\n\tdeleteByQuery: MockFunction<[string], Promise<void>>;\n\tgetBounces: MockFunction<[number], Promise<unknown[]>>;\n\tdeleteBounces: MockFunction<[number], Promise<void>>;\n\texport: MockFunction<[number], Promise<unknown>>;\n\tsendOptin: MockFunction<[number], Promise<void>>;\n\tmodifyListsByQuery: MockFunction<[unknown], Promise<void>>;\n}\n\n/**\n * Creates a mock subscribers resource.\n */\nexport function createMockSubscribersResource(): MockSubscribersResource {\n\treturn {\n\t\tcreate: createMockFunction(\"subscribers\", \"create\"),\n\t\tretrieve: createMockFunction(\"subscribers\", \"retrieve\"),\n\t\tupdate: createMockFunction(\"subscribers\", \"update\"),\n\t\tremove: createMockFunction(\"subscribers\", \"remove\"),\n\t\tlist: createMockFunction(\"subscribers\", \"list\"),\n\t\tlistAll: createMockFunction(\"subscribers\", \"listAll\"),\n\t\tmodifyLists: createMockFunction(\"subscribers\", \"modifyLists\"),\n\t\tmodifyListsForList: createMockFunction(\"subscribers\", \"modifyListsForList\"),\n\t\tblocklist: createMockFunction(\"subscribers\", \"blocklist\"),\n\t\tblocklistMany: createMockFunction(\"subscribers\", \"blocklistMany\"),\n\t\tblocklistByQuery: createMockFunction(\"subscribers\", \"blocklistByQuery\"),\n\t\tdeleteMany: createMockFunction(\"subscribers\", \"deleteMany\"),\n\t\tdeleteByQuery: createMockFunction(\"subscribers\", \"deleteByQuery\"),\n\t\tgetBounces: createMockFunction(\"subscribers\", \"getBounces\"),\n\t\tdeleteBounces: createMockFunction(\"subscribers\", \"deleteBounces\"),\n\t\texport: createMockFunction(\"subscribers\", \"export\"),\n\t\tsendOptin: createMockFunction(\"subscribers\", \"sendOptin\"),\n\t\tmodifyListsByQuery: createMockFunction(\"subscribers\", \"modifyListsByQuery\"),\n\t};\n}\n",
|
|
8
|
+
"/**\n * Mock lists resource.\n *\n * @module testing/resources/lists\n */\n\nimport { createMockFunction } from \"../mock-function\";\nimport type { MockFunction } from \"../types\";\n\n/**\n * Mock lists resource with all methods as mock functions.\n */\nexport interface MockListsResource {\n\tcreate: MockFunction<[unknown], Promise<unknown>>;\n\tretrieve: MockFunction<[number], Promise<unknown>>;\n\tupdate: MockFunction<[number, unknown], Promise<unknown>>;\n\tremove: MockFunction<[number], Promise<void>>;\n\tlist: MockFunction<[unknown?], Promise<unknown>>;\n\tlistAll: MockFunction<[unknown?], AsyncIterableIterator<unknown>>;\n\tdeleteMany: MockFunction<[number[]], Promise<void>>;\n\tdeleteByQuery: MockFunction<[string], Promise<void>>;\n\tgetPublic: MockFunction<[], Promise<unknown[]>>;\n}\n\n/**\n * Creates a mock lists resource.\n */\nexport function createMockListsResource(): MockListsResource {\n\treturn {\n\t\tcreate: createMockFunction(\"lists\", \"create\"),\n\t\tretrieve: createMockFunction(\"lists\", \"retrieve\"),\n\t\tupdate: createMockFunction(\"lists\", \"update\"),\n\t\tremove: createMockFunction(\"lists\", \"remove\"),\n\t\tlist: createMockFunction(\"lists\", \"list\"),\n\t\tlistAll: createMockFunction(\"lists\", \"listAll\"),\n\t\tdeleteMany: createMockFunction(\"lists\", \"deleteMany\"),\n\t\tdeleteByQuery: createMockFunction(\"lists\", \"deleteByQuery\"),\n\t\tgetPublic: createMockFunction(\"lists\", \"getPublic\"),\n\t};\n}\n",
|
|
9
|
+
"/**\n * Mock campaigns resource.\n *\n * @module testing/resources/campaigns\n */\n\nimport { createMockFunction } from \"../mock-function\";\nimport type { MockFunction } from \"../types\";\n\n/**\n * Mock campaigns resource with all methods as mock functions.\n */\nexport interface MockCampaignsResource {\n\tcreate: MockFunction<[unknown], Promise<unknown>>;\n\tretrieve: MockFunction<[number, unknown?], Promise<unknown>>;\n\tupdate: MockFunction<[number, unknown], Promise<unknown>>;\n\tremove: MockFunction<[number], Promise<void>>;\n\tlist: MockFunction<[unknown?], Promise<unknown>>;\n\tlistAll: MockFunction<[unknown?], AsyncIterableIterator<unknown>>;\n\tupdateStatus: MockFunction<[number, string, unknown?], Promise<unknown>>;\n\tpreview: MockFunction<[number, unknown?], Promise<unknown>>;\n\tpreviewText: MockFunction<[number], Promise<unknown>>;\n\tgetRunningStats: MockFunction<[number[]], Promise<unknown[]>>;\n\tgetAnalytics: MockFunction<[string, unknown?], Promise<unknown[]>>;\n\tsendTest: MockFunction<[number, unknown], Promise<void>>;\n\tarchive: MockFunction<[number, boolean?, unknown?], Promise<unknown>>;\n\tconvertContent: MockFunction<[number, string], Promise<unknown>>;\n\tdeleteMany: MockFunction<[number[]], Promise<void>>;\n\tdeleteByQuery: MockFunction<[string], Promise<void>>;\n}\n\n/**\n * Creates a mock campaigns resource.\n */\nexport function createMockCampaignsResource(): MockCampaignsResource {\n\treturn {\n\t\tcreate: createMockFunction(\"campaigns\", \"create\"),\n\t\tretrieve: createMockFunction(\"campaigns\", \"retrieve\"),\n\t\tupdate: createMockFunction(\"campaigns\", \"update\"),\n\t\tremove: createMockFunction(\"campaigns\", \"remove\"),\n\t\tlist: createMockFunction(\"campaigns\", \"list\"),\n\t\tlistAll: createMockFunction(\"campaigns\", \"listAll\"),\n\t\tupdateStatus: createMockFunction(\"campaigns\", \"updateStatus\"),\n\t\tpreview: createMockFunction(\"campaigns\", \"preview\"),\n\t\tpreviewText: createMockFunction(\"campaigns\", \"previewText\"),\n\t\tgetRunningStats: createMockFunction(\"campaigns\", \"getRunningStats\"),\n\t\tgetAnalytics: createMockFunction(\"campaigns\", \"getAnalytics\"),\n\t\tsendTest: createMockFunction(\"campaigns\", \"sendTest\"),\n\t\tarchive: createMockFunction(\"campaigns\", \"archive\"),\n\t\tconvertContent: createMockFunction(\"campaigns\", \"convertContent\"),\n\t\tdeleteMany: createMockFunction(\"campaigns\", \"deleteMany\"),\n\t\tdeleteByQuery: createMockFunction(\"campaigns\", \"deleteByQuery\"),\n\t};\n}\n",
|
|
10
|
+
"/**\n * Mock templates resource.\n *\n * @module testing/resources/templates\n */\n\nimport { createMockFunction } from \"../mock-function\";\nimport type { MockFunction } from \"../types\";\n\n/**\n * Mock templates resource with all methods as mock functions.\n */\nexport interface MockTemplatesResource {\n\tcreate: MockFunction<[unknown], Promise<unknown>>;\n\tretrieve: MockFunction<[number], Promise<unknown>>;\n\tupdate: MockFunction<[number, unknown], Promise<unknown>>;\n\tremove: MockFunction<[number], Promise<void>>;\n\tlist: MockFunction<[unknown?], Promise<unknown[]>>;\n\tlistAll: MockFunction<[unknown?], AsyncIterableIterator<unknown>>;\n\tpreview: MockFunction<[number | null, unknown?], Promise<unknown>>;\n\tsetDefault: MockFunction<[number], Promise<unknown>>;\n\tdeleteMany: MockFunction<[number[]], Promise<void>>;\n}\n\n/**\n * Creates a mock templates resource.\n */\nexport function createMockTemplatesResource(): MockTemplatesResource {\n\treturn {\n\t\tcreate: createMockFunction(\"templates\", \"create\"),\n\t\tretrieve: createMockFunction(\"templates\", \"retrieve\"),\n\t\tupdate: createMockFunction(\"templates\", \"update\"),\n\t\tremove: createMockFunction(\"templates\", \"remove\"),\n\t\tlist: createMockFunction(\"templates\", \"list\"),\n\t\tlistAll: createMockFunction(\"templates\", \"listAll\"),\n\t\tpreview: createMockFunction(\"templates\", \"preview\"),\n\t\tsetDefault: createMockFunction(\"templates\", \"setDefault\"),\n\t\tdeleteMany: createMockFunction(\"templates\", \"deleteMany\"),\n\t};\n}\n",
|
|
11
|
+
"/**\n * Mock transactional resource.\n *\n * @module testing/resources/tx\n */\n\nimport { createMockFunction } from \"../mock-function\";\nimport type { MockFunction } from \"../types\";\n\n/**\n * Mock transactional resource with all methods as mock functions.\n */\nexport interface MockTransactionalResource {\n\tsend: MockFunction<[unknown], Promise<boolean>>;\n}\n\n/**\n * Creates a mock transactional resource.\n */\nexport function createMockTransactionalResource(): MockTransactionalResource {\n\treturn {\n\t\tsend: createMockFunction(\"tx\", \"send\"),\n\t};\n}\n",
|
|
12
|
+
"/**\n * Mock media resource.\n *\n * @module testing/resources/media\n */\n\nimport { createMockFunction } from \"../mock-function\";\nimport type { MockFunction } from \"../types\";\n\n/**\n * Mock media resource with all methods as mock functions.\n */\nexport interface MockMediaResource {\n\tupload: MockFunction<[unknown], Promise<unknown>>;\n\tlist: MockFunction<[], Promise<unknown[]>>;\n\tlistAll: MockFunction<[], AsyncIterableIterator<unknown>>;\n\tretrieve: MockFunction<[number], Promise<unknown>>;\n\tremove: MockFunction<[number], Promise<boolean>>;\n\tdeleteMany: MockFunction<[number[]], Promise<void>>;\n}\n\n/**\n * Creates a mock media resource.\n */\nexport function createMockMediaResource(): MockMediaResource {\n\treturn {\n\t\tupload: createMockFunction(\"media\", \"upload\"),\n\t\tlist: createMockFunction(\"media\", \"list\"),\n\t\tlistAll: createMockFunction(\"media\", \"listAll\"),\n\t\tretrieve: createMockFunction(\"media\", \"retrieve\"),\n\t\tremove: createMockFunction(\"media\", \"remove\"),\n\t\tdeleteMany: createMockFunction(\"media\", \"deleteMany\"),\n\t};\n}\n",
|
|
13
|
+
"/**\n * Mock import resource.\n *\n * @module testing/resources/import\n */\n\nimport { createMockFunction } from \"../mock-function\";\nimport type { MockFunction } from \"../types\";\n\n/**\n * Mock import resource with all methods as mock functions.\n */\nexport interface MockImportResource {\n\tstart: MockFunction<[unknown, unknown], Promise<unknown>>;\n\tgetStatus: MockFunction<[], Promise<unknown>>;\n\tgetLogs: MockFunction<[], Promise<string[]>>;\n\tcancel: MockFunction<[], Promise<boolean>>;\n}\n\n/**\n * Creates a mock import resource.\n */\nexport function createMockImportResource(): MockImportResource {\n\treturn {\n\t\tstart: createMockFunction(\"import\", \"start\"),\n\t\tgetStatus: createMockFunction(\"import\", \"getStatus\"),\n\t\tgetLogs: createMockFunction(\"import\", \"getLogs\"),\n\t\tcancel: createMockFunction(\"import\", \"cancel\"),\n\t};\n}\n",
|
|
14
|
+
"/**\n * Mock bounces resource.\n *\n * @module testing/resources/bounces\n */\n\nimport { createMockFunction } from \"../mock-function\";\nimport type { MockFunction } from \"../types\";\n\n/**\n * Mock bounces resource with all methods as mock functions.\n */\nexport interface MockBouncesResource {\n\tlist: MockFunction<[unknown?], Promise<unknown>>;\n\tlistAll: MockFunction<[unknown?], AsyncIterableIterator<unknown>>;\n\tremove: MockFunction<[number], Promise<boolean>>;\n\tdeleteMany: MockFunction<[number[]], Promise<boolean>>;\n\tdeleteAll: MockFunction<[], Promise<boolean>>;\n\tretrieve: MockFunction<[number], Promise<unknown>>;\n\tblocklistBounced: MockFunction<[], Promise<boolean>>;\n}\n\n/**\n * Creates a mock bounces resource.\n */\nexport function createMockBouncesResource(): MockBouncesResource {\n\treturn {\n\t\tlist: createMockFunction(\"bounces\", \"list\"),\n\t\tlistAll: createMockFunction(\"bounces\", \"listAll\"),\n\t\tremove: createMockFunction(\"bounces\", \"remove\"),\n\t\tdeleteMany: createMockFunction(\"bounces\", \"deleteMany\"),\n\t\tdeleteAll: createMockFunction(\"bounces\", \"deleteAll\"),\n\t\tretrieve: createMockFunction(\"bounces\", \"retrieve\"),\n\t\tblocklistBounced: createMockFunction(\"bounces\", \"blocklistBounced\"),\n\t};\n}\n",
|
|
15
|
+
"/**\n * Mock settings resource.\n *\n * @module testing/resources/settings\n */\n\nimport { createMockFunction } from \"../mock-function\";\nimport type { MockFunction } from \"../types\";\n\n/**\n * Mock settings resource with all methods as mock functions.\n */\nexport interface MockSettingsResource {\n\tgetAll: MockFunction<[], Promise<unknown>>;\n\tupdate: MockFunction<[unknown], Promise<unknown>>;\n\tupdateByKey: MockFunction<[string, unknown], Promise<true>>;\n\ttestSmtp: MockFunction<[unknown], Promise<unknown>>;\n}\n\n/**\n * Creates a mock settings resource.\n */\nexport function createMockSettingsResource(): MockSettingsResource {\n\treturn {\n\t\tgetAll: createMockFunction(\"settings\", \"getAll\"),\n\t\tupdate: createMockFunction(\"settings\", \"update\"),\n\t\tupdateByKey: createMockFunction(\"settings\", \"updateByKey\"),\n\t\ttestSmtp: createMockFunction(\"settings\", \"testSmtp\"),\n\t};\n}\n",
|
|
16
|
+
"/**\n * Mock dashboard resource.\n *\n * @module testing/resources/dashboard\n */\n\nimport { createMockFunction } from \"../mock-function\";\nimport type { MockFunction } from \"../types\";\n\n/**\n * Mock dashboard resource with all methods as mock functions.\n */\nexport interface MockDashboardResource {\n\tgetCounts: MockFunction<[], Promise<unknown>>;\n\tgetCharts: MockFunction<[], Promise<unknown>>;\n}\n\n/**\n * Creates a mock dashboard resource.\n */\nexport function createMockDashboardResource(): MockDashboardResource {\n\treturn {\n\t\tgetCounts: createMockFunction(\"dashboard\", \"getCounts\"),\n\t\tgetCharts: createMockFunction(\"dashboard\", \"getCharts\"),\n\t};\n}\n",
|
|
17
|
+
"/**\n * Mock admin resource.\n *\n * @module testing/resources/admin\n */\n\nimport { createMockFunction } from \"../mock-function\";\nimport type { MockFunction } from \"../types\";\n\n/**\n * Mock admin resource with all methods as mock functions.\n */\nexport interface MockAdminResource {\n\treload: MockFunction<[], Promise<unknown>>;\n\tgetLogs: MockFunction<[], Promise<unknown>>;\n\tgetEventStream: MockFunction<\n\t\t[unknown?],\n\t\tAsyncGenerator<unknown, void, undefined>\n\t>;\n}\n\n/**\n * Creates a mock admin resource.\n */\nexport function createMockAdminResource(): MockAdminResource {\n\treturn {\n\t\treload: createMockFunction(\"admin\", \"reload\"),\n\t\tgetLogs: createMockFunction(\"admin\", \"getLogs\"),\n\t\tgetEventStream: createMockFunction(\"admin\", \"getEventStream\"),\n\t};\n}\n",
|
|
18
|
+
"/**\n * Mock maintenance resource.\n *\n * @module testing/resources/maintenance\n */\n\nimport { createMockFunction } from \"../mock-function\";\nimport type { MockFunction } from \"../types\";\n\n/**\n * Mock maintenance resource with all methods as mock functions.\n */\nexport interface MockMaintenanceResource {\n\tgcSubscribers: MockFunction<[string], Promise<unknown>>;\n\tgcSubscriptions: MockFunction<[string], Promise<unknown>>;\n\tgcAnalytics: MockFunction<[string, string], Promise<unknown>>;\n}\n\n/**\n * Creates a mock maintenance resource.\n */\nexport function createMockMaintenanceResource(): MockMaintenanceResource {\n\treturn {\n\t\tgcSubscribers: createMockFunction(\"maintenance\", \"gcSubscribers\"),\n\t\tgcSubscriptions: createMockFunction(\"maintenance\", \"gcSubscriptions\"),\n\t\tgcAnalytics: createMockFunction(\"maintenance\", \"gcAnalytics\"),\n\t};\n}\n",
|
|
19
|
+
"/**\n * Mock public resource.\n *\n * @module testing/resources/public\n */\n\nimport { createMockFunction } from \"../mock-function\";\nimport type { MockFunction } from \"../types\";\n\n/**\n * Mock public resource with all methods as mock functions.\n */\nexport interface MockPublicResource {\n\tgetLists: MockFunction<[], Promise<unknown[]>>;\n\tsubscribe: MockFunction<[unknown], Promise<unknown>>;\n\tgetCaptchaChallenge: MockFunction<[], Promise<unknown>>;\n}\n\n/**\n * Creates a mock public resource.\n */\nexport function createMockPublicResource(): MockPublicResource {\n\treturn {\n\t\tgetLists: createMockFunction(\"public\", \"getLists\"),\n\t\tsubscribe: createMockFunction(\"public\", \"subscribe\"),\n\t\tgetCaptchaChallenge: createMockFunction(\"public\", \"getCaptchaChallenge\"),\n\t};\n}\n",
|
|
20
|
+
"/**\n * MockListmonkClient for testing.\n *\n * @module testing/mock-client\n */\n\nimport { createMockFunction } from \"./mock-function\";\nimport type { MockFunction } from \"./types\";\nimport {\n\ttype MockSubscribersResource,\n\tcreateMockSubscribersResource,\n\ttype MockListsResource,\n\tcreateMockListsResource,\n\ttype MockCampaignsResource,\n\tcreateMockCampaignsResource,\n\ttype MockTemplatesResource,\n\tcreateMockTemplatesResource,\n\ttype MockTransactionalResource,\n\tcreateMockTransactionalResource,\n\ttype MockMediaResource,\n\tcreateMockMediaResource,\n\ttype MockImportResource,\n\tcreateMockImportResource,\n\ttype MockBouncesResource,\n\tcreateMockBouncesResource,\n\ttype MockSettingsResource,\n\tcreateMockSettingsResource,\n\ttype MockDashboardResource,\n\tcreateMockDashboardResource,\n\ttype MockAdminResource,\n\tcreateMockAdminResource,\n\ttype MockMaintenanceResource,\n\tcreateMockMaintenanceResource,\n\ttype MockPublicResource,\n\tcreateMockPublicResource,\n} from \"./resources\";\n\n/**\n * Mock Listmonk client for testing.\n *\n * Mirrors the real Listmonk client interface with all methods replaced\n * by configurable MockFunctions. Use this for unit testing application\n * code that depends on the Listmonk SDK without making real API calls.\n *\n * @example\n * ```typescript\n * import { MockListmonkClient, createMockSubscriber } from '@solytude/listmonk/testing';\n *\n * describe('MyApp', () => {\n * let mockClient: MockListmonkClient;\n *\n * beforeEach(() => {\n * mockClient = new MockListmonkClient();\n * });\n *\n * afterEach(() => {\n * mockClient.reset();\n * });\n *\n * it('fetches subscribers', async () => {\n * const mockSub = { id: 1, email: 'test@example.com' };\n * mockClient.subscribers.retrieve.mockResolvedValue(mockSub);\n *\n * const result = await myApp.getSubscriber(1);\n *\n * expect(mockClient.subscribers.retrieve.mock.callCount).toBe(1);\n * expect(result.email).toBe('test@example.com');\n * });\n * });\n * ```\n */\nexport class MockListmonkClient {\n\t/**\n\t * Mocked subscribers resource.\n\t */\n\tpublic readonly subscribers: MockSubscribersResource;\n\n\t/**\n\t * Mocked lists resource.\n\t */\n\tpublic readonly lists: MockListsResource;\n\n\t/**\n\t * Mocked campaigns resource.\n\t */\n\tpublic readonly campaigns: MockCampaignsResource;\n\n\t/**\n\t * Mocked templates resource.\n\t */\n\tpublic readonly templates: MockTemplatesResource;\n\n\t/**\n\t * Mocked transactional resource.\n\t */\n\tpublic readonly tx: MockTransactionalResource;\n\n\t/**\n\t * Mocked media resource.\n\t */\n\tpublic readonly media: MockMediaResource;\n\n\t/**\n\t * Mocked import resource.\n\t */\n\tpublic readonly import: MockImportResource;\n\n\t/**\n\t * Mocked bounces resource.\n\t */\n\tpublic readonly bounces: MockBouncesResource;\n\n\t/**\n\t * Mocked settings resource.\n\t */\n\tpublic readonly settings: MockSettingsResource;\n\n\t/**\n\t * Mocked dashboard resource.\n\t */\n\tpublic readonly dashboard: MockDashboardResource;\n\n\t/**\n\t * Mocked admin resource.\n\t */\n\tpublic readonly admin: MockAdminResource;\n\n\t/**\n\t * Mocked maintenance resource.\n\t */\n\tpublic readonly maintenance: MockMaintenanceResource;\n\n\t/**\n\t * Mocked public resource.\n\t */\n\tpublic readonly public: MockPublicResource;\n\n\t/**\n\t * Mocked health check method.\n\t */\n\tpublic readonly health: MockFunction<[], Promise<unknown>>;\n\n\t/**\n\t * Mocked public health check method.\n\t */\n\tpublic readonly publicHealth: MockFunction<[], Promise<unknown>>;\n\n\t/**\n\t * Mocked config retrieval method.\n\t */\n\tpublic readonly getConfig: MockFunction<[], Promise<unknown>>;\n\n\t/**\n\t * Creates a new MockListmonkClient.\n\t *\n\t * Unlike the real Listmonk client, the mock client requires no configuration.\n\t */\n\tconstructor() {\n\t\tthis.subscribers = createMockSubscribersResource();\n\t\tthis.lists = createMockListsResource();\n\t\tthis.campaigns = createMockCampaignsResource();\n\t\tthis.templates = createMockTemplatesResource();\n\t\tthis.tx = createMockTransactionalResource();\n\t\tthis.media = createMockMediaResource();\n\t\tthis.import = createMockImportResource();\n\t\tthis.bounces = createMockBouncesResource();\n\t\tthis.settings = createMockSettingsResource();\n\t\tthis.dashboard = createMockDashboardResource();\n\t\tthis.admin = createMockAdminResource();\n\t\tthis.maintenance = createMockMaintenanceResource();\n\t\tthis.public = createMockPublicResource();\n\n\t\tthis.health = createMockFunction(\"client\", \"health\");\n\t\tthis.publicHealth = createMockFunction(\"client\", \"publicHealth\");\n\t\tthis.getConfig = createMockFunction(\"client\", \"getConfig\");\n\t}\n\n\t/**\n\t * Reset all mock configurations and call history.\n\t *\n\t * Should be called in afterEach() hooks to ensure test isolation.\n\t */\n\treset(): void {\n\t\t// Reset all subscriber mocks\n\t\tfor (const method of Object.values(this.subscribers)) {\n\t\t\tif (typeof method?.mockReset === \"function\") {\n\t\t\t\tmethod.mockReset();\n\t\t\t}\n\t\t}\n\n\t\t// Reset all list mocks\n\t\tfor (const method of Object.values(this.lists)) {\n\t\t\tif (typeof method?.mockReset === \"function\") {\n\t\t\t\tmethod.mockReset();\n\t\t\t}\n\t\t}\n\n\t\t// Reset all campaign mocks\n\t\tfor (const method of Object.values(this.campaigns)) {\n\t\t\tif (typeof method?.mockReset === \"function\") {\n\t\t\t\tmethod.mockReset();\n\t\t\t}\n\t\t}\n\n\t\t// Reset all template mocks\n\t\tfor (const method of Object.values(this.templates)) {\n\t\t\tif (typeof method?.mockReset === \"function\") {\n\t\t\t\tmethod.mockReset();\n\t\t\t}\n\t\t}\n\n\t\t// Reset all transactional mocks\n\t\tfor (const method of Object.values(this.tx)) {\n\t\t\tif (typeof method?.mockReset === \"function\") {\n\t\t\t\tmethod.mockReset();\n\t\t\t}\n\t\t}\n\n\t\t// Reset all media mocks\n\t\tfor (const method of Object.values(this.media)) {\n\t\t\tif (typeof method?.mockReset === \"function\") {\n\t\t\t\tmethod.mockReset();\n\t\t\t}\n\t\t}\n\n\t\t// Reset all import mocks\n\t\tfor (const method of Object.values(this.import)) {\n\t\t\tif (typeof method?.mockReset === \"function\") {\n\t\t\t\tmethod.mockReset();\n\t\t\t}\n\t\t}\n\n\t\t// Reset all bounce mocks\n\t\tfor (const method of Object.values(this.bounces)) {\n\t\t\tif (typeof method?.mockReset === \"function\") {\n\t\t\t\tmethod.mockReset();\n\t\t\t}\n\t\t}\n\n\t\t// Reset all settings mocks\n\t\tfor (const method of Object.values(this.settings)) {\n\t\t\tif (typeof method?.mockReset === \"function\") {\n\t\t\t\tmethod.mockReset();\n\t\t\t}\n\t\t}\n\n\t\t// Reset all dashboard mocks\n\t\tfor (const method of Object.values(this.dashboard)) {\n\t\t\tif (typeof method?.mockReset === \"function\") {\n\t\t\t\tmethod.mockReset();\n\t\t\t}\n\t\t}\n\n\t\t// Reset all admin mocks\n\t\tfor (const method of Object.values(this.admin)) {\n\t\t\tif (typeof method?.mockReset === \"function\") {\n\t\t\t\tmethod.mockReset();\n\t\t\t}\n\t\t}\n\n\t\t// Reset all maintenance mocks\n\t\tfor (const method of Object.values(this.maintenance)) {\n\t\t\tif (typeof method?.mockReset === \"function\") {\n\t\t\t\tmethod.mockReset();\n\t\t\t}\n\t\t}\n\n\t\t// Reset all public mocks\n\t\tfor (const method of Object.values(this.public)) {\n\t\t\tif (typeof method?.mockReset === \"function\") {\n\t\t\t\tmethod.mockReset();\n\t\t\t}\n\t\t}\n\n\t\t// Reset client-level mocks\n\t\tthis.health.mockReset();\n\t\tthis.publicHealth.mockReset();\n\t\tthis.getConfig.mockReset();\n\t}\n}\n",
|
|
21
|
+
"/**\n * Common factory utilities.\n *\n * @module testing/factories/common\n */\n\n/** Global counters for unique IDs */\nconst counters = {\n\tsubscriber: 0,\n\tlist: 0,\n\tcampaign: 0,\n\ttemplate: 0,\n\tmedia: 0,\n\tbounce: 0,\n};\n\n/**\n * Get next ID for a counter.\n */\nexport function nextId(key: keyof typeof counters): number {\n\treturn ++counters[key];\n}\n\n/**\n * Reset all factory counters to 0.\n *\n * Call this in beforeEach/afterEach hooks for predictable test IDs.\n *\n * @example\n * ```typescript\n * beforeEach(() => {\n * resetFactories();\n * });\n *\n * it('creates subscriber with id 1', () => {\n * const sub = createMockSubscriber();\n * expect(sub.id).toBe(1); // Always 1 after reset\n * });\n * ```\n */\nexport function resetFactories(): void {\n\tcounters.subscriber = 0;\n\tcounters.list = 0;\n\tcounters.campaign = 0;\n\tcounters.template = 0;\n\tcounters.media = 0;\n\tcounters.bounce = 0;\n}\n\n/**\n * Entity type codes for UUID generation (hex-compatible).\n * Maps entity type to a unique hex prefix for traceability.\n */\nconst ENTITY_HEX_CODES: Record<string, string> = {\n\tsub: \"00000001\", // subscriber\n\tlist: \"00000002\", // list\n\tcamp: \"00000003\", // campaign\n\ttmpl: \"00000004\", // template\n\tmed: \"00000005\", // media\n\tbnce: \"00000006\", // bounce\n};\n\n/**\n * Generate a valid RFC 4122 UUID v4 for testing.\n *\n * The UUID is deterministic based on the entity type and id, making tests predictable.\n * Format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\n * - 4 indicates version 4\n * - y is one of 8, 9, a, b (variant bits)\n *\n * @param entityType - Entity type prefix (sub, list, camp, tmpl, med, bnce)\n * @param id - Numeric ID to embed in the UUID\n * @returns A valid UUID v4 string that passes Zod validation\n */\nexport function mockUuid(entityType: string, id: number): string {\n\t// First segment (8 chars): entity type code\n\tconst segment1 = ENTITY_HEX_CODES[entityType] || \"00000000\";\n\t// Second segment (4 chars): id encoded\n\tconst segment2 = id.toString(16).padStart(4, \"0\");\n\t// Third segment (4 chars): version 4 UUID starts with 4\n\tconst segment3 = \"4000\";\n\t// Fourth segment (4 chars): variant bits (8, 9, a, or b as first char)\n\tconst segment4 = \"8000\";\n\t// Fifth segment (12 chars): id again for easy debugging\n\tconst segment5 = id.toString(16).padStart(12, \"0\");\n\n\treturn `${segment1}-${segment2}-${segment3}-${segment4}-${segment5}`;\n}\n\n/**\n * Get current ISO timestamp.\n */\nexport function nowISO(): string {\n\treturn new Date().toISOString();\n}\n",
|
|
22
|
+
"/**\n * Subscriber factory functions.\n *\n * @module testing/factories/subscriber\n */\n\nimport type { Subscriber } from \"../../resources/subscribers/types\";\nimport { nextId, mockUuid, nowISO } from \"./common\";\n\n/**\n * Creates a mock subscriber with realistic default values.\n *\n * @param overrides - Optional fields to override defaults\n * @returns A valid Subscriber object\n *\n * @example\n * ```typescript\n * // Default subscriber\n * const sub = createMockSubscriber();\n * // { id: 1, email: 'user1@example.com', name: 'Test User 1', ... }\n *\n * // With overrides\n * const custom = createMockSubscriber({\n * email: 'custom@mycompany.com',\n * status: 'disabled',\n * });\n * ```\n */\nexport function createMockSubscriber(\n\toverrides?: Partial<Subscriber>,\n): Subscriber {\n\tconst id = overrides?.id ?? nextId(\"subscriber\");\n\tconst now = nowISO();\n\n\treturn {\n\t\tid,\n\t\tuuid: mockUuid(\"sub\", id),\n\t\temail: `user${id}@example.com`,\n\t\tname: `Test User ${id}`,\n\t\tstatus: \"enabled\",\n\t\tattribs: {},\n\t\tlists: [],\n\t\tcreated_at: now,\n\t\tupdated_at: now,\n\t\t...overrides,\n\t};\n}\n\n/**\n * Creates multiple unique mock subscribers.\n *\n * @param count - Number of subscribers to create\n * @param overrides - Optional fields to apply to all subscribers\n * @returns Array of unique Subscriber objects\n *\n * @example\n * ```typescript\n * const subs = createMockSubscribers(5);\n * // 5 subscribers with unique IDs and emails\n *\n * const blocklisted = createMockSubscribers(3, { status: 'blocklisted' });\n * // 3 blocklisted subscribers\n * ```\n */\nexport function createMockSubscribers(\n\tcount: number,\n\toverrides?: Partial<Omit<Subscriber, \"id\" | \"uuid\" | \"email\">>,\n): Subscriber[] {\n\treturn Array.from({ length: count }, () => createMockSubscriber(overrides));\n}\n",
|
|
23
|
+
"/**\n * List factory functions.\n *\n * @module testing/factories/list\n */\n\nimport type { List } from \"../../resources/lists/types\";\nimport { nextId, mockUuid, nowISO } from \"./common\";\n\n/**\n * Creates a mock list with realistic default values.\n *\n * @param overrides - Optional fields to override defaults\n * @returns A valid List object\n *\n * @example\n * ```typescript\n * // Default list\n * const list = createMockList();\n * // { id: 1, name: 'Test List 1', type: 'public', ... }\n *\n * // With overrides\n * const custom = createMockList({\n * name: 'Newsletter',\n * type: 'private',\n * });\n * ```\n */\nexport function createMockList(overrides?: Partial<List>): List {\n\tconst id = overrides?.id ?? nextId(\"list\");\n\tconst now = nowISO();\n\n\treturn {\n\t\tid,\n\t\tuuid: mockUuid(\"list\", id),\n\t\tname: `Test List ${id}`,\n\t\ttype: \"public\",\n\t\toptin: \"single\",\n\t\tstatus: \"active\",\n\t\ttags: [],\n\t\tdescription: \"\",\n\t\tsubscriber_count: 0,\n\t\tcreated_at: now,\n\t\tupdated_at: now,\n\t\t...overrides,\n\t};\n}\n\n/**\n * Creates multiple unique mock lists.\n *\n * @param count - Number of lists to create\n * @param overrides - Optional fields to apply to all lists\n * @returns Array of unique List objects\n *\n * @example\n * ```typescript\n * const lists = createMockLists(3);\n * // 3 lists with unique IDs and names\n *\n * const privateLists = createMockLists(2, { type: 'private' });\n * // 2 private lists\n * ```\n */\nexport function createMockLists(\n\tcount: number,\n\toverrides?: Partial<Omit<List, \"id\" | \"uuid\" | \"name\">>,\n): List[] {\n\treturn Array.from({ length: count }, () => createMockList(overrides));\n}\n",
|
|
24
|
+
"/**\n * Campaign factory functions.\n *\n * @module testing/factories/campaign\n */\n\nimport type { Campaign } from \"../../resources/campaigns/types\";\nimport { nextId, mockUuid, nowISO } from \"./common\";\n\n/**\n * Creates a mock campaign with realistic default values.\n *\n * @param overrides - Optional fields to override defaults\n * @returns A valid Campaign object\n *\n * @example\n * ```typescript\n * // Default campaign\n * const campaign = createMockCampaign();\n * // { id: 1, name: 'Test Campaign 1', status: 'draft', ... }\n *\n * // With overrides\n * const custom = createMockCampaign({\n * name: 'Weekly Newsletter',\n * status: 'running',\n * });\n * ```\n */\nexport function createMockCampaign(overrides?: Partial<Campaign>): Campaign {\n\tconst id = overrides?.id ?? nextId(\"campaign\");\n\tconst now = nowISO();\n\n\treturn {\n\t\tid,\n\t\tuuid: mockUuid(\"camp\", id),\n\t\tname: `Test Campaign ${id}`,\n\t\tsubject: `Test Subject ${id}`,\n\t\tfrom_email: \"test@example.com\",\n\t\tstatus: \"draft\",\n\t\ttype: \"regular\",\n\t\tcontent_type: \"html\",\n\t\tbody: \"<p>Test campaign content</p>\",\n\t\taltbody: null,\n\t\ttemplate_id: 1,\n\t\tmessenger: \"email\",\n\t\tlists: [],\n\t\theaders: [],\n\t\ttags: [],\n\t\tsend_at: null,\n\t\tstarted_at: null,\n\t\tto_send: 0,\n\t\tsent: 0,\n\t\tarchive: false,\n\t\tarchive_slug: null,\n\t\tarchive_template_id: null,\n\t\tarchive_meta: {},\n\t\tviews: 0,\n\t\tclicks: 0,\n\t\tbounces: 0,\n\t\tcreated_at: now,\n\t\tupdated_at: now,\n\t\t...overrides,\n\t};\n}\n\n/**\n * Creates multiple unique mock campaigns.\n *\n * @param count - Number of campaigns to create\n * @param overrides - Optional fields to apply to all campaigns\n * @returns Array of unique Campaign objects\n *\n * @example\n * ```typescript\n * const campaigns = createMockCampaigns(3);\n * // 3 campaigns with unique IDs and names\n *\n * const drafts = createMockCampaigns(2, { status: 'draft' });\n * // 2 draft campaigns\n * ```\n */\nexport function createMockCampaigns(\n\tcount: number,\n\toverrides?: Partial<Omit<Campaign, \"id\" | \"uuid\" | \"name\">>,\n): Campaign[] {\n\treturn Array.from({ length: count }, () => createMockCampaign(overrides));\n}\n",
|
|
25
|
+
"/**\n * Template factory functions.\n *\n * @module testing/factories/template\n */\n\nimport type { Template } from \"../../resources/templates/types\";\nimport { nextId, nowISO } from \"./common\";\n\n/**\n * Creates a mock template with realistic default values.\n *\n * @param overrides - Optional fields to override defaults\n * @returns A valid Template object\n *\n * @example\n * ```typescript\n * // Default template\n * const template = createMockTemplate();\n * // { id: 1, name: 'Test Template 1', type: 'campaign', ... }\n *\n * // With overrides\n * const custom = createMockTemplate({\n * name: 'Welcome Email',\n * is_default: true,\n * });\n * ```\n */\nexport function createMockTemplate(overrides?: Partial<Template>): Template {\n\tconst id = overrides?.id ?? nextId(\"template\");\n\tconst now = nowISO();\n\n\treturn {\n\t\tid,\n\t\tname: `Test Template ${id}`,\n\t\ttype: \"campaign\",\n\t\tsubject: null,\n\t\tbody: '<html><body>{{ template \"content\" . }}</body></html>',\n\t\tis_default: false,\n\t\tcreated_at: now,\n\t\tupdated_at: now,\n\t\t...overrides,\n\t};\n}\n\n/**\n * Creates multiple unique mock templates.\n *\n * @param count - Number of templates to create\n * @param overrides - Optional fields to apply to all templates\n * @returns Array of unique Template objects\n *\n * @example\n * ```typescript\n * const templates = createMockTemplates(3);\n * // 3 templates with unique IDs and names\n * ```\n */\nexport function createMockTemplates(\n\tcount: number,\n\toverrides?: Partial<Omit<Template, \"id\" | \"name\">>,\n): Template[] {\n\treturn Array.from({ length: count }, () => createMockTemplate(overrides));\n}\n",
|
|
26
|
+
"/**\n * Media factory functions.\n *\n * @module testing/factories/media\n */\n\nimport type { Media } from \"../../resources/media/types\";\nimport { nextId, mockUuid, nowISO } from \"./common\";\n\n/**\n * Creates a mock media item with realistic default values.\n *\n * @param overrides - Optional fields to override defaults\n * @returns A valid Media object\n *\n * @example\n * ```typescript\n * // Default media\n * const media = createMockMedia();\n * // { id: 1, filename: 'image1.jpg', content_type: 'image/jpeg', ... }\n *\n * // With overrides\n * const custom = createMockMedia({\n * filename: 'logo.png',\n * content_type: 'image/png',\n * });\n * ```\n */\nexport function createMockMedia(overrides?: Partial<Media>): Media {\n\tconst id = overrides?.id ?? nextId(\"media\");\n\tconst now = nowISO();\n\n\treturn {\n\t\tid,\n\t\tuuid: mockUuid(\"med\", id),\n\t\tfilename: `image${id}.jpg`,\n\t\tcontent_type: \"image/jpeg\",\n\t\turl: `/uploads/image${id}.jpg`,\n\t\tthumb_url: `/uploads/thumb_image${id}.jpg`,\n\t\tprovider: \"filesystem\",\n\t\tmeta: {},\n\t\tcreated_at: now,\n\t\t...overrides,\n\t};\n}\n\n/**\n * Creates multiple unique mock media items.\n *\n * @param count - Number of media items to create\n * @param overrides - Optional fields to apply to all media items\n * @returns Array of unique Media objects\n *\n * @example\n * ```typescript\n * const media = createMockMediaItems(5);\n * // 5 media items with unique IDs and filenames\n * ```\n */\nexport function createMockMediaItems(\n\tcount: number,\n\toverrides?: Partial<Omit<Media, \"id\" | \"uuid\" | \"filename\">>,\n): Media[] {\n\treturn Array.from({ length: count }, () => createMockMedia(overrides));\n}\n",
|
|
27
|
+
"/**\n * Bounce factory functions.\n *\n * @module testing/factories/bounce\n */\n\nimport type { Bounce } from \"../../resources/bounces/types\";\nimport { nextId, mockUuid, nowISO } from \"./common\";\n\n/**\n * Creates a mock bounce record with realistic default values.\n *\n * @param overrides - Optional fields to override defaults\n * @returns A valid Bounce object\n *\n * @example\n * ```typescript\n * // Default bounce\n * const bounce = createMockBounce();\n * // { id: 1, email: 'bounce1@example.com', type: 'hard', ... }\n *\n * // With overrides\n * const custom = createMockBounce({\n * type: 'soft',\n * source: 'mailgun',\n * });\n * ```\n */\nexport function createMockBounce(overrides?: Partial<Bounce>): Bounce {\n\tconst id = overrides?.id ?? nextId(\"bounce\");\n\tconst now = nowISO();\n\n\treturn {\n\t\tid,\n\t\temail: `bounce${id}@example.com`,\n\t\tsubscriber_uuid: mockUuid(\"sub\", id),\n\t\tsubscriber_id: id,\n\t\tcampaign: null,\n\t\ttype: \"hard\",\n\t\tsource: \"smtp\",\n\t\tmeta: {},\n\t\tcreated_at: now,\n\t\t...overrides,\n\t};\n}\n\n/**\n * Creates multiple unique mock bounce records.\n *\n * @param count - Number of bounces to create\n * @param overrides - Optional fields to apply to all bounces\n * @returns Array of unique Bounce objects\n *\n * @example\n * ```typescript\n * const bounces = createMockBounces(3);\n * // 3 bounce records with unique IDs and emails\n *\n * const softBounces = createMockBounces(2, { type: 'soft' });\n * // 2 soft bounces\n * ```\n */\nexport function createMockBounces(\n\tcount: number,\n\toverrides?: Partial<Omit<Bounce, \"id\" | \"email\">>,\n): Bounce[] {\n\treturn Array.from({ length: count }, () => createMockBounce(overrides));\n}\n"
|
|
28
|
+
],
|
|
29
|
+
"mappings": ";;;AAaO,MAAM,+BAA+B,MAAM;AAAA,EAC/B,OAAO;AAAA,EAKhB;AAAA,EAKA;AAAA,EAET,WAAW,CAAC,cAAsB,YAAoB;AAAA,IACrD,MAAM,WAAW,GAAG,gBAAgB;AAAA,IACpC,MACC,gBAAgB;AAAA,IACf,8BAA8B,iCAChC;AAAA,IACA,KAAK,eAAe;AAAA,IACpB,KAAK,aAAa;AAAA;AAEpB;;;ACLO,SAAS,kBAAoD,CACnE,cACA,YAC+B;AAAA,EAC/B,IAAI;AAAA,EACJ,IAAI,eAAe;AAAA,EAEnB,MAAM,QAA4C;AAAA,IACjD,OAAO,CAAC;AAAA,IACR,SAAS,CAAC;AAAA,IACV,UAAU;AAAA,IACV,WAAW;AAAA,EACZ;AAAA,EAEA,MAAM,SAAU,IAAI,SAAyB;AAAA,IAC5C,MAAM,MAAM,KAAK,IAAI;AAAA,IACrB,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;AAAA;;AClClE,SAAS,eAAe,CAAC,WAAmC;AAAA,EAClE,MAAM,KAAK,WAAW,MAAM,OAAO,OAAO;AAAA,EAC1C,MAAM,MAAM,OAAO;AAAA,EAEnB,OAAO;AAAA,IACN;AAAA,IACA,MAAM,SAAS,OAAO,EAAE;AAAA,IACxB,UAAU,QAAQ;AAAA,IAClB,cAAc;AAAA,IACd,KAAK,iBAAiB;AAAA,IACtB,WAAW,uBAAuB;AAAA,IAClC,UAAU;AAAA,IACV,MAAM,CAAC;AAAA,IACP,YAAY;AAAA,OACT;AAAA,EACJ;AAAA;AAgBM,SAAS,oBAAoB,CACnC,OACA,WACU;AAAA,EACV,OAAO,MAAM,KAAK,EAAE,QAAQ,MAAM,GAAG,MAAM,gBAAgB,SAAS,CAAC;AAAA;;ACnC/D,SAAS,gBAAgB,CAAC,WAAqC;AAAA,EACrE,MAAM,KAAK,WAAW,MAAM,OAAO,QAAQ;AAAA,EAC3C,MAAM,MAAM,OAAO;AAAA,EAEnB,OAAO;AAAA,IACN;AAAA,IACA,OAAO,SAAS;AAAA,IAChB,iBAAiB,SAAS,OAAO,EAAE;AAAA,IACnC,eAAe;AAAA,IACf,UAAU;AAAA,IACV,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,MAAM,CAAC;AAAA,IACP,YAAY;AAAA,OACT;AAAA,EACJ;AAAA;AAmBM,SAAS,iBAAiB,CAChC,OACA,WACW;AAAA,EACX,OAAO,MAAM,KAAK,EAAE,QAAQ,MAAM,GAAG,MAAM,iBAAiB,SAAS,CAAC;AAAA;",
|
|
30
|
+
"debugId": "367CDA81B275C35364756E2164756E21",
|
|
31
|
+
"names": []
|
|
32
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MockListmonkClient for testing.
|
|
3
|
+
*
|
|
4
|
+
* @module testing/mock-client
|
|
5
|
+
*/
|
|
6
|
+
import type { MockFunction } from "./types";
|
|
7
|
+
import { type MockSubscribersResource, type MockListsResource, type MockCampaignsResource, type MockTemplatesResource, type MockTransactionalResource, type MockMediaResource, type MockImportResource, type MockBouncesResource, type MockSettingsResource, type MockDashboardResource, type MockAdminResource, type MockMaintenanceResource, type MockPublicResource } from "./resources";
|
|
8
|
+
/**
|
|
9
|
+
* Mock Listmonk client for testing.
|
|
10
|
+
*
|
|
11
|
+
* Mirrors the real Listmonk client interface with all methods replaced
|
|
12
|
+
* by configurable MockFunctions. Use this for unit testing application
|
|
13
|
+
* code that depends on the Listmonk SDK without making real API calls.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { MockListmonkClient, createMockSubscriber } from '@solytude/listmonk/testing';
|
|
18
|
+
*
|
|
19
|
+
* describe('MyApp', () => {
|
|
20
|
+
* let mockClient: MockListmonkClient;
|
|
21
|
+
*
|
|
22
|
+
* beforeEach(() => {
|
|
23
|
+
* mockClient = new MockListmonkClient();
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* afterEach(() => {
|
|
27
|
+
* mockClient.reset();
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* it('fetches subscribers', async () => {
|
|
31
|
+
* const mockSub = { id: 1, email: 'test@example.com' };
|
|
32
|
+
* mockClient.subscribers.retrieve.mockResolvedValue(mockSub);
|
|
33
|
+
*
|
|
34
|
+
* const result = await myApp.getSubscriber(1);
|
|
35
|
+
*
|
|
36
|
+
* expect(mockClient.subscribers.retrieve.mock.callCount).toBe(1);
|
|
37
|
+
* expect(result.email).toBe('test@example.com');
|
|
38
|
+
* });
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare class MockListmonkClient {
|
|
43
|
+
/**
|
|
44
|
+
* Mocked subscribers resource.
|
|
45
|
+
*/
|
|
46
|
+
readonly subscribers: MockSubscribersResource;
|
|
47
|
+
/**
|
|
48
|
+
* Mocked lists resource.
|
|
49
|
+
*/
|
|
50
|
+
readonly lists: MockListsResource;
|
|
51
|
+
/**
|
|
52
|
+
* Mocked campaigns resource.
|
|
53
|
+
*/
|
|
54
|
+
readonly campaigns: MockCampaignsResource;
|
|
55
|
+
/**
|
|
56
|
+
* Mocked templates resource.
|
|
57
|
+
*/
|
|
58
|
+
readonly templates: MockTemplatesResource;
|
|
59
|
+
/**
|
|
60
|
+
* Mocked transactional resource.
|
|
61
|
+
*/
|
|
62
|
+
readonly tx: MockTransactionalResource;
|
|
63
|
+
/**
|
|
64
|
+
* Mocked media resource.
|
|
65
|
+
*/
|
|
66
|
+
readonly media: MockMediaResource;
|
|
67
|
+
/**
|
|
68
|
+
* Mocked import resource.
|
|
69
|
+
*/
|
|
70
|
+
readonly import: MockImportResource;
|
|
71
|
+
/**
|
|
72
|
+
* Mocked bounces resource.
|
|
73
|
+
*/
|
|
74
|
+
readonly bounces: MockBouncesResource;
|
|
75
|
+
/**
|
|
76
|
+
* Mocked settings resource.
|
|
77
|
+
*/
|
|
78
|
+
readonly settings: MockSettingsResource;
|
|
79
|
+
/**
|
|
80
|
+
* Mocked dashboard resource.
|
|
81
|
+
*/
|
|
82
|
+
readonly dashboard: MockDashboardResource;
|
|
83
|
+
/**
|
|
84
|
+
* Mocked admin resource.
|
|
85
|
+
*/
|
|
86
|
+
readonly admin: MockAdminResource;
|
|
87
|
+
/**
|
|
88
|
+
* Mocked maintenance resource.
|
|
89
|
+
*/
|
|
90
|
+
readonly maintenance: MockMaintenanceResource;
|
|
91
|
+
/**
|
|
92
|
+
* Mocked public resource.
|
|
93
|
+
*/
|
|
94
|
+
readonly public: MockPublicResource;
|
|
95
|
+
/**
|
|
96
|
+
* Mocked health check method.
|
|
97
|
+
*/
|
|
98
|
+
readonly health: MockFunction<[], Promise<unknown>>;
|
|
99
|
+
/**
|
|
100
|
+
* Mocked public health check method.
|
|
101
|
+
*/
|
|
102
|
+
readonly publicHealth: MockFunction<[], Promise<unknown>>;
|
|
103
|
+
/**
|
|
104
|
+
* Mocked config retrieval method.
|
|
105
|
+
*/
|
|
106
|
+
readonly getConfig: MockFunction<[], Promise<unknown>>;
|
|
107
|
+
/**
|
|
108
|
+
* Creates a new MockListmonkClient.
|
|
109
|
+
*
|
|
110
|
+
* Unlike the real Listmonk client, the mock client requires no configuration.
|
|
111
|
+
*/
|
|
112
|
+
constructor();
|
|
113
|
+
/**
|
|
114
|
+
* Reset all mock configurations and call history.
|
|
115
|
+
*
|
|
116
|
+
* Should be called in afterEach() hooks to ensure test isolation.
|
|
117
|
+
*/
|
|
118
|
+
reset(): void;
|
|
119
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock function implementation for test-runner-agnostic testing.
|
|
3
|
+
*
|
|
4
|
+
* @module testing/mock-function
|
|
5
|
+
*/
|
|
6
|
+
import type { MockFunction } from "./types";
|
|
7
|
+
/**
|
|
8
|
+
* Creates a mock function with call tracking and configurable return values.
|
|
9
|
+
*
|
|
10
|
+
* @param resourceName - The resource name for error messages (e.g., 'subscribers')
|
|
11
|
+
* @param methodName - The method name for error messages (e.g., 'get')
|
|
12
|
+
* @returns A mock function that can be configured and tracked
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const mockGet = createMockFunction<[number], Promise<Subscriber>>(
|
|
17
|
+
* 'subscribers',
|
|
18
|
+
* 'get'
|
|
19
|
+
* );
|
|
20
|
+
*
|
|
21
|
+
* mockGet.mockResolvedValue({ id: 1, email: 'test@example.com' });
|
|
22
|
+
*
|
|
23
|
+
* const result = await mockGet(1);
|
|
24
|
+
* console.log(mockGet.mock.callCount); // 1
|
|
25
|
+
* console.log(mockGet.mock.calls[0]); // [1]
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function createMockFunction<TArgs extends unknown[], TReturn>(resourceName: string, methodName: string): MockFunction<TArgs, TReturn>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock admin resource.
|
|
3
|
+
*
|
|
4
|
+
* @module testing/resources/admin
|
|
5
|
+
*/
|
|
6
|
+
import type { MockFunction } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Mock admin resource with all methods as mock functions.
|
|
9
|
+
*/
|
|
10
|
+
export interface MockAdminResource {
|
|
11
|
+
reload: MockFunction<[], Promise<unknown>>;
|
|
12
|
+
getLogs: MockFunction<[], Promise<unknown>>;
|
|
13
|
+
getEventStream: MockFunction<[
|
|
14
|
+
unknown?
|
|
15
|
+
], AsyncGenerator<unknown, void, undefined>>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a mock admin resource.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createMockAdminResource(): MockAdminResource;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock bounces resource.
|
|
3
|
+
*
|
|
4
|
+
* @module testing/resources/bounces
|
|
5
|
+
*/
|
|
6
|
+
import type { MockFunction } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Mock bounces resource with all methods as mock functions.
|
|
9
|
+
*/
|
|
10
|
+
export interface MockBouncesResource {
|
|
11
|
+
list: MockFunction<[unknown?], Promise<unknown>>;
|
|
12
|
+
listAll: MockFunction<[unknown?], AsyncIterableIterator<unknown>>;
|
|
13
|
+
remove: MockFunction<[number], Promise<boolean>>;
|
|
14
|
+
deleteMany: MockFunction<[number[]], Promise<boolean>>;
|
|
15
|
+
deleteAll: MockFunction<[], Promise<boolean>>;
|
|
16
|
+
retrieve: MockFunction<[number], Promise<unknown>>;
|
|
17
|
+
blocklistBounced: MockFunction<[], Promise<boolean>>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a mock bounces resource.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createMockBouncesResource(): MockBouncesResource;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock campaigns resource.
|
|
3
|
+
*
|
|
4
|
+
* @module testing/resources/campaigns
|
|
5
|
+
*/
|
|
6
|
+
import type { MockFunction } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Mock campaigns resource with all methods as mock functions.
|
|
9
|
+
*/
|
|
10
|
+
export interface MockCampaignsResource {
|
|
11
|
+
create: MockFunction<[unknown], Promise<unknown>>;
|
|
12
|
+
retrieve: MockFunction<[number, unknown?], Promise<unknown>>;
|
|
13
|
+
update: MockFunction<[number, unknown], Promise<unknown>>;
|
|
14
|
+
remove: MockFunction<[number], Promise<void>>;
|
|
15
|
+
list: MockFunction<[unknown?], Promise<unknown>>;
|
|
16
|
+
listAll: MockFunction<[unknown?], AsyncIterableIterator<unknown>>;
|
|
17
|
+
updateStatus: MockFunction<[number, string, unknown?], Promise<unknown>>;
|
|
18
|
+
preview: MockFunction<[number, unknown?], Promise<unknown>>;
|
|
19
|
+
previewText: MockFunction<[number], Promise<unknown>>;
|
|
20
|
+
getRunningStats: MockFunction<[number[]], Promise<unknown[]>>;
|
|
21
|
+
getAnalytics: MockFunction<[string, unknown?], Promise<unknown[]>>;
|
|
22
|
+
sendTest: MockFunction<[number, unknown], Promise<void>>;
|
|
23
|
+
archive: MockFunction<[number, boolean?, unknown?], Promise<unknown>>;
|
|
24
|
+
convertContent: MockFunction<[number, string], Promise<unknown>>;
|
|
25
|
+
deleteMany: MockFunction<[number[]], Promise<void>>;
|
|
26
|
+
deleteByQuery: MockFunction<[string], Promise<void>>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a mock campaigns resource.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createMockCampaignsResource(): MockCampaignsResource;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock dashboard resource.
|
|
3
|
+
*
|
|
4
|
+
* @module testing/resources/dashboard
|
|
5
|
+
*/
|
|
6
|
+
import type { MockFunction } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Mock dashboard resource with all methods as mock functions.
|
|
9
|
+
*/
|
|
10
|
+
export interface MockDashboardResource {
|
|
11
|
+
getCounts: MockFunction<[], Promise<unknown>>;
|
|
12
|
+
getCharts: MockFunction<[], Promise<unknown>>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates a mock dashboard resource.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createMockDashboardResource(): MockDashboardResource;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock import resource.
|
|
3
|
+
*
|
|
4
|
+
* @module testing/resources/import
|
|
5
|
+
*/
|
|
6
|
+
import type { MockFunction } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Mock import resource with all methods as mock functions.
|
|
9
|
+
*/
|
|
10
|
+
export interface MockImportResource {
|
|
11
|
+
start: MockFunction<[unknown, unknown], Promise<unknown>>;
|
|
12
|
+
getStatus: MockFunction<[], Promise<unknown>>;
|
|
13
|
+
getLogs: MockFunction<[], Promise<string[]>>;
|
|
14
|
+
cancel: MockFunction<[], Promise<boolean>>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates a mock import resource.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createMockImportResource(): MockImportResource;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock resources index.
|
|
3
|
+
*
|
|
4
|
+
* @module testing/resources
|
|
5
|
+
*/
|
|
6
|
+
export { type MockSubscribersResource, createMockSubscribersResource, } from "./subscribers";
|
|
7
|
+
export { type MockListsResource, createMockListsResource } from "./lists";
|
|
8
|
+
export { type MockCampaignsResource, createMockCampaignsResource, } from "./campaigns";
|
|
9
|
+
export { type MockTemplatesResource, createMockTemplatesResource, } from "./templates";
|
|
10
|
+
export { type MockTransactionalResource, createMockTransactionalResource, } from "./tx";
|
|
11
|
+
export { type MockMediaResource, createMockMediaResource } from "./media";
|
|
12
|
+
export { type MockImportResource, createMockImportResource } from "./import";
|
|
13
|
+
export { type MockBouncesResource, createMockBouncesResource } from "./bounces";
|
|
14
|
+
export { type MockSettingsResource, createMockSettingsResource, } from "./settings";
|
|
15
|
+
export { type MockDashboardResource, createMockDashboardResource, } from "./dashboard";
|
|
16
|
+
export { type MockAdminResource, createMockAdminResource } from "./admin";
|
|
17
|
+
export { type MockMaintenanceResource, createMockMaintenanceResource, } from "./maintenance";
|
|
18
|
+
export { type MockPublicResource, createMockPublicResource } from "./public";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock lists resource.
|
|
3
|
+
*
|
|
4
|
+
* @module testing/resources/lists
|
|
5
|
+
*/
|
|
6
|
+
import type { MockFunction } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Mock lists resource with all methods as mock functions.
|
|
9
|
+
*/
|
|
10
|
+
export interface MockListsResource {
|
|
11
|
+
create: MockFunction<[unknown], Promise<unknown>>;
|
|
12
|
+
retrieve: MockFunction<[number], Promise<unknown>>;
|
|
13
|
+
update: MockFunction<[number, unknown], Promise<unknown>>;
|
|
14
|
+
remove: MockFunction<[number], Promise<void>>;
|
|
15
|
+
list: MockFunction<[unknown?], Promise<unknown>>;
|
|
16
|
+
listAll: MockFunction<[unknown?], AsyncIterableIterator<unknown>>;
|
|
17
|
+
deleteMany: MockFunction<[number[]], Promise<void>>;
|
|
18
|
+
deleteByQuery: MockFunction<[string], Promise<void>>;
|
|
19
|
+
getPublic: MockFunction<[], Promise<unknown[]>>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a mock lists resource.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createMockListsResource(): MockListsResource;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock maintenance resource.
|
|
3
|
+
*
|
|
4
|
+
* @module testing/resources/maintenance
|
|
5
|
+
*/
|
|
6
|
+
import type { MockFunction } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Mock maintenance resource with all methods as mock functions.
|
|
9
|
+
*/
|
|
10
|
+
export interface MockMaintenanceResource {
|
|
11
|
+
gcSubscribers: MockFunction<[string], Promise<unknown>>;
|
|
12
|
+
gcSubscriptions: MockFunction<[string], Promise<unknown>>;
|
|
13
|
+
gcAnalytics: MockFunction<[string, string], Promise<unknown>>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a mock maintenance resource.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createMockMaintenanceResource(): MockMaintenanceResource;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock media resource.
|
|
3
|
+
*
|
|
4
|
+
* @module testing/resources/media
|
|
5
|
+
*/
|
|
6
|
+
import type { MockFunction } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Mock media resource with all methods as mock functions.
|
|
9
|
+
*/
|
|
10
|
+
export interface MockMediaResource {
|
|
11
|
+
upload: MockFunction<[unknown], Promise<unknown>>;
|
|
12
|
+
list: MockFunction<[], Promise<unknown[]>>;
|
|
13
|
+
listAll: MockFunction<[], AsyncIterableIterator<unknown>>;
|
|
14
|
+
retrieve: MockFunction<[number], Promise<unknown>>;
|
|
15
|
+
remove: MockFunction<[number], Promise<boolean>>;
|
|
16
|
+
deleteMany: MockFunction<[number[]], Promise<void>>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates a mock media resource.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createMockMediaResource(): MockMediaResource;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock public resource.
|
|
3
|
+
*
|
|
4
|
+
* @module testing/resources/public
|
|
5
|
+
*/
|
|
6
|
+
import type { MockFunction } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Mock public resource with all methods as mock functions.
|
|
9
|
+
*/
|
|
10
|
+
export interface MockPublicResource {
|
|
11
|
+
getLists: MockFunction<[], Promise<unknown[]>>;
|
|
12
|
+
subscribe: MockFunction<[unknown], Promise<unknown>>;
|
|
13
|
+
getCaptchaChallenge: MockFunction<[], Promise<unknown>>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a mock public resource.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createMockPublicResource(): MockPublicResource;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock settings resource.
|
|
3
|
+
*
|
|
4
|
+
* @module testing/resources/settings
|
|
5
|
+
*/
|
|
6
|
+
import type { MockFunction } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Mock settings resource with all methods as mock functions.
|
|
9
|
+
*/
|
|
10
|
+
export interface MockSettingsResource {
|
|
11
|
+
getAll: MockFunction<[], Promise<unknown>>;
|
|
12
|
+
update: MockFunction<[unknown], Promise<unknown>>;
|
|
13
|
+
updateByKey: MockFunction<[string, unknown], Promise<true>>;
|
|
14
|
+
testSmtp: MockFunction<[unknown], Promise<unknown>>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates a mock settings resource.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createMockSettingsResource(): MockSettingsResource;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock subscribers resource.
|
|
3
|
+
*
|
|
4
|
+
* @module testing/resources/subscribers
|
|
5
|
+
*/
|
|
6
|
+
import type { MockFunction } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Mock subscribers resource with all methods as mock functions.
|
|
9
|
+
*/
|
|
10
|
+
export interface MockSubscribersResource {
|
|
11
|
+
create: MockFunction<[unknown], Promise<unknown>>;
|
|
12
|
+
retrieve: MockFunction<[number], Promise<unknown>>;
|
|
13
|
+
update: MockFunction<[number, unknown], Promise<unknown>>;
|
|
14
|
+
remove: MockFunction<[number], Promise<void>>;
|
|
15
|
+
list: MockFunction<[unknown?], Promise<unknown>>;
|
|
16
|
+
listAll: MockFunction<[unknown?], AsyncIterableIterator<unknown>>;
|
|
17
|
+
modifyLists: MockFunction<[unknown], Promise<void>>;
|
|
18
|
+
modifyListsForList: MockFunction<[number, unknown], Promise<void>>;
|
|
19
|
+
blocklist: MockFunction<[number], Promise<void>>;
|
|
20
|
+
blocklistMany: MockFunction<[number[]], Promise<void>>;
|
|
21
|
+
blocklistByQuery: MockFunction<[string], Promise<void>>;
|
|
22
|
+
deleteMany: MockFunction<[number[]], Promise<void>>;
|
|
23
|
+
deleteByQuery: MockFunction<[string], Promise<void>>;
|
|
24
|
+
getBounces: MockFunction<[number], Promise<unknown[]>>;
|
|
25
|
+
deleteBounces: MockFunction<[number], Promise<void>>;
|
|
26
|
+
export: MockFunction<[number], Promise<unknown>>;
|
|
27
|
+
sendOptin: MockFunction<[number], Promise<void>>;
|
|
28
|
+
modifyListsByQuery: MockFunction<[unknown], Promise<void>>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a mock subscribers resource.
|
|
32
|
+
*/
|
|
33
|
+
export declare function createMockSubscribersResource(): MockSubscribersResource;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock templates resource.
|
|
3
|
+
*
|
|
4
|
+
* @module testing/resources/templates
|
|
5
|
+
*/
|
|
6
|
+
import type { MockFunction } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Mock templates resource with all methods as mock functions.
|
|
9
|
+
*/
|
|
10
|
+
export interface MockTemplatesResource {
|
|
11
|
+
create: MockFunction<[unknown], Promise<unknown>>;
|
|
12
|
+
retrieve: MockFunction<[number], Promise<unknown>>;
|
|
13
|
+
update: MockFunction<[number, unknown], Promise<unknown>>;
|
|
14
|
+
remove: MockFunction<[number], Promise<void>>;
|
|
15
|
+
list: MockFunction<[unknown?], Promise<unknown[]>>;
|
|
16
|
+
listAll: MockFunction<[unknown?], AsyncIterableIterator<unknown>>;
|
|
17
|
+
preview: MockFunction<[number | null, unknown?], Promise<unknown>>;
|
|
18
|
+
setDefault: MockFunction<[number], Promise<unknown>>;
|
|
19
|
+
deleteMany: MockFunction<[number[]], Promise<void>>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a mock templates resource.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createMockTemplatesResource(): MockTemplatesResource;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock transactional resource.
|
|
3
|
+
*
|
|
4
|
+
* @module testing/resources/tx
|
|
5
|
+
*/
|
|
6
|
+
import type { MockFunction } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Mock transactional resource with all methods as mock functions.
|
|
9
|
+
*/
|
|
10
|
+
export interface MockTransactionalResource {
|
|
11
|
+
send: MockFunction<[unknown], Promise<boolean>>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a mock transactional resource.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createMockTransactionalResource(): MockTransactionalResource;
|