Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannes Bornö committed Nov 9, 2022
1 parent 9367591 commit cc66d81
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
11 changes: 11 additions & 0 deletions test/e2e/app-dir/rsc-external.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('app dir - rsc external dependency', () => {
next = await createNext({
files: new FileRef(path.join(__dirname, './rsc-external')),
dependencies: {
'@next/font': 'canary',
react: 'latest',
'react-dom': 'latest',
swr: '2.0.0-rc.0',
Expand Down Expand Up @@ -155,4 +156,14 @@ describe('app dir - rsc external dependency', () => {
)
).toBe('rgb(255, 0, 0)')
})

it('should handle external @next/font', async () => {
const browser = await webdriver(next.url, '/font')

expect(
await browser.eval(
`window.getComputedStyle(document.querySelector('p')).fontFamily`
)
).toMatch(/^__myFont_.{6}, __myFont_Fallback_.{6}$/)
})
})
5 changes: 5 additions & 0 deletions test/e2e/app-dir/rsc-external/app/font/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { myFont } from 'font'

export default function Page() {
return <p className={myFont.className}>Hello world</p>
}
2 changes: 1 addition & 1 deletion test/e2e/app-dir/rsc-external/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module.exports = {
experimental: {
appDir: true,
serverComponentsExternalPackages: ['conditional-exports-optout'],
transpilePackages: ['untranspiled-module', 'css'],
transpilePackages: ['untranspiled-module', 'css', 'font'],
},
}
3 changes: 3 additions & 0 deletions test/e2e/app-dir/rsc-external/node_modules_bak/font/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import localFont from '@next/font/local'

export const myFont = localFont({ src: './my-font.woff2' })
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "font",
"main": "index.ts"
}

0 comments on commit cc66d81

Please sign in to comment.