Some clean up stuff
This commit is contained in:
1 parent
db2bc7ab97
commit
16142178f4
6 files changed
+57
-14
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { provideZonelessChangeDetection } from '@angular/core';
|
||||
import { Component, provideZonelessChangeDetection } from '@angular/core';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { provideRouter } from '@angular/router';
|
||||
import { provideTranslateService } from '@ngx-translate/core';
|
||||
@@ -172,3 +173,42 @@ describe('AboutComponent', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Material typography (`brand-family` in styles.scss) and the Tailwind body
|
||||
* stack are declared in two separate places and are easy to change apart. When
|
||||
* they disagree, only visitors who happen to have the extra font installed
|
||||
* locally see it, so it will not show up in review.
|
||||
*/
|
||||
describe('global font stack', () => {
|
||||
@Component({
|
||||
imports: [MatCardModule],
|
||||
template: `<mat-card><mat-card-title>probe</mat-card-title></mat-card>`,
|
||||
})
|
||||
class FontProbeComponent {}
|
||||
|
||||
function normalizeStack(value: string): string {
|
||||
return value
|
||||
.replace(/["']/g, '')
|
||||
.split(',')
|
||||
.map(family => family.trim())
|
||||
.filter(family => family.length > 0)
|
||||
.join(', ');
|
||||
}
|
||||
|
||||
it('resolves Material card titles to the same font stack as body copy', async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [FontProbeComponent],
|
||||
providers: [provideZonelessChangeDetection()],
|
||||
}).compileComponents();
|
||||
|
||||
const probe = TestBed.createComponent(FontProbeComponent);
|
||||
probe.detectChanges();
|
||||
|
||||
const title = probe.nativeElement.querySelector('.mat-mdc-card-title') as HTMLElement;
|
||||
const titleStack = normalizeStack(getComputedStyle(title).fontFamily);
|
||||
const bodyStack = normalizeStack(getComputedStyle(document.body).fontFamily);
|
||||
|
||||
expect(titleStack).toBe(bodyStack);
|
||||
});
|
||||
});
|
||||
@@ -14,12 +14,15 @@ describe('LanguageService', () => {
|
||||
return TestBed.inject(LanguageService);
|
||||
}
|
||||
|
||||
const documentLanguage = document.documentElement.lang;
|
||||
|
||||
beforeEach(() => {
|
||||
localStorage.clear();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
localStorage.clear();
|
||||
document.documentElement.lang = documentLanguage;
|
||||
});
|
||||
|
||||
it('uses the stored language as the initial value', () => {
|
||||
|
||||
Reference in new issue
Block a user