Мне нужно написать спецификацию для следующей функции в Жасмин.
export function getComponent<T>(ele: HTMLElement, comp: string): T {
let instance: T;
for (let i = 0; i < (<DomElements>(ele as HTMLElement)).ej2_instances.length; i++) {
instance = <T>(ele as DomElements).ej2_instances[i];
let compName: string = (instance as { getModuleName: () => string } & T).getModuleName();
if (comp === compName) {
return instance;
}
}
return undefined;
}
Я попробовал следующее, но это не сработало.
describe('getcomponent function', (): void => {
let instance: string;
let componentname: string;
function test(instance, componentname) {
it('if statement', function () {
expect(instance).toEqual(componentname)
});
}
for (let i = 0; i < instance.length; i++) {
test(instance[i], componentname[i])
}
})