Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannes Bornö committed Feb 9, 2023
1 parent 1518021 commit b17ca83
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Oswald } from "@next/font/google";
import localFont1 from "@next/font/local";

const oswald = Oswald({ subsets: ["latin"] });
const myFont = localFont1({
src: "./my-font.woff2",
});

import { Inter } from "next/font/google";
import localFont2 from "next/font/local";

const inter = Inter({ subsets: ["latin"] });
const myOtherFont = localFont2({
src: "./my-other-font.woff2",
});

export default function WithFonts() {
return (
<>
<p className={oswald.className}>oswald</p>
<p className={myFont.className}>myFont</p>

<p className={inter.className}>inter</p>
<p className={myOtherFont.className}>myOtherFont</p>
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Oswald } from "next/font/google";
import localFont1 from "next/font/local";

const oswald = Oswald({ subsets: ["latin"] });
const myFont = localFont1({
src: "./my-font.woff2",
});

import { Inter } from "next/font/google";
import localFont2 from "next/font/local";

const inter = Inter({ subsets: ["latin"] });
const myOtherFont = localFont2({
src: "./my-other-font.woff2",
});

export default function WithFonts() {
return (
<>
<p className={oswald.className}>oswald</p>
<p className={myFont.className}>myFont</p>

<p className={inter.className}>inter</p>
<p className={myOtherFont.className}>myOtherFont</p>
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* global jest */
jest.autoMockOff()
const defineTest = require('jscodeshift/dist/testUtils').defineTest
const { readdirSync } = require('fs')
const { join } = require('path')

const fixtureDir = 'built-in-next-font'
const fixtureDirPath = join(__dirname, '..', '__testfixtures__', fixtureDir)
const fixtures = readdirSync(fixtureDirPath)
.filter(file => file.endsWith('.input.js'))
.map(file => file.replace('.input.js', ''))

for (const fixture of fixtures) {
const prefix = `${fixtureDir}/${fixture}`;
defineTest(__dirname, fixtureDir, null, prefix)
}

0 comments on commit b17ca83

Please sign in to comment.