2022-09-22 07:12:59 +02:00
|
|
|
import cheerio from 'cheerio'
|
|
|
|
import { createNext, FileRef } from 'e2e-utils'
|
|
|
|
import { NextInstance } from 'test/lib/next-modes/base'
|
|
|
|
import { renderViaHTTP } from 'next-test-utils'
|
|
|
|
import { join } from 'path'
|
|
|
|
import webdriver from 'next-webdriver'
|
|
|
|
|
|
|
|
const mockedGoogleFontResponses = require.resolve(
|
|
|
|
'./google-font-mocked-responses.js'
|
|
|
|
)
|
|
|
|
|
|
|
|
describe('@next/font/google', () => {
|
|
|
|
let next: NextInstance
|
|
|
|
|
|
|
|
if ((global as any).isNextDeploy) {
|
|
|
|
it('should skip next deploy for now', () => {})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
next = await createNext({
|
|
|
|
files: {
|
|
|
|
pages: new FileRef(join(__dirname, 'app/pages')),
|
|
|
|
components: new FileRef(join(__dirname, 'app/components')),
|
2022-09-22 21:49:02 +02:00
|
|
|
fonts: new FileRef(join(__dirname, 'app/fonts')),
|
2022-09-22 07:12:59 +02:00
|
|
|
'next.config.js': new FileRef(join(__dirname, 'app/next.config.js')),
|
|
|
|
},
|
|
|
|
dependencies: {
|
|
|
|
'@next/font': 'canary',
|
|
|
|
},
|
|
|
|
env: {
|
|
|
|
NEXT_FONT_GOOGLE_MOCKED_RESPONSES: mockedGoogleFontResponses,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|
|
|
|
afterAll(() => next.destroy())
|
|
|
|
|
|
|
|
describe('import values', () => {
|
|
|
|
test('page with font', async () => {
|
|
|
|
const html = await renderViaHTTP(next.url, '/with-fonts')
|
|
|
|
const $ = cheerio.load(html)
|
|
|
|
|
|
|
|
// _app.js
|
|
|
|
expect(JSON.parse($('#app-open-sans').text())).toEqual({
|
2022-09-27 20:10:05 +02:00
|
|
|
className: expect.stringMatching(/^__className_.{6}$/),
|
|
|
|
variable: expect.stringMatching(/^__variable_.{6}$/),
|
2022-09-22 07:12:59 +02:00
|
|
|
style: {
|
2022-10-28 00:25:57 +02:00
|
|
|
fontFamily: expect.stringMatching(
|
|
|
|
/^'__Open_Sans_.{6}', '__Open_Sans_Fallback_.{6}'$/
|
|
|
|
),
|
2022-10-20 19:42:19 +02:00
|
|
|
fontStyle: 'normal',
|
2022-09-22 07:12:59 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
// with-fonts.js
|
|
|
|
expect(JSON.parse($('#with-fonts-open-sans').text())).toEqual({
|
2022-09-27 20:10:05 +02:00
|
|
|
className: expect.stringMatching(/^__className_.{6}$/),
|
|
|
|
variable: expect.stringMatching(/^__variable_.{6}$/),
|
2022-09-22 07:12:59 +02:00
|
|
|
style: {
|
2022-10-28 00:25:57 +02:00
|
|
|
fontFamily: expect.stringMatching(
|
|
|
|
/^'__Open_Sans_.{6}', '__Open_Sans_Fallback_.{6}'$/
|
|
|
|
),
|
2022-10-20 19:42:19 +02:00
|
|
|
fontStyle: 'normal',
|
2022-09-22 07:12:59 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
// CompWithFonts.js
|
|
|
|
expect(JSON.parse($('#comp-with-fonts-inter').text())).toEqual({
|
2022-09-27 20:10:05 +02:00
|
|
|
className: expect.stringMatching(/^__className_.{6}$/),
|
2022-09-22 07:12:59 +02:00
|
|
|
style: {
|
2022-10-28 00:25:57 +02:00
|
|
|
fontFamily: expect.stringMatching(
|
|
|
|
/^'__Inter_.{6}', '__Inter_Fallback_.{6}'$/
|
|
|
|
),
|
2022-09-22 07:12:59 +02:00
|
|
|
fontWeight: 900,
|
2022-10-20 19:42:19 +02:00
|
|
|
fontStyle: 'normal',
|
2022-09-22 07:12:59 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
expect(JSON.parse($('#comp-with-fonts-roboto').text())).toEqual({
|
2022-09-27 20:10:05 +02:00
|
|
|
className: expect.stringMatching(/^__className_.{6}$/),
|
2022-09-22 07:12:59 +02:00
|
|
|
style: {
|
2022-10-28 00:25:57 +02:00
|
|
|
fontFamily: expect.stringMatching(
|
|
|
|
/^'__Roboto_.{6}', '__Roboto_Fallback_.{6}'$/
|
|
|
|
),
|
2022-09-22 07:12:59 +02:00
|
|
|
fontStyle: 'italic',
|
|
|
|
fontWeight: 100,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|
2022-09-22 21:49:02 +02:00
|
|
|
|
|
|
|
test('page with local fonts', async () => {
|
|
|
|
const html = await renderViaHTTP(next.url, '/with-local-fonts')
|
|
|
|
const $ = cheerio.load(html)
|
|
|
|
|
|
|
|
// _app.js
|
|
|
|
expect(JSON.parse($('#app-open-sans').text())).toEqual({
|
2022-09-28 21:19:52 +02:00
|
|
|
className: expect.stringMatching(/__className_.{6}/),
|
|
|
|
variable: expect.stringMatching(/__variable_.{6}/),
|
2022-09-22 21:49:02 +02:00
|
|
|
style: {
|
2022-10-28 00:25:57 +02:00
|
|
|
fontFamily: expect.stringMatching(
|
|
|
|
/^'__Open_Sans_.{6}', '__Open_Sans_Fallback_.{6}'$/
|
|
|
|
),
|
2022-10-20 19:42:19 +02:00
|
|
|
fontStyle: 'normal',
|
2022-09-22 21:49:02 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
// with-local-fonts.js
|
|
|
|
expect(JSON.parse($('#first-local-font').text())).toEqual({
|
2022-09-28 21:19:52 +02:00
|
|
|
className: expect.stringMatching(/__className_.{6}/),
|
2022-09-22 21:49:02 +02:00
|
|
|
style: {
|
2022-10-10 20:54:34 +02:00
|
|
|
fontFamily: expect.stringMatching(
|
|
|
|
/^'__Fraunces_.{6}', system-ui, '__Fraunces_Fallback_.{6}'$/
|
|
|
|
),
|
2022-09-22 21:49:02 +02:00
|
|
|
fontStyle: 'italic',
|
|
|
|
fontWeight: 100,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
expect(JSON.parse($('#second-local-font').text())).toEqual({
|
2022-09-28 21:19:52 +02:00
|
|
|
className: expect.stringMatching(/^__className_.{6}$/),
|
|
|
|
variable: expect.stringMatching(/^__variable_.{6}$/),
|
2022-09-22 21:49:02 +02:00
|
|
|
style: {
|
2022-09-28 21:19:52 +02:00
|
|
|
fontFamily: expect.stringMatching(
|
2022-10-10 20:54:34 +02:00
|
|
|
/^'__Indie_Flower_.{6}', '__Indie_Flower_Fallback_.{6}'$/
|
2022-09-28 21:19:52 +02:00
|
|
|
),
|
2022-09-22 21:49:02 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|
2022-09-22 07:12:59 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
describe('computed styles', () => {
|
|
|
|
test('page with fonts', async () => {
|
|
|
|
const browser = await webdriver(next.url, '/with-fonts')
|
|
|
|
|
|
|
|
// _app.js
|
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#app-open-sans")).fontFamily'
|
|
|
|
)
|
2022-10-28 00:25:57 +02:00
|
|
|
).toMatch(/^__Open_Sans_.{6}, __Open_Sans_Fallback_.{6}$/)
|
2022-09-22 07:12:59 +02:00
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#app-open-sans")).fontWeight'
|
|
|
|
)
|
|
|
|
).toBe('400')
|
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#app-open-sans")).fontStyle'
|
|
|
|
)
|
|
|
|
).toBe('normal')
|
|
|
|
|
|
|
|
// with-fonts.js
|
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#with-fonts-open-sans")).fontFamily'
|
|
|
|
)
|
2022-10-28 00:25:57 +02:00
|
|
|
).toMatch(/^__Open_Sans_.{6}, __Open_Sans_Fallback_.{6}$/)
|
2022-09-22 07:12:59 +02:00
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#with-fonts-open-sans")).fontWeight'
|
|
|
|
)
|
|
|
|
).toBe('400')
|
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#with-fonts-open-sans")).fontStyle'
|
|
|
|
)
|
|
|
|
).toBe('normal')
|
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#with-fonts-open-sans-style")).fontWeight'
|
|
|
|
)
|
|
|
|
).toBe('400')
|
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#with-fonts-open-sans-style")).fontStyle'
|
|
|
|
)
|
|
|
|
).toBe('normal')
|
|
|
|
|
|
|
|
// CompWithFonts.js
|
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#comp-with-fonts-inter")).fontFamily'
|
|
|
|
)
|
2022-10-28 00:25:57 +02:00
|
|
|
).toMatch(/^__Inter_.{6}, __Inter_Fallback_.{6}$/)
|
2022-09-22 07:12:59 +02:00
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#comp-with-fonts-inter")).fontWeight'
|
|
|
|
)
|
|
|
|
).toBe('900')
|
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#comp-with-fonts-inter")).fontStyle'
|
|
|
|
)
|
|
|
|
).toBe('normal')
|
|
|
|
|
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#comp-with-fonts-roboto")).fontFamily'
|
|
|
|
)
|
2022-10-28 00:25:57 +02:00
|
|
|
).toMatch(/^__Roboto_.{6}, __Roboto_Fallback_.{6}$/)
|
2022-09-22 07:12:59 +02:00
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#comp-with-fonts-roboto")).fontWeight'
|
|
|
|
)
|
|
|
|
).toBe('100')
|
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#comp-with-fonts-roboto")).fontStyle'
|
|
|
|
)
|
|
|
|
).toBe('italic')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('page using variables', async () => {
|
|
|
|
const browser = await webdriver(next.url, '/variables')
|
|
|
|
|
|
|
|
// Fira Code Variable
|
2022-10-28 00:25:57 +02:00
|
|
|
const firaCodeRegex = /^__Fira_Code_.{6}, __Fira_Code_Fallback_.{6}$/
|
2022-09-22 07:12:59 +02:00
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#variables-fira-code")).fontFamily'
|
|
|
|
)
|
2022-09-27 20:10:05 +02:00
|
|
|
).toMatch(firaCodeRegex)
|
2022-09-22 07:12:59 +02:00
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#without-variables-fira-code")).fontFamily'
|
|
|
|
)
|
2022-09-27 20:10:05 +02:00
|
|
|
).not.toMatch(firaCodeRegex)
|
2022-09-22 07:12:59 +02:00
|
|
|
|
|
|
|
// Roboto 100 Italic
|
2022-10-28 00:25:57 +02:00
|
|
|
const roboto100ItalicRegex = /^__Roboto_.{6}, __Roboto_Fallback_.{6}$/
|
2022-09-22 07:12:59 +02:00
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#variables-roboto-100-italic")).fontFamily'
|
|
|
|
)
|
2022-09-27 20:10:05 +02:00
|
|
|
).toMatch(roboto100ItalicRegex)
|
2022-09-22 07:12:59 +02:00
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#without-variables-roboto-100-italic")).fontFamily'
|
|
|
|
)
|
2022-09-27 20:10:05 +02:00
|
|
|
).not.toMatch(roboto100ItalicRegex)
|
2022-09-28 21:19:52 +02:00
|
|
|
|
|
|
|
// Local font
|
2022-10-10 20:54:34 +02:00
|
|
|
const localFontRegex = /^__Fraunces_.{6}, __Fraunces_Fallback_.{6}$/
|
2022-09-28 21:19:52 +02:00
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#variables-local-font")).fontFamily'
|
|
|
|
)
|
|
|
|
).toMatch(localFontRegex)
|
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#without-variables-local-font")).fontFamily'
|
|
|
|
)
|
|
|
|
).not.toMatch(localFontRegex)
|
2022-09-22 07:12:59 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
test('page using fallback fonts', async () => {
|
|
|
|
const browser = await webdriver(next.url, '/with-fallback')
|
|
|
|
|
|
|
|
// .className
|
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#with-fallback-fonts-classname")).fontFamily'
|
|
|
|
)
|
2022-10-28 00:25:57 +02:00
|
|
|
).toMatch(
|
|
|
|
/^__Open_Sans_.{6}, system-ui, Arial, __Open_Sans_Fallback_.{6}$/
|
|
|
|
)
|
2022-09-22 07:12:59 +02:00
|
|
|
|
|
|
|
// .style
|
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#with-fallback-fonts-style")).fontFamily'
|
|
|
|
)
|
2022-10-28 00:25:57 +02:00
|
|
|
).toMatch(
|
|
|
|
/^__Open_Sans_.{6}, system-ui, Arial, __Open_Sans_Fallback_.{6}$/
|
|
|
|
)
|
2022-09-22 07:12:59 +02:00
|
|
|
|
|
|
|
// .variable
|
|
|
|
expect(
|
|
|
|
await browser.eval(
|
|
|
|
'getComputedStyle(document.querySelector("#with-fallback-fonts-variable")).fontFamily'
|
|
|
|
)
|
2022-10-28 00:25:57 +02:00
|
|
|
).toMatch(
|
|
|
|
/^__Open_Sans_.{6}, system-ui, Arial, __Open_Sans_Fallback_.{6}$/
|
|
|
|
)
|
2022-09-22 07:12:59 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('preload', () => {
|
|
|
|
test('page with fonts', async () => {
|
|
|
|
const html = await renderViaHTTP(next.url, '/with-fonts')
|
|
|
|
const $ = cheerio.load(html)
|
|
|
|
|
|
|
|
// Preconnect
|
|
|
|
expect($('link[rel="preconnect"]').length).toBe(0)
|
|
|
|
|
|
|
|
expect($('link[as="font"]').length).toBe(2)
|
|
|
|
// From /_app
|
|
|
|
expect($('link[as="font"]').get(0).attribs).toEqual({
|
|
|
|
as: 'font',
|
|
|
|
crossorigin: 'anonymous',
|
2022-09-26 21:59:38 +02:00
|
|
|
href: '/_next/static/media/0812efcfaefec5ea.p.woff2',
|
2022-09-22 07:12:59 +02:00
|
|
|
rel: 'preload',
|
|
|
|
type: 'font/woff2',
|
|
|
|
})
|
|
|
|
expect($('link[as="font"]').get(1).attribs).toEqual({
|
|
|
|
as: 'font',
|
|
|
|
crossorigin: 'anonymous',
|
2022-10-24 07:21:38 +02:00
|
|
|
href: '/_next/static/media/675c25f648fd6a30.p.woff2',
|
2022-09-22 07:12:59 +02:00
|
|
|
rel: 'preload',
|
|
|
|
type: 'font/woff2',
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
test('page without fonts', async () => {
|
|
|
|
const html = await renderViaHTTP(next.url, '/without-fonts')
|
|
|
|
const $ = cheerio.load(html)
|
|
|
|
|
|
|
|
// Preconnect
|
|
|
|
expect($('link[rel="preconnect"]').length).toBe(0)
|
|
|
|
|
|
|
|
// From _app
|
|
|
|
expect($('link[as="font"]').length).toBe(1)
|
|
|
|
expect($('link[as="font"]').get(0).attribs).toEqual({
|
|
|
|
as: 'font',
|
|
|
|
crossorigin: 'anonymous',
|
2022-09-26 21:59:38 +02:00
|
|
|
href: '/_next/static/media/0812efcfaefec5ea.p.woff2',
|
2022-09-22 07:12:59 +02:00
|
|
|
rel: 'preload',
|
|
|
|
type: 'font/woff2',
|
|
|
|
})
|
|
|
|
})
|
2022-09-22 21:49:02 +02:00
|
|
|
|
|
|
|
test('page with local fonts', async () => {
|
|
|
|
const html = await renderViaHTTP(next.url, '/with-local-fonts')
|
|
|
|
const $ = cheerio.load(html)
|
|
|
|
|
|
|
|
// Preconnect
|
|
|
|
expect($('link[rel="preconnect"]').length).toBe(0)
|
|
|
|
|
|
|
|
// Preload
|
|
|
|
expect($('link[as="font"]').length).toBe(2)
|
|
|
|
// _app
|
|
|
|
expect($('link[as="font"]').get(0).attribs).toEqual({
|
|
|
|
as: 'font',
|
|
|
|
crossorigin: 'anonymous',
|
2022-09-26 21:59:38 +02:00
|
|
|
href: '/_next/static/media/0812efcfaefec5ea.p.woff2',
|
2022-09-22 21:49:02 +02:00
|
|
|
rel: 'preload',
|
|
|
|
type: 'font/woff2',
|
|
|
|
})
|
|
|
|
// with-local-fonts
|
|
|
|
expect($('link[as="font"]').get(1).attribs).toEqual({
|
|
|
|
as: 'font',
|
|
|
|
crossorigin: 'anonymous',
|
2022-10-10 20:54:34 +02:00
|
|
|
href: '/_next/static/media/ab6fdae82d1a8d92.p.woff2',
|
2022-09-22 21:49:02 +02:00
|
|
|
rel: 'preload',
|
|
|
|
type: 'font/woff2',
|
|
|
|
})
|
|
|
|
})
|
2022-09-22 07:12:59 +02:00
|
|
|
})
|
2022-10-10 20:54:34 +02:00
|
|
|
|
|
|
|
describe('Fallback fontfaces', () => {
|
|
|
|
describe('local', () => {
|
|
|
|
test('Indie flower', async () => {
|
|
|
|
const browser = await webdriver(next.url, '/with-local-fonts')
|
|
|
|
|
|
|
|
const ascentOverride = await browser.eval(
|
|
|
|
'Array.from(document.fonts.values()).find(font => font.family.includes("Indie_Flower_Fallback")).ascentOverride'
|
|
|
|
)
|
2022-10-24 22:47:19 +02:00
|
|
|
expect(ascentOverride).toBe('103.26%')
|
2022-10-10 20:54:34 +02:00
|
|
|
|
|
|
|
const descentOverride = await browser.eval(
|
|
|
|
'Array.from(document.fonts.values()).find(font => font.family.includes("Indie_Flower_Fallback")).descentOverride'
|
|
|
|
)
|
2022-10-24 22:47:19 +02:00
|
|
|
expect(descentOverride).toBe('51.94%')
|
2022-10-10 20:54:34 +02:00
|
|
|
|
|
|
|
const lineGapOverride = await browser.eval(
|
|
|
|
'Array.from(document.fonts.values()).find(font => font.family.includes("Indie_Flower_Fallback")).lineGapOverride'
|
|
|
|
)
|
|
|
|
expect(lineGapOverride).toBe('0%')
|
|
|
|
|
|
|
|
const sizeAdjust = await browser.eval(
|
|
|
|
'Array.from(document.fonts.values()).find(font => font.family.includes("Indie_Flower_Fallback")).sizeAdjust'
|
|
|
|
)
|
2022-10-24 22:47:19 +02:00
|
|
|
expect(sizeAdjust).toBe('94%')
|
2022-10-10 20:54:34 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
test('Fraunces', async () => {
|
|
|
|
const browser = await webdriver(next.url, '/with-local-fonts')
|
|
|
|
|
|
|
|
const ascentOverride = await browser.eval(
|
|
|
|
'Array.from(document.fonts.values()).find(font => font.family.includes("Fraunces_Fallback")).ascentOverride'
|
|
|
|
)
|
2022-10-24 22:47:19 +02:00
|
|
|
expect(ascentOverride).toBe('84.71%')
|
2022-10-10 20:54:34 +02:00
|
|
|
|
|
|
|
const descentOverride = await browser.eval(
|
|
|
|
'Array.from(document.fonts.values()).find(font => font.family.includes("Fraunces_Fallback")).descentOverride'
|
|
|
|
)
|
2022-10-24 22:47:19 +02:00
|
|
|
expect(descentOverride).toBe('22.09%')
|
2022-10-10 20:54:34 +02:00
|
|
|
|
|
|
|
const lineGapOverride = await browser.eval(
|
|
|
|
'Array.from(document.fonts.values()).find(font => font.family.includes("Fraunces_Fallback")).lineGapOverride'
|
|
|
|
)
|
|
|
|
expect(lineGapOverride).toBe('0%')
|
|
|
|
|
|
|
|
const sizeAdjust = await browser.eval(
|
|
|
|
'Array.from(document.fonts.values()).find(font => font.family.includes("Fraunces_Fallback")).sizeAdjust'
|
|
|
|
)
|
2022-10-24 22:47:19 +02:00
|
|
|
expect(sizeAdjust).toBe('115.45%')
|
2022-10-10 20:54:34 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('google', () => {
|
|
|
|
test('Indie flower', async () => {
|
|
|
|
const browser = await webdriver(next.url, '/with-google-fonts')
|
|
|
|
|
|
|
|
const ascentOverride = await browser.eval(
|
|
|
|
'Array.from(document.fonts.values()).find(font => font.family.includes("Indie_Flower_Fallback")).ascentOverride'
|
|
|
|
)
|
2022-10-24 22:47:19 +02:00
|
|
|
expect(ascentOverride).toBe('103.26%')
|
2022-10-10 20:54:34 +02:00
|
|
|
|
|
|
|
const descentOverride = await browser.eval(
|
|
|
|
'Array.from(document.fonts.values()).find(font => font.family.includes("Indie_Flower_Fallback")).descentOverride'
|
|
|
|
)
|
2022-10-24 22:47:19 +02:00
|
|
|
expect(descentOverride).toBe('51.94%')
|
2022-10-10 20:54:34 +02:00
|
|
|
|
|
|
|
const lineGapOverride = await browser.eval(
|
|
|
|
'Array.from(document.fonts.values()).find(font => font.family.includes("Indie_Flower_Fallback")).lineGapOverride'
|
|
|
|
)
|
|
|
|
expect(lineGapOverride).toBe('0%')
|
|
|
|
|
|
|
|
const sizeAdjust = await browser.eval(
|
|
|
|
'Array.from(document.fonts.values()).find(font => font.family.includes("Indie_Flower_Fallback")).sizeAdjust'
|
|
|
|
)
|
2022-10-24 22:47:19 +02:00
|
|
|
expect(sizeAdjust).toBe('94%')
|
2022-10-10 20:54:34 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
test('Fraunces', async () => {
|
|
|
|
const browser = await webdriver(next.url, '/with-google-fonts')
|
|
|
|
|
|
|
|
const ascentOverride = await browser.eval(
|
|
|
|
'Array.from(document.fonts.values()).find(font => font.family.includes("Fraunces_Fallback")).ascentOverride'
|
|
|
|
)
|
2022-10-24 22:47:19 +02:00
|
|
|
expect(ascentOverride).toBe('84.71%')
|
2022-10-10 20:54:34 +02:00
|
|
|
|
|
|
|
const descentOverride = await browser.eval(
|
|
|
|
'Array.from(document.fonts.values()).find(font => font.family.includes("Fraunces_Fallback")).descentOverride'
|
|
|
|
)
|
2022-10-24 22:47:19 +02:00
|
|
|
expect(descentOverride).toBe('22.09%')
|
2022-10-10 20:54:34 +02:00
|
|
|
|
|
|
|
const lineGapOverride = await browser.eval(
|
|
|
|
'Array.from(document.fonts.values()).find(font => font.family.includes("Fraunces_Fallback")).lineGapOverride'
|
|
|
|
)
|
|
|
|
expect(lineGapOverride).toBe('0%')
|
|
|
|
|
|
|
|
const sizeAdjust = await browser.eval(
|
|
|
|
'Array.from(document.fonts.values()).find(font => font.family.includes("Fraunces_Fallback")).sizeAdjust'
|
|
|
|
)
|
2022-10-24 22:47:19 +02:00
|
|
|
expect(sizeAdjust).toBe('115.45%')
|
2022-10-10 20:54:34 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2022-09-22 07:12:59 +02:00
|
|
|
})
|