From dc0e6d5be23484e7f241f7f503b490e5c2dfa724 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Thu, 18 Jul 2019 17:38:12 -0500 Subject: [PATCH] Fix syntax error in ie11 from next-server/amp --- packages/next-server/amp.js | 4 ++-- test/integration/production/pages/some-amp.js | 11 +++++++++++ test/integration/production/test/index.test.js | 7 +++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 test/integration/production/pages/some-amp.js diff --git a/packages/next-server/amp.js b/packages/next-server/amp.js index 796d2be7cfdbb..af255285585dd 100644 --- a/packages/next-server/amp.js +++ b/packages/next-server/amp.js @@ -1,2 +1,2 @@ -const { useAmp } = require('./dist/lib/amp') -module.exports = { useAmp } +const amp = require('./dist/lib/amp') +module.exports = { useAmp: amp.useAmp } diff --git a/test/integration/production/pages/some-amp.js b/test/integration/production/pages/some-amp.js new file mode 100644 index 0000000000000..1d5e82525af1b --- /dev/null +++ b/test/integration/production/pages/some-amp.js @@ -0,0 +1,11 @@ +import { useAmp } from 'next/amp' + +if (typeof window !== 'undefined') { + window.addEventListener('error', () => { + document.querySelector('p').innerText('error') + }) +} + +export const config = { amp: 'hybrid' } + +export default () =>

{useAmp() ? 'AMP' : 'Not AMP'}

diff --git a/test/integration/production/test/index.test.js b/test/integration/production/test/index.test.js index c365905fa56c6..9f8ea2c0e272f 100644 --- a/test/integration/production/test/index.test.js +++ b/test/integration/production/test/index.test.js @@ -566,6 +566,13 @@ describe('Production Usage', () => { expect(text).toMatch(/some interesting title/) }) + it('should handle AMP correctly in IE', async () => { + const browser = await webdriver(appPort, '/some-amp') + await waitFor(1000) + const text = await browser.elementByCss('p').text() + expect(text).toBe('Not AMP') + }) + dynamicImportTests(context, (p, q) => renderViaHTTP(context.appPort, p, q)) processEnv(context)