Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Created September 12, 2023 03:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Testing that the elements exist in the DOM
it ('should have greet button inside', () => {
const greeter = document.createElement('yag-greeter');
expect(greeter.shadowRoot?.querySelector('#greet-form button')).toBeTruthy();
});
it ('should have greet form inside', () => {
const greeter = document.createElement('yag-greeter');
expect(greeter.shadowRoot?.querySelector('#greet-form')).toBeTruthy();
});
it ('should have greet input associated with the form', () => {
const greeter = document.createElement('yag-greeter');
const greetInput = greeter.shadowRoot?.querySelector('#greet-input');
expect(greetInput?.form).toEqual(greeter.shadowRoot?.querySelector('#greet-form'));
});
it ('should have greet message area', () => {
const greeter = document.createElement('yag-greeter');
expect(greeter.shadowRoot?.querySelector('#greet-msg')).toBeTruthy();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment