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>
105 lines
3.7 KiB
TypeScript
105 lines
3.7 KiB
TypeScript
/**
|
|
* @copyright NHCarrigan
|
|
* @license Naomi's Public License
|
|
* @author Naomi Carrigan
|
|
*/
|
|
import { TestBed } from "@angular/core/testing";
|
|
import { RouterTestingModule } from "@angular/router/testing";
|
|
import { describe, beforeEach, it, expect } from "vitest";
|
|
import { App } from "./app";
|
|
|
|
describe("app", () => {
|
|
beforeEach(async() => {
|
|
await TestBed.configureTestingModule({
|
|
// eslint-disable-next-line deprecation/deprecation -- We need to use the deprecated method.
|
|
imports: [ App, RouterTestingModule ],
|
|
}).compileComponents();
|
|
});
|
|
|
|
it("should create the app", () => {
|
|
expect.assertions(1);
|
|
const fixture = TestBed.createComponent(App);
|
|
const app = fixture.componentInstance;
|
|
expect(app, "did not compile").toBeTruthy();
|
|
});
|
|
|
|
it("should initialize with correct title", () => {
|
|
expect.assertions(1);
|
|
const fixture = TestBed.createComponent(App);
|
|
const app = fixture.componentInstance;
|
|
// @ts-expect-error - We want it protected, but need to use it in the test.
|
|
expect(app.title(), "should have correct title").toBe("lore");
|
|
});
|
|
|
|
it("should render navigation component", async() => {
|
|
expect.assertions(1);
|
|
const fixture = TestBed.createComponent(App);
|
|
await fixture.whenStable();
|
|
fixture.detectChanges();
|
|
const compiled = fixture.nativeElement as HTMLElement;
|
|
const nav = compiled.querySelector("app-nav");
|
|
expect(nav, "should render nav component").toBeTruthy();
|
|
});
|
|
|
|
it("should render ticker component", async() => {
|
|
expect.assertions(1);
|
|
const fixture = TestBed.createComponent(App);
|
|
await fixture.whenStable();
|
|
fixture.detectChanges();
|
|
const compiled = fixture.nativeElement as HTMLElement;
|
|
const ticker = compiled.querySelector("app-ticker");
|
|
expect(ticker, "should render ticker component").toBeTruthy();
|
|
});
|
|
|
|
it("should render disclaimer component", async() => {
|
|
expect.assertions(1);
|
|
const fixture = TestBed.createComponent(App);
|
|
await fixture.whenStable();
|
|
fixture.detectChanges();
|
|
const compiled = fixture.nativeElement as HTMLElement;
|
|
const disclaimer = compiled.querySelector("app-disclaimer");
|
|
expect(disclaimer, "should render disclaimer component").toBeTruthy();
|
|
});
|
|
|
|
it("should render footer component", async() => {
|
|
expect.assertions(1);
|
|
const fixture = TestBed.createComponent(App);
|
|
await fixture.whenStable();
|
|
fixture.detectChanges();
|
|
const compiled = fixture.nativeElement as HTMLElement;
|
|
const footer = compiled.querySelector("app-footer");
|
|
expect(footer, "should render footer component").toBeTruthy();
|
|
});
|
|
|
|
it("should render router outlet", async() => {
|
|
expect.assertions(1);
|
|
const fixture = TestBed.createComponent(App);
|
|
await fixture.whenStable();
|
|
fixture.detectChanges();
|
|
const compiled = fixture.nativeElement as HTMLElement;
|
|
const routerOutlet = compiled.querySelector("router-outlet");
|
|
expect(routerOutlet, "should render router outlet").toBeTruthy();
|
|
});
|
|
|
|
it("should have proper layout structure", async() => {
|
|
expect.assertions(1);
|
|
const fixture = TestBed.createComponent(App);
|
|
await fixture.whenStable();
|
|
fixture.detectChanges();
|
|
const compiled = fixture.nativeElement as HTMLElement;
|
|
const main = compiled.querySelector("main");
|
|
expect(main, "should render main element").toBeTruthy();
|
|
});
|
|
|
|
it("should have fixed positioning for nav and ticker", async() => {
|
|
expect.assertions(1);
|
|
const fixture = TestBed.createComponent(App);
|
|
await fixture.whenStable();
|
|
fixture.detectChanges();
|
|
const compiled = fixture.nativeElement as HTMLElement;
|
|
const fixedContainer = compiled.querySelector(".fixed");
|
|
expect(fixedContainer,
|
|
"should have fixed positioning container").toBeTruthy();
|
|
});
|
|
});
|