Skip to content

Commit

Permalink
Remove unnecessary mock system.
Browse files Browse the repository at this point in the history
  • Loading branch information
enbock committed Feb 13, 2024
1 parent 085e130 commit 649f821
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@enbock/ts-jsx",
"version": "0.1.0",
"version": "0.1.1",
"description": "An simple JSX rendering based on ShadowDOMv1.",
"license": "MIT",
"author": "Endre Bock <endre@itbock.de>",
Expand Down
20 changes: 0 additions & 20 deletions src/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,6 @@ export interface ComponentProperties {
[name: string]: any;
}

export function mock<T>(component: T): void {
const staticReference: typeof Component = component as any;

function mockedFactory<T extends Component>(): T {
let node: T = document.createElement('div') as any;
const output: string = 'test::' + staticReference.name + ':';
const textNode: Text = document.createTextNode(output);
node.appendChild(textNode);
node.updateProps = function (props: any) {
const shownProps: any = {...props};
if (shownProps.hasOwnProperty('attach')) shownProps.attach = shownProps.attach.toString();
if (shownProps.hasOwnProperty('adapter')) shownProps.adapter = shownProps.adapter.toString();
textNode.nodeValue = output + JSON.stringify(shownProps);
};
return node;
}

staticReference.factory = mockedFactory;
}

// noinspection JSUnusedGlobalSymbols
export default class Component<Properties extends ComponentProperties = ComponentProperties> extends HTMLElement {
public static dependencyInjection: any[] = [];
Expand Down

0 comments on commit 649f821

Please sign in to comment.