Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OR-1219]: Fix failing tests on o-typography #1936

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 54 additions & 29 deletions components/o-typography/test/scss/_mixins.test.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
$o-typography-load-fonts: true !global;
$o-typography-progressive-font-loading: true !global;
}

@include expect {
.o-typography-heading-level-1 {
font-family: MetricWeb, sans-serif;
font-size: 32px;
line-height: 32px;
font-weight: 600;
color: #33302e;
color: rgb(51, 48.2, 45.8); // #33302e
margin: 0 0 16px;
}
}
Expand All @@ -30,13 +31,14 @@
$o-typography-load-fonts: true !global;
$o-typography-progressive-font-loading: true !global;
}

@include expect($selector: false) {
.o-typography-heading-level-1 {
font-family: MetricWeb, sans-serif;
font-size: 32px;
line-height: 32px;
font-weight: 600;
color: #33302e;
color: rgb(51, 48.2, 45.8); // #33302e
margin: 0 0 16px;
}

Expand All @@ -45,7 +47,7 @@
font-size: 28px;
line-height: 32px;
font-weight: 600;
color: #33302e;
color: rgb(51, 48.2, 45.8); // #33302e
margin: 0 0 16px;
}
}
Expand All @@ -59,6 +61,7 @@
@include output {
@include oTypographySans();
}

@include expect {
font-family: oFontsGetFontFamilyWithFallbacks(MetricWeb);
}
Expand All @@ -70,10 +73,12 @@
@include output {
@include oTypographySans(1);
}

@include expect {
font-family: oFontsGetFontFamilyWithFallbacks(MetricWeb);
font-size: 18px;
line-height: 20px;

.o-typography--loading-sans & {
font-size: 15.66px;
font-family: sans-serif;
Expand All @@ -87,10 +92,12 @@
@include output {
@include oTypographySans(1, 1.6);
}

@include expect {
font-family: oFontsGetFontFamilyWithFallbacks(MetricWeb);
font-size: 18px;
line-height: 1.6;

.o-typography--loading-sans & {
font-size: 15.66px;
font-family: sans-serif;
Expand All @@ -104,11 +111,13 @@
@include output {
@include oTypographySans(1, $weight: 'bold');
}

@include expect {
font-family: oFontsGetFontFamilyWithFallbacks(MetricWeb);
font-size: 18px;
line-height: 20px;
font-weight: 700;

.o-typography--loading-sans-bold & {
font-size: 14.94px;
font-family: sans-serif;
Expand Down Expand Up @@ -138,6 +147,7 @@
@include output {
@include oTypographySans(1, 1.6, $include-font-family: false);
}

@include expect {
font-size: 18px;
line-height: 1.6;
Expand All @@ -154,6 +164,7 @@
@include output {
@include oTypographySans(1, 1.6, $include-progressive: false);
}

@include expect {
font-family: oFontsGetFontFamilyWithFallbacks(MetricWeb);
font-size: 18px;
Expand All @@ -168,6 +179,7 @@
@include output {
@include oTypographySans($scale: (default: 1, L: 2));
}

@include contains {
font-size: 18px;
line-height: 20px;
Expand All @@ -185,6 +197,7 @@
@include output {
@include oTypographySans($scale: 1, $line-height: 1.4);
}

@include contains {
font-size: 18px;
line-height: 1.4;
Expand All @@ -197,6 +210,7 @@
@include output {
@include oTypographySans($scale: (default: 1, L: 2), $line-height: 24px);
}

@include contains {
font-size: 18px;
line-height: 24px;
Expand All @@ -214,6 +228,7 @@
@include output {
@include oTypographySans($scale: (default: (1, 18px), L: (2, 24px)));
}

@include contains {
font-size: 18px;
line-height: 18px;
Expand All @@ -231,6 +246,7 @@
@include output {
@include oTypographySans($scale: (default: (1, 18px), L: 2), $line-height: 1.4);
}

@include contains {
font-size: 18px;
line-height: 18px;
Expand All @@ -250,6 +266,7 @@
@include oTypographySans($scale: 1, $line-height: unset);
$o-typography-relative-units: false !global;
}

@include contains {
font-size: 1.125rem;
line-height: unset;
Expand All @@ -264,6 +281,7 @@
@include oTypographySans($scale: 1);
$o-typography-relative-units: false !global;
}

@include contains {
font-size: 1.125rem;
line-height: 1.25rem;
Expand All @@ -278,6 +296,7 @@
@include oTypographySans($scale: 1, $line-height: unset);
$o-typography-relative-units: false !global;
}

@include contains {
font-size: 1.125rem;
line-height: unset;
Expand All @@ -292,6 +311,7 @@
@include output {
@include oTypographySerif();
}

@include expect {
font-family: oFontsGetFontFamilyWithFallbacks(Georgia);
}
Expand All @@ -303,6 +323,7 @@
@include output {
@include oTypographySerif(1);
}

@include expect {
font-family: oFontsGetFontFamilyWithFallbacks(Georgia);
font-size: 18px;
Expand All @@ -316,6 +337,7 @@
@include output {
@include oTypographySerif(1, 1.6);
}

@include expect {
font-family: oFontsGetFontFamilyWithFallbacks(Georgia);
font-size: 18px;
Expand All @@ -329,6 +351,7 @@
@include output {
@include oTypographySerif(1, $weight: 'bold');
}

@include expect {
font-family: oFontsGetFontFamilyWithFallbacks(Georgia);
font-size: 18px;
Expand Down Expand Up @@ -358,6 +381,7 @@
@include output {
@include oTypographySerif(1, 1.6, $include-font-family: false);
}

@include expect {
font-size: 18px;
line-height: 1.6;
Expand All @@ -370,6 +394,7 @@
@include output {
@include oTypographySerif(1, 1.6, $include-progressive: false);
}

@include expect {
font-family: oFontsGetFontFamilyWithFallbacks(Georgia);
font-size: 18px;
Expand All @@ -385,6 +410,7 @@
@include output {
@include oTypographyDisplay();
}

@include expect {
font-family: oFontsGetFontFamilyWithFallbacks(FinancierDisplayWeb);
}
Expand All @@ -396,10 +422,12 @@
@include output {
@include oTypographyDisplay(1);
}

@include expect {
font-family: oFontsGetFontFamilyWithFallbacks(FinancierDisplayWeb);
font-size: 18px;
line-height: 20px;

.o-typography--loading-display & {
font-size: 16.2px;
font-family: serif;
Expand All @@ -413,10 +441,12 @@
@include output {
@include oTypographyDisplay(1, 1.6);
}

@include expect {
font-family: oFontsGetFontFamilyWithFallbacks(FinancierDisplayWeb);
font-size: 18px;
line-height: 1.6;

.o-typography--loading-display & {
font-size: 16.2px;
font-family: serif;
Expand All @@ -430,11 +460,13 @@
@include output {
@include oTypographyDisplay(1, $weight: 'bold');
}

@include expect {
font-family: oFontsGetFontFamilyWithFallbacks(FinancierDisplayWeb);
font-size: 18px;
line-height: 20px;
font-weight: 700;

.o-typography--loading-display-bold & {
font-size: 16.2px;
font-family: serif;
Expand All @@ -448,6 +480,7 @@
@include output {
@include oTypographyDisplay(1, 1.6, $include-font-family: false);
}

@include expect {
font-size: 18px;
line-height: 1.6;
Expand All @@ -464,6 +497,7 @@
@include output {
@include oTypographyDisplay(1, 1.6, $include-progressive: false);
}

@include expect {
font-family: oFontsGetFontFamilyWithFallbacks(FinancierDisplayWeb);
font-size: 18px;
Expand All @@ -489,44 +523,35 @@
9: (18, 20),
10: (20, 22)
);
@include test('Adds scale to font scale map.') {
// Set custom scale for custom font.
@include oTypographyDefineFontScale('MyFont, sans', $custom-font-scale);

// The custom scale is added to the font scale map.
@include assert-equal(
$_o-typography-font-scale-by-font,
(
'MyFont': $custom-font-scale
)
);
}

@include test('Adds scale to font scale map.') {
// Set custom scale for custom font.
@include oTypographyDefineFontScale('MyFont, sans', $custom-font-scale);

// The custom scale is added to the font scale map.
@include assert-equal($_o-typography-font-scale-by-font,
('MyFont': $custom-font-scale));
}
}

@include test-module('oTypographySetFont') {
@include test('Updates the global variable for the sans font') {
@include oFontsDefineCustomFont('system-ui', (
(weight: semibold, style: normal),
(weight: regular, style: normal),
(weight: bold, style: normal)
));
@include oFontsDefineCustomFont('system-ui', ((weight: semibold, style: normal),
(weight: regular, style: normal),
(weight: bold, style: normal)));
// Set sans font.
@include oTypographySetFont(
$type: 'sans',
@include oTypographySetFont($type: 'sans',
$family: 'system-ui'
);
@include assert-equal($_o-typography-sans, 'system-ui');
}

@include test('Updates the global variable for the display font') {
@include oFontsDefineCustomFont('MyDisplayFont, serif', (
(weight: semibold, style: normal),
(weight: regular, style: normal),
(weight: bold, style: normal)
));
@include oFontsDefineCustomFont('MyDisplayFont, serif', ((weight: semibold, style: normal),
(weight: regular, style: normal),
(weight: bold, style: normal)));
// Set display font.
@include oTypographySetFont(
$type: 'display',
@include oTypographySetFont($type: 'display',
$family: 'MyDisplayFont'
);
@include assert-equal($_o-typography-display, 'MyDisplayFont');
Expand Down
Loading