@ebertjendustries/cstestwrapper 1.0.19 → 1.0.21

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/dist/index.d.mts CHANGED
@@ -547,43 +547,10 @@ declare class MockRestClient implements _ebertjendustries_cswrapper.IRestClient
547
547
  private mockImpl;
548
548
  }
549
549
 
550
- declare class MockServerBuilder {
551
- private port;
552
- private mockData;
553
- private redirectUrls;
554
- private server;
555
- private jsonServer;
556
- constructor(port: number, requireFunc: Function);
557
- addToMockData(key: string, data: any): void;
558
- /**
559
- * Puts mock data: Adds it to internal data structures and prepares it for mocking. It potentially updates
560
- * the overall mock data object later passed into jsonServer router as well as the rewrite object later
561
- * passed into jsonServer.rewriter.
562
- *
563
- * @param key The key of the data
564
- * @param data The data itself
565
- * @param urlRedirects The redirect URLs to be rewritten to the key url
566
- * @param crud Whether this is a crud redirect
567
- * @returns The loaded mock data object
568
- */
569
- putMockData(key: string, data: any, urlRedirects: string[], crud?: boolean): void;
570
- addToRedirects(key: string, urlRedirects: string[], crud: boolean): void;
571
- rewritePostToGet(url: string): void;
572
- static set200WithData(res: any, data: any): void;
573
- static respondWithError(res: any, componentId: string, messageId: string, httpStatus: number, op: string, message: string): void;
574
- mockCall(url: string, callProcessor: (req: any, res: any, next: Function) => void): void;
575
- mockCRUDMulti(urls: string[], allElements: any, finder: (id: number) => any, operationDesc: string): void;
576
- mockCRUD(url: string, allElements: any, finder: (id: number) => any, operationDesc: string): void;
577
- start(): void;
578
- private useCors;
579
- private static allowCors;
580
- private static postRewriteToGet;
581
- }
582
-
583
550
  declare class ViewTestWrapperProps<T> {
584
551
  initialValue: T;
585
552
  view: (value: T, onChange: PropertyChangeFunction) => React.ReactNode;
586
553
  }
587
554
  declare function ViewTestWrapper<T>(props: ViewTestWrapperProps<T>): react_jsx_runtime.JSX.Element;
588
555
 
589
- export { AbstractComponentTesting, AbstractInputTesting, AbstractSelectTesting, AbstractViewTesting, AlertTesting, BoxTesting, ButtonDropdownTesting, ButtonTesting, CSVNoItemsViewTesting, CSVPriceInputViewTesting, CSVSearchFilterViewTesting, CSVTextPromptModalViewTesting, CardsTesting, CheckboxTesting, CollectionPreferencesSetting, CollectionPreferencesTesting, CopyToClipboardTesting, DatePickerTesting, FlashbarTesting, FormTesting, HeaderTesting, IconTesting, LinkTesting, MockBrowserAPIs, MockRestClient, MockServerBuilder, ModalTesting, MultiselectTesting, NumberInputTesting, PaginationTesting, ProgressBarTesting, RatingTesting, SegmentedControlTesting, SelectTesting, StatusIndicatorTesting, StringInputTesting, TableTesting, TabsTesting, TestLocalisation, TestingFactory, TextContentTesting, TextFilterTesting, TextareaTesting, ToggleTesting, ViewTestWrapper, WizardTesting, setupRestClientMock };
556
+ export { AbstractComponentTesting, AbstractInputTesting, AbstractSelectTesting, AbstractViewTesting, AlertTesting, BoxTesting, ButtonDropdownTesting, ButtonTesting, CSVNoItemsViewTesting, CSVPriceInputViewTesting, CSVSearchFilterViewTesting, CSVTextPromptModalViewTesting, CardsTesting, CheckboxTesting, CollectionPreferencesSetting, CollectionPreferencesTesting, CopyToClipboardTesting, DatePickerTesting, FlashbarTesting, FormTesting, HeaderTesting, IconTesting, LinkTesting, MockBrowserAPIs, MockRestClient, ModalTesting, MultiselectTesting, NumberInputTesting, PaginationTesting, ProgressBarTesting, RatingTesting, SegmentedControlTesting, SelectTesting, StatusIndicatorTesting, StringInputTesting, TableTesting, TabsTesting, TestLocalisation, TestingFactory, TextContentTesting, TextFilterTesting, TextareaTesting, ToggleTesting, ViewTestWrapper, WizardTesting, setupRestClientMock };
package/dist/index.d.ts CHANGED
@@ -547,43 +547,10 @@ declare class MockRestClient implements _ebertjendustries_cswrapper.IRestClient
547
547
  private mockImpl;
548
548
  }
549
549
 
550
- declare class MockServerBuilder {
551
- private port;
552
- private mockData;
553
- private redirectUrls;
554
- private server;
555
- private jsonServer;
556
- constructor(port: number, requireFunc: Function);
557
- addToMockData(key: string, data: any): void;
558
- /**
559
- * Puts mock data: Adds it to internal data structures and prepares it for mocking. It potentially updates
560
- * the overall mock data object later passed into jsonServer router as well as the rewrite object later
561
- * passed into jsonServer.rewriter.
562
- *
563
- * @param key The key of the data
564
- * @param data The data itself
565
- * @param urlRedirects The redirect URLs to be rewritten to the key url
566
- * @param crud Whether this is a crud redirect
567
- * @returns The loaded mock data object
568
- */
569
- putMockData(key: string, data: any, urlRedirects: string[], crud?: boolean): void;
570
- addToRedirects(key: string, urlRedirects: string[], crud: boolean): void;
571
- rewritePostToGet(url: string): void;
572
- static set200WithData(res: any, data: any): void;
573
- static respondWithError(res: any, componentId: string, messageId: string, httpStatus: number, op: string, message: string): void;
574
- mockCall(url: string, callProcessor: (req: any, res: any, next: Function) => void): void;
575
- mockCRUDMulti(urls: string[], allElements: any, finder: (id: number) => any, operationDesc: string): void;
576
- mockCRUD(url: string, allElements: any, finder: (id: number) => any, operationDesc: string): void;
577
- start(): void;
578
- private useCors;
579
- private static allowCors;
580
- private static postRewriteToGet;
581
- }
582
-
583
550
  declare class ViewTestWrapperProps<T> {
584
551
  initialValue: T;
585
552
  view: (value: T, onChange: PropertyChangeFunction) => React.ReactNode;
586
553
  }
587
554
  declare function ViewTestWrapper<T>(props: ViewTestWrapperProps<T>): react_jsx_runtime.JSX.Element;
588
555
 
589
- export { AbstractComponentTesting, AbstractInputTesting, AbstractSelectTesting, AbstractViewTesting, AlertTesting, BoxTesting, ButtonDropdownTesting, ButtonTesting, CSVNoItemsViewTesting, CSVPriceInputViewTesting, CSVSearchFilterViewTesting, CSVTextPromptModalViewTesting, CardsTesting, CheckboxTesting, CollectionPreferencesSetting, CollectionPreferencesTesting, CopyToClipboardTesting, DatePickerTesting, FlashbarTesting, FormTesting, HeaderTesting, IconTesting, LinkTesting, MockBrowserAPIs, MockRestClient, MockServerBuilder, ModalTesting, MultiselectTesting, NumberInputTesting, PaginationTesting, ProgressBarTesting, RatingTesting, SegmentedControlTesting, SelectTesting, StatusIndicatorTesting, StringInputTesting, TableTesting, TabsTesting, TestLocalisation, TestingFactory, TextContentTesting, TextFilterTesting, TextareaTesting, ToggleTesting, ViewTestWrapper, WizardTesting, setupRestClientMock };
556
+ export { AbstractComponentTesting, AbstractInputTesting, AbstractSelectTesting, AbstractViewTesting, AlertTesting, BoxTesting, ButtonDropdownTesting, ButtonTesting, CSVNoItemsViewTesting, CSVPriceInputViewTesting, CSVSearchFilterViewTesting, CSVTextPromptModalViewTesting, CardsTesting, CheckboxTesting, CollectionPreferencesSetting, CollectionPreferencesTesting, CopyToClipboardTesting, DatePickerTesting, FlashbarTesting, FormTesting, HeaderTesting, IconTesting, LinkTesting, MockBrowserAPIs, MockRestClient, ModalTesting, MultiselectTesting, NumberInputTesting, PaginationTesting, ProgressBarTesting, RatingTesting, SegmentedControlTesting, SelectTesting, StatusIndicatorTesting, StringInputTesting, TableTesting, TabsTesting, TestLocalisation, TestingFactory, TextContentTesting, TextFilterTesting, TextareaTesting, ToggleTesting, ViewTestWrapper, WizardTesting, setupRestClientMock };
package/dist/index.js CHANGED
@@ -55,7 +55,6 @@ __export(index_exports, {
55
55
  LinkTesting: () => LinkTesting,
56
56
  MockBrowserAPIs: () => MockBrowserAPIs,
57
57
  MockRestClient: () => MockRestClient,
58
- MockServerBuilder: () => MockServerBuilder,
59
58
  ModalTesting: () => ModalTesting,
60
59
  MultiselectTesting: () => MultiselectTesting,
61
60
  NumberInputTesting: () => NumberInputTesting,
@@ -1799,140 +1798,6 @@ var MockRestClient = class {
1799
1798
  }
1800
1799
  };
1801
1800
 
1802
- // src/mocks/MockServerBuilder.ts
1803
- var MockServerBuilder = class _MockServerBuilder {
1804
- constructor(port, requireFunc) {
1805
- this.port = port;
1806
- this.mockData = {};
1807
- this.redirectUrls = {};
1808
- this.jsonServer = requireFunc("json-server");
1809
- this.server = this.jsonServer.create();
1810
- this.server.use(this.jsonServer.bodyParser);
1811
- }
1812
- addToMockData(key, data) {
1813
- this.mockData[key] = data;
1814
- }
1815
- /**
1816
- * Puts mock data: Adds it to internal data structures and prepares it for mocking. It potentially updates
1817
- * the overall mock data object later passed into jsonServer router as well as the rewrite object later
1818
- * passed into jsonServer.rewriter.
1819
- *
1820
- * @param key The key of the data
1821
- * @param data The data itself
1822
- * @param urlRedirects The redirect URLs to be rewritten to the key url
1823
- * @param crud Whether this is a crud redirect
1824
- * @returns The loaded mock data object
1825
- */
1826
- putMockData(key, data, urlRedirects, crud) {
1827
- this.addToMockData(key, data);
1828
- if (crud !== void 0) {
1829
- this.addToRedirects(key, urlRedirects, crud);
1830
- } else {
1831
- this.addToRedirects(key, urlRedirects, false);
1832
- }
1833
- }
1834
- addToRedirects(key, urlRedirects, crud) {
1835
- urlRedirects.forEach((urlRedirect) => this.redirectUrls[urlRedirect] = "/" + key);
1836
- if (crud) {
1837
- urlRedirects.forEach((urlRedirect) => this.redirectUrls[urlRedirect + "/:id"] = "/" + key + "/:id");
1838
- }
1839
- }
1840
- rewritePostToGet(url) {
1841
- this.useCors(url);
1842
- this.server.use(url, _MockServerBuilder.postRewriteToGet);
1843
- }
1844
- static set200WithData(res, data) {
1845
- res.status(200).jsonp({ content: data });
1846
- }
1847
- static respondWithError(res, componentId, messageId, httpStatus, op, message) {
1848
- res.status(httpStatus).jsonp({
1849
- messages: [
1850
- {
1851
- "code": {
1852
- "componentId": componentId,
1853
- "httpStatusCode": httpStatus,
1854
- "localCode": messageId,
1855
- "messageSeverity": "ERR",
1856
- "uniqueCode": componentId + messageId
1857
- },
1858
- "correlationId": "N/A",
1859
- "detailMessage": message,
1860
- "operation": op,
1861
- "timestamp": "2022-05-10T15:17:08Z"
1862
- }
1863
- ]
1864
- });
1865
- }
1866
- mockCall(url, callProcessor) {
1867
- this.useCors(url);
1868
- this.server.use(url, callProcessor);
1869
- }
1870
- mockCRUDMulti(urls, allElements, finder, operationDesc) {
1871
- urls.forEach((url) => this.mockCRUD(url, allElements, finder, operationDesc));
1872
- }
1873
- mockCRUD(url, allElements, finder, operationDesc) {
1874
- this.mockCall(`${url}${url.endsWith("/") ? "" : "/"}:id`, async (req, res, next) => {
1875
- const method = req.method;
1876
- const id = parseInt(req.params["id"]);
1877
- console.log(`Calling ${operationDesc} CRUD ${method} with id ${id}`);
1878
- if (method === "GET") {
1879
- let returnedEntity = finder(id);
1880
- _MockServerBuilder.set200WithData(res, returnedEntity);
1881
- } else {
1882
- _MockServerBuilder.set200WithData(res, {});
1883
- }
1884
- });
1885
- this.mockCall(`${url}`, async (req, res, next) => {
1886
- const method = req.method;
1887
- console.log(`Calling ${operationDesc} CRUD ${method}${method === "GET" ? " ALL" : ""}`);
1888
- if (method === "GET") {
1889
- _MockServerBuilder.set200WithData(res, allElements);
1890
- } else if (method === "PUT") {
1891
- _MockServerBuilder.set200WithData(res, req.body);
1892
- } else {
1893
- _MockServerBuilder.set200WithData(res, {});
1894
- }
1895
- });
1896
- }
1897
- start() {
1898
- console.log("Mock data keys: " + Object.keys(this.mockData));
1899
- console.log("Redirect URLs: ", this.redirectUrls);
1900
- const router = this.jsonServer.router(this.mockData);
1901
- const middlewares = this.jsonServer.defaults();
1902
- this.server.use(this.jsonServer.rewriter(this.redirectUrls));
1903
- Object.keys(this.redirectUrls).forEach((redirectUrl) => {
1904
- this.useCors(redirectUrl);
1905
- });
1906
- this.server.use(middlewares);
1907
- this.server.use(router);
1908
- router.render = function(req, res) {
1909
- res.jsonp({
1910
- content: res.locals.data
1911
- });
1912
- };
1913
- this.server.listen(this.port, () => {
1914
- console.log("JSON Server is running on port " + this.port);
1915
- });
1916
- }
1917
- useCors(url) {
1918
- console.log("Configuring CORS for: ", url);
1919
- this.server.use(url, _MockServerBuilder.allowCors);
1920
- }
1921
- static allowCors(req, res, next) {
1922
- res.header("Access-Control-Allow-Origin", "*");
1923
- res.header("Access-Control-Allow-Headers", "*");
1924
- res.header("Access-Control-Allow-Methods", "*");
1925
- next();
1926
- }
1927
- static postRewriteToGet(req, res, next) {
1928
- if (req.method === "POST") {
1929
- console.log(`Received POST request, rewriting to GET: ` + req.url);
1930
- req.method = "GET";
1931
- }
1932
- next();
1933
- }
1934
- };
1935
-
1936
1801
  // src/utils/ViewTestWrapper.tsx
1937
1802
  var import_react30 = require("react");
1938
1803
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -1967,7 +1832,6 @@ function ViewTestWrapper(props) {
1967
1832
  LinkTesting,
1968
1833
  MockBrowserAPIs,
1969
1834
  MockRestClient,
1970
- MockServerBuilder,
1971
1835
  ModalTesting,
1972
1836
  MultiselectTesting,
1973
1837
  NumberInputTesting,
package/dist/index.mjs CHANGED
@@ -1719,140 +1719,6 @@ var MockRestClient = class {
1719
1719
  }
1720
1720
  };
1721
1721
 
1722
- // src/mocks/MockServerBuilder.ts
1723
- var MockServerBuilder = class _MockServerBuilder {
1724
- constructor(port, requireFunc) {
1725
- this.port = port;
1726
- this.mockData = {};
1727
- this.redirectUrls = {};
1728
- this.jsonServer = requireFunc("json-server");
1729
- this.server = this.jsonServer.create();
1730
- this.server.use(this.jsonServer.bodyParser);
1731
- }
1732
- addToMockData(key, data) {
1733
- this.mockData[key] = data;
1734
- }
1735
- /**
1736
- * Puts mock data: Adds it to internal data structures and prepares it for mocking. It potentially updates
1737
- * the overall mock data object later passed into jsonServer router as well as the rewrite object later
1738
- * passed into jsonServer.rewriter.
1739
- *
1740
- * @param key The key of the data
1741
- * @param data The data itself
1742
- * @param urlRedirects The redirect URLs to be rewritten to the key url
1743
- * @param crud Whether this is a crud redirect
1744
- * @returns The loaded mock data object
1745
- */
1746
- putMockData(key, data, urlRedirects, crud) {
1747
- this.addToMockData(key, data);
1748
- if (crud !== void 0) {
1749
- this.addToRedirects(key, urlRedirects, crud);
1750
- } else {
1751
- this.addToRedirects(key, urlRedirects, false);
1752
- }
1753
- }
1754
- addToRedirects(key, urlRedirects, crud) {
1755
- urlRedirects.forEach((urlRedirect) => this.redirectUrls[urlRedirect] = "/" + key);
1756
- if (crud) {
1757
- urlRedirects.forEach((urlRedirect) => this.redirectUrls[urlRedirect + "/:id"] = "/" + key + "/:id");
1758
- }
1759
- }
1760
- rewritePostToGet(url) {
1761
- this.useCors(url);
1762
- this.server.use(url, _MockServerBuilder.postRewriteToGet);
1763
- }
1764
- static set200WithData(res, data) {
1765
- res.status(200).jsonp({ content: data });
1766
- }
1767
- static respondWithError(res, componentId, messageId, httpStatus, op, message) {
1768
- res.status(httpStatus).jsonp({
1769
- messages: [
1770
- {
1771
- "code": {
1772
- "componentId": componentId,
1773
- "httpStatusCode": httpStatus,
1774
- "localCode": messageId,
1775
- "messageSeverity": "ERR",
1776
- "uniqueCode": componentId + messageId
1777
- },
1778
- "correlationId": "N/A",
1779
- "detailMessage": message,
1780
- "operation": op,
1781
- "timestamp": "2022-05-10T15:17:08Z"
1782
- }
1783
- ]
1784
- });
1785
- }
1786
- mockCall(url, callProcessor) {
1787
- this.useCors(url);
1788
- this.server.use(url, callProcessor);
1789
- }
1790
- mockCRUDMulti(urls, allElements, finder, operationDesc) {
1791
- urls.forEach((url) => this.mockCRUD(url, allElements, finder, operationDesc));
1792
- }
1793
- mockCRUD(url, allElements, finder, operationDesc) {
1794
- this.mockCall(`${url}${url.endsWith("/") ? "" : "/"}:id`, async (req, res, next) => {
1795
- const method = req.method;
1796
- const id = parseInt(req.params["id"]);
1797
- console.log(`Calling ${operationDesc} CRUD ${method} with id ${id}`);
1798
- if (method === "GET") {
1799
- let returnedEntity = finder(id);
1800
- _MockServerBuilder.set200WithData(res, returnedEntity);
1801
- } else {
1802
- _MockServerBuilder.set200WithData(res, {});
1803
- }
1804
- });
1805
- this.mockCall(`${url}`, async (req, res, next) => {
1806
- const method = req.method;
1807
- console.log(`Calling ${operationDesc} CRUD ${method}${method === "GET" ? " ALL" : ""}`);
1808
- if (method === "GET") {
1809
- _MockServerBuilder.set200WithData(res, allElements);
1810
- } else if (method === "PUT") {
1811
- _MockServerBuilder.set200WithData(res, req.body);
1812
- } else {
1813
- _MockServerBuilder.set200WithData(res, {});
1814
- }
1815
- });
1816
- }
1817
- start() {
1818
- console.log("Mock data keys: " + Object.keys(this.mockData));
1819
- console.log("Redirect URLs: ", this.redirectUrls);
1820
- const router = this.jsonServer.router(this.mockData);
1821
- const middlewares = this.jsonServer.defaults();
1822
- this.server.use(this.jsonServer.rewriter(this.redirectUrls));
1823
- Object.keys(this.redirectUrls).forEach((redirectUrl) => {
1824
- this.useCors(redirectUrl);
1825
- });
1826
- this.server.use(middlewares);
1827
- this.server.use(router);
1828
- router.render = function(req, res) {
1829
- res.jsonp({
1830
- content: res.locals.data
1831
- });
1832
- };
1833
- this.server.listen(this.port, () => {
1834
- console.log("JSON Server is running on port " + this.port);
1835
- });
1836
- }
1837
- useCors(url) {
1838
- console.log("Configuring CORS for: ", url);
1839
- this.server.use(url, _MockServerBuilder.allowCors);
1840
- }
1841
- static allowCors(req, res, next) {
1842
- res.header("Access-Control-Allow-Origin", "*");
1843
- res.header("Access-Control-Allow-Headers", "*");
1844
- res.header("Access-Control-Allow-Methods", "*");
1845
- next();
1846
- }
1847
- static postRewriteToGet(req, res, next) {
1848
- if (req.method === "POST") {
1849
- console.log(`Received POST request, rewriting to GET: ` + req.url);
1850
- req.method = "GET";
1851
- }
1852
- next();
1853
- }
1854
- };
1855
-
1856
1722
  // src/utils/ViewTestWrapper.tsx
1857
1723
  import { useState } from "react";
1858
1724
  import { jsx } from "react/jsx-runtime";
@@ -1886,7 +1752,6 @@ export {
1886
1752
  LinkTesting,
1887
1753
  MockBrowserAPIs,
1888
1754
  MockRestClient,
1889
- MockServerBuilder,
1890
1755
  ModalTesting,
1891
1756
  MultiselectTesting,
1892
1757
  NumberInputTesting,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebertjendustries/cstestwrapper",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -93,5 +93,5 @@
93
93
  "last 1 safari version"
94
94
  ]
95
95
  },
96
- "packageManager": "yarn@4.9.1"
96
+ "packageManager": "yarn@4.9.2"
97
97
  }