Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Created September 12, 2023 03:36
Show Gist options
  • Save YonatanKra/19c6b63a8d0e6b5c4481e2706d3d0555 to your computer and use it in GitHub Desktop.
Save YonatanKra/19c6b63a8d0e6b5c4481e2706d3d0555 to your computer and use it in GitHub Desktop.
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