generated from nhcarrigan/template
0b5b4eadb9
### Explanation _No response_ ### Issue _No response_ ### Attestations - [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/) - [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/). - [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/). ### Dependencies - [ ] I have pinned the dependencies to a specific patch version. ### Style - [ ] I have run the linter and resolved any errors. - [ ] My pull request uses an appropriate title, matching the conventional commit standards. - [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request. ### Tests - [ ] My contribution adds new code, and I have added tests to cover it. - [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes. - [ ] All new and existing tests pass locally with my changes. - [ ] Code coverage remains at or above the configured threshold. ### Documentation _No response_ ### Versioning _No response_ Reviewed-on: #1 Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com> Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
84 lines
2.6 KiB
TypeScript
84 lines
2.6 KiB
TypeScript
/**
|
|
* @copyright NHCarrigan
|
|
* @license Naomi's Public License
|
|
* @author Naomi Carrigan
|
|
*/
|
|
import { type ComponentFixture, TestBed } from "@angular/core/testing";
|
|
import { describe, beforeEach, it, expect } from "vitest";
|
|
import { Faq } from "./faq";
|
|
|
|
describe("faq", () => {
|
|
let component: Faq;
|
|
let fixture: ComponentFixture<Faq>;
|
|
|
|
beforeEach(async() => {
|
|
await TestBed.configureTestingModule({
|
|
imports: [ Faq ],
|
|
}).
|
|
compileComponents();
|
|
|
|
fixture = TestBed.createComponent(Faq);
|
|
component = fixture.componentInstance;
|
|
await fixture.whenStable();
|
|
});
|
|
|
|
it("should create", () => {
|
|
expect.assertions(1);
|
|
expect(component, "did not compile").toBeTruthy();
|
|
});
|
|
|
|
it("should render main heading", () => {
|
|
expect.assertions(1);
|
|
fixture.detectChanges();
|
|
const compiled = fixture.nativeElement as HTMLElement;
|
|
const heading = compiled.querySelector("h1");
|
|
expect(heading?.textContent.trim(), "should render FAQ heading").
|
|
toBe("F.A.Q. (Frequently Asked Questions)");
|
|
});
|
|
|
|
it("should render questions", () => {
|
|
expect.assertions(1);
|
|
fixture.detectChanges();
|
|
const compiled = fixture.nativeElement as HTMLElement;
|
|
const questions = compiled.querySelectorAll(".question");
|
|
expect(questions.length, "should render multiple questions").
|
|
toBeGreaterThan(0);
|
|
});
|
|
|
|
it("should render answers", () => {
|
|
expect.assertions(1);
|
|
fixture.detectChanges();
|
|
const compiled = fixture.nativeElement as HTMLElement;
|
|
const answers = compiled.querySelectorAll(".answer");
|
|
expect(answers.length, "should render multiple answers").toBeGreaterThan(0);
|
|
});
|
|
|
|
it("should have matching number of questions and answers", () => {
|
|
expect.assertions(1);
|
|
fixture.detectChanges();
|
|
const compiled = fixture.nativeElement as HTMLElement;
|
|
const questions = compiled.querySelectorAll(".question");
|
|
const answers = compiled.querySelectorAll(".answer");
|
|
expect(questions, "should have matching Q&A pairs").
|
|
toHaveLength(answers.length);
|
|
});
|
|
|
|
it("should render office hours question", () => {
|
|
expect.assertions(1);
|
|
fixture.detectChanges();
|
|
const compiled = fixture.nativeElement as HTMLElement;
|
|
const text = compiled.textContent;
|
|
expect(text, "should contain office hours question").
|
|
toContain("office hours 6:00 PM to 6:00 AM");
|
|
});
|
|
|
|
it("should render payment methods question", () => {
|
|
expect.assertions(1);
|
|
fixture.detectChanges();
|
|
const compiled = fixture.nativeElement as HTMLElement;
|
|
const text = compiled.textContent;
|
|
expect(text, "should contain payment methods question").
|
|
toContain("forms of payment");
|
|
});
|
|
});
|