feat(cli): Improve test runner configuration: update test scripts, reorganize test directories, update dependencies and add local settings for command permissions.
This commit is contained in:
40
ts_tapbundle/webhelpers.ts
Normal file
40
ts_tapbundle/webhelpers.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import * as plugins from './tapbundle.plugins.js';
|
||||
import { tap } from './tapbundle.classes.tap.js';
|
||||
|
||||
class WebHelpers {
|
||||
html: any;
|
||||
fixture: any;
|
||||
|
||||
constructor() {
|
||||
const smartenv = new plugins.smartenv.Smartenv();
|
||||
|
||||
// Initialize HTML template tag function
|
||||
this.html = (strings: TemplateStringsArray, ...values: any[]) => {
|
||||
let result = '';
|
||||
for (let i = 0; i < strings.length; i++) {
|
||||
result += strings[i];
|
||||
if (i < values.length) {
|
||||
result += values[i];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
// Initialize fixture function based on environment
|
||||
if (smartenv.isBrowser) {
|
||||
this.fixture = async (htmlString: string): Promise<HTMLElement> => {
|
||||
const container = document.createElement('div');
|
||||
container.innerHTML = htmlString.trim();
|
||||
const element = container.firstChild as HTMLElement;
|
||||
return element;
|
||||
};
|
||||
} else {
|
||||
// Node.js environment - provide a stub or alternative implementation
|
||||
this.fixture = async (htmlString: string): Promise<any> => {
|
||||
throw new Error('WebHelpers.fixture is only available in browser environment');
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const webhelpers = new WebHelpers();
|
Reference in New Issue
Block a user