Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Last active September 12, 2023 06:09
Show Gist options
  • Save YonatanKra/ec14bb347163ea26a677160055ddc841 to your computer and use it in GitHub Desktop.
Save YonatanKra/ec14bb347163ea26a677160055ddc841 to your computer and use it in GitHub Desktop.
Tauri-demo: the IPC test
it('should set the greeting message inside the message element', async () => {
const greeter = document.createElement('yag-greeter');
const name = 'John Doe';
const greetForm = greeter.shadowRoot?.querySelector('#greet-form') as HTMLFormElement;
const greetInput = greeter.shadowRoot?.querySelector('#greet-input') as HTMLInputElement;
const greetMsgEl = greeter.shadowRoot?.querySelector('#greet-msg') as HTMLElement;
greetInput.value = name;
mockIPC((cmd, args) => {
if(cmd === "greet") {
return `Hello, ${args.name}! You've been greeted from Rust!`;
}
});
greetForm.dispatchEvent(new Event("submit"));
await new Promise((resolve) => setTimeout(resolve, 0));
expect(greetMsgEl?.textContent).toBe(`Hello, ${name}! You've been greeted from Rust!`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment