Skip to content

Commit

Permalink
test: βœ… use testing library
Browse files Browse the repository at this point in the history
  • Loading branch information
yjaaidi committed Nov 3, 2023
1 parent 60e052d commit b4a2417
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions apps/whiskmate/src/app/recipe/recipe-filter.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
import { TestBed } from '@angular/core/testing';

Check warning on line 1 in apps/whiskmate/src/app/recipe/recipe-filter.component.spec.ts

View workflow job for this annotation

GitHub Actions / βœ… Test

'TestBed' is defined but never used
import { By } from '@angular/platform-browser';

Check warning on line 2 in apps/whiskmate/src/app/recipe/recipe-filter.component.spec.ts

View workflow job for this annotation

GitHub Actions / βœ… Test

'By' is defined but never used
import { RecipeFilterComponent } from './recipe-filter.component';
import { render, screen } from '@testing-library/angular';
import userEvent from '@testing-library/user-event/index';

describe(RecipeFilterComponent.name, () => {
it.todo('🚧 should trigger filterChange output');

function renderComponent() {
const fixture = TestBed.createComponent(RecipeFilterComponent);

fixture.detectChanges();
async function renderComponent() {

Check warning on line 10 in apps/whiskmate/src/app/recipe/recipe-filter.component.spec.ts

View workflow job for this annotation

GitHub Actions / βœ… Test

'renderComponent' is defined but never used
const { fixture } = await render(RecipeFilterComponent);

return {
component: fixture.componentInstance,
setInputValue(
dataRole:
| 'keywords-input'
| 'max-ingredient-count-input'
| 'max-step-count-input',
async setInputValue(
label: 'Keywords' | 'Max Ingredients' | 'Max Steps',
value: string
) {
const el = fixture.debugElement.query(
By.css(`[data-role="${dataRole}"]`)
);
el.nativeElement.value = value;
el.nativeElement.dispatchEvent(new Event('input'));
const inputEl = screen.getByLabelText(label);
await userEvent.type(inputEl, value);
},
};
}
Expand Down

0 comments on commit b4a2417

Please sign in to comment.