forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom AMP Validator Variable Name Collision Fix (vercel#10371)
* Changing variable name internally * Add tests for custom AMP validator Co-authored-by: JJ Kasper <[email protected]>
- Loading branch information
Showing
5 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
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
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
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,7 @@ | ||
module.exports = { | ||
experimental: { | ||
amp: { | ||
validator: 'https://cdn.ampproject.org/v0/validator.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,5 @@ | ||
export const config = { | ||
amp: true, | ||
} | ||
|
||
export default () => <p>Hello from AMP</p> |
49 changes: 49 additions & 0 deletions
49
test/integration/amphtml-custom-validator/test/index.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,49 @@ | ||
/* eslint-env jest */ | ||
/* global jasmine */ | ||
import { join } from 'path' | ||
import { | ||
nextBuild, | ||
findPort, | ||
nextStart, | ||
killApp, | ||
launchApp, | ||
renderViaHTTP, | ||
} from 'next-test-utils' | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 1 | ||
|
||
let app | ||
let appPort | ||
const appDir = join(__dirname, '../') | ||
|
||
describe('AMP Custom Validator', () => { | ||
it('should build and start successfully', async () => { | ||
const { code } = await nextBuild(appDir) | ||
expect(code).toBe(0) | ||
|
||
appPort = await findPort() | ||
app = await nextStart(appDir, appPort) | ||
|
||
const html = await renderViaHTTP(appPort, '/') | ||
await killApp(app) | ||
|
||
expect(html).toContain('Hello from AMP') | ||
}) | ||
|
||
it('should run in dev mode successfully', async () => { | ||
let stderr = '' | ||
|
||
appPort = await findPort() | ||
app = await launchApp(appDir, appPort, { | ||
onStderr(msg) { | ||
stderr += msg || '' | ||
}, | ||
}) | ||
|
||
const html = await renderViaHTTP(appPort, '/') | ||
await killApp(app) | ||
|
||
expect(stderr).not.toContain('error') | ||
expect(html).toContain('Hello from AMP') | ||
}) | ||
}) |