Unverified Commit e2d00827 authored by 조계진's avatar 조계진 Committed by GitHub

Refactor app dir metadata test (#66331)

### What?
Because `createMultiHtmlMatcher` does not use `await` keyword internally
and is not an async function, all `await` in front of the match function
returned from `createMultiHtmlMatcher` was removed in
`test/e2e/app-dir/metadata/metadata.test.ts`.

The JSDoc for `createMultiHtmlMatcher` was also modified.
Co-authored-by: 's avatarJiachi Liu <inbox@huozhi.im>
parent b5ab9abd
...@@ -76,13 +76,13 @@ describe('app dir - metadata', () => { ...@@ -76,13 +76,13 @@ describe('app dir - metadata', () => {
* @param queryKey - query key, e.g. 'property' * @param queryKey - query key, e.g. 'property'
* @param domAttributeField - dom attribute field, e.g. 'content' * @param domAttributeField - dom attribute field, e.g. 'content'
* @param expected - expected object, e.g. { description: 'my description' } * @param expected - expected object, e.g. { description: 'my description' }
* @returns {Promise<void>} - promise that resolves when the check is done * @returns {void} - void when the check is done
* *
* @example * @example
* *
* const $ = await next.render$('html') * const $ = await next.render$('html')
* const matchHtml = createMultiHtmlMatcher($) * const matchHtml = createMultiHtmlMatcher($)
* await matchHtml('meta', 'name', 'property', { * matchHtml('meta', 'name', 'property', {
* description: 'description', * description: 'description',
* og: 'og:description' * og: 'og:description'
* }) * })
...@@ -369,8 +369,7 @@ describe('app dir - metadata', () => { ...@@ -369,8 +369,7 @@ describe('app dir - metadata', () => {
it('should support robots tags', async () => { it('should support robots tags', async () => {
const $ = await next.render$('/robots') const $ = await next.render$('/robots')
const matchMultiDom = createMultiHtmlMatcher($) const matchMultiDom = createMultiHtmlMatcher($)
matchMultiDom('meta', 'name', 'content', {
await matchMultiDom('meta', 'name', 'content', {
robots: 'noindex, follow, nocache', robots: 'noindex, follow, nocache',
googlebot: googlebot:
'index, nofollow, noimageindex, max-video-preview:standard, max-image-preview:-1, max-snippet:-1', 'index, nofollow, noimageindex, max-video-preview:standard, max-image-preview:-1, max-snippet:-1',
...@@ -380,7 +379,7 @@ describe('app dir - metadata', () => { ...@@ -380,7 +379,7 @@ describe('app dir - metadata', () => {
it('should support verification tags', async () => { it('should support verification tags', async () => {
const $ = await next.render$('/verification') const $ = await next.render$('/verification')
const matchMultiDom = createMultiHtmlMatcher($) const matchMultiDom = createMultiHtmlMatcher($)
await matchMultiDom('meta', 'name', 'content', { matchMultiDom('meta', 'name', 'content', {
'google-site-verification': 'google', 'google-site-verification': 'google',
y_key: 'yahoo', y_key: 'yahoo',
'yandex-verification': 'yandex', 'yandex-verification': 'yandex',
...@@ -508,7 +507,7 @@ describe('app dir - metadata', () => { ...@@ -508,7 +507,7 @@ describe('app dir - metadata', () => {
const $ = await next.render$('/opengraph/static') const $ = await next.render$('/opengraph/static')
const match = createMultiHtmlMatcher($) const match = createMultiHtmlMatcher($)
await match('meta', 'property', 'content', { match('meta', 'property', 'content', {
'og:image:width': '114', 'og:image:width': '114',
'og:image:height': '114', 'og:image:height': '114',
'og:image:type': 'image/png', 'og:image:type': 'image/png',
...@@ -526,7 +525,7 @@ describe('app dir - metadata', () => { ...@@ -526,7 +525,7 @@ describe('app dir - metadata', () => {
), ),
}) })
await match('meta', 'name', 'content', { match('meta', 'name', 'content', {
'twitter:image': isNextDev 'twitter:image': isNextDev
? expect.stringMatching( ? expect.stringMatching(
/http:\/\/localhost:\d+\/opengraph\/static\/twitter-image/ /http:\/\/localhost:\d+\/opengraph\/static\/twitter-image/
...@@ -550,12 +549,12 @@ describe('app dir - metadata', () => { ...@@ -550,12 +549,12 @@ describe('app dir - metadata', () => {
const $ = await next.render$('/opengraph/static/override') const $ = await next.render$('/opengraph/static/override')
const match = createMultiHtmlMatcher($) const match = createMultiHtmlMatcher($)
await match('meta', 'property', 'content', { match('meta', 'property', 'content', {
'og:title': 'no-og-image', 'og:title': 'no-og-image',
'og:image': undefined, 'og:image': undefined,
}) })
await match('meta', 'name', 'content', { match('meta', 'name', 'content', {
'twitter:image': undefined, 'twitter:image': undefined,
'twitter:title': 'no-tw-image', 'twitter:title': 'no-tw-image',
}) })
...@@ -574,7 +573,7 @@ describe('app dir - metadata', () => { ...@@ -574,7 +573,7 @@ describe('app dir - metadata', () => {
// Should contain default metadata and noindex tag // Should contain default metadata and noindex tag
const matchHtml = createMultiHtmlMatcher($) const matchHtml = createMultiHtmlMatcher($)
expect($('meta[charset="utf-8"]').length).toBe(1) expect($('meta[charset="utf-8"]').length).toBe(1)
await matchHtml('meta', 'name', 'content', { matchHtml('meta', 'name', 'content', {
viewport: 'width=device-width, initial-scale=1', viewport: 'width=device-width, initial-scale=1',
robots: 'noindex', robots: 'noindex',
// not found metadata // not found metadata
...@@ -603,7 +602,7 @@ describe('app dir - metadata', () => { ...@@ -603,7 +602,7 @@ describe('app dir - metadata', () => {
// Should contain default metadata and noindex tag // Should contain default metadata and noindex tag
const matchHtml = createMultiHtmlMatcher($) const matchHtml = createMultiHtmlMatcher($)
expect($('meta[charset="utf-8"]').length).toBe(1) expect($('meta[charset="utf-8"]').length).toBe(1)
await matchHtml('meta', 'name', 'content', { matchHtml('meta', 'name', 'content', {
viewport: 'width=device-width, initial-scale=1', viewport: 'width=device-width, initial-scale=1',
robots: 'noindex', robots: 'noindex',
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment