forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hannes Bornö
committed
Feb 9, 2023
1 parent
1518021
commit b17ca83
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
packages/next-codemod/transforms/__testfixtures__/built-in-next-font/page.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
</> | ||
); | ||
} |
27 changes: 27 additions & 0 deletions
27
packages/next-codemod/transforms/__testfixtures__/built-in-next-font/page.output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
</> | ||
); | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/next-codemod/transforms/__tests__/built-in-next-font.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |