Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('ClientFunction call with complex return types', async() => {
const fn = ClientFunction(() => {
return [/\S+/ig, new Error('Hey!'), void 0, NaN];
});
const res = await fn();
await t.expect(res[0].source).eql('\\S+');
await t.expect(res[1].message).eql('Hey!');
await t.expect(res[2]).eql(void 0);
await t.expect(Number.isNaN(res[3])).ok();
});
test('Call with arguments', async() => {
const getElementText = ClientFunction((className, idx) => {
return document.querySelectorAll('.' + className)[idx].textContent;
});
const answer = await getElementText('answer', 1);
await t.expect(answer.trim()).eql('42');
});
test('Hammerhead code instrumentation', async() => {
const location = await getLocation();
await t.expect(location).eql('http://localhost:3000/fixtures/api/es-next/client-function/pages/index.html');
});
async assertIsVisible () {
await t.expect(Selector(this.selector).exists).ok(`${this.selector} should be visible`)
}
export async function expectVisible() {
await t.expect(Selector('mesh-container-contents').visible).ok('Container contents are not visible');
}
async function expectMessage(msg: string, type: string) {
await t
.expect(Selector(`gtx-toast div.${type}`).withText(msg).exists)
.ok(`Expected toast error message containing "${msg}"`);
}
}
async assertNotVisible () {
await t.expect(Selector(this.selector).exists).ok(`${this.selector} should be not visible`)
}
}
export default async function () {
const {error} = await t.getBrowserConsoleMessages();
if (error[0]) {
console.log('These console errors were the cause of the failed test:', error);
}
await t.expect(error[0]).notOk();
}
async open(identityType) {
const button = this.find(identityType);
const currentIdentity = new Identity(identityType);
await t
.expect(button.visible)
.ok()
.click(button)
.expect(currentIdentity.container.visible)
.ok();
return currentIdentity;
}