Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Jude Agboola <marvinjudehk@gmail.com>
- Loading branch information
1 parent
6f0d46b
commit 19c9c0b
Showing
4 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
e2e-tests/production-runtime/cypress/integration/head-function-export/use-location.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,13 @@ | ||
import headFunctionExportSharedData from "../../../shared-data/head-function-export.js" | ||
|
||
it(`Page with Head Export that uses useLocation works`, () => { | ||
cy.visit(headFunctionExportSharedData.page.pageWithUseLocation).waitForRouteChange() | ||
|
||
cy.getTestElement(`location-pathname-in-template`) | ||
.invoke(`text`) | ||
.then(text => { | ||
cy.getTestElement(`location-pathname-in-head`) | ||
.invoke(`attr`, `content`) | ||
.should('equal', text) | ||
}) | ||
}) |
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
19 changes: 19 additions & 0 deletions
19
e2e-tests/production-runtime/src/pages/head-function-export/page-with-uselocation.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,19 @@ | ||
import * as React from "react" | ||
import { useLocation } from '@gatsbyjs/reach-router'; | ||
|
||
export default function HeadFunctionExportWithUseLocation() { | ||
const location = useLocation(); | ||
|
||
return ( | ||
<> | ||
<h1>I test that Head export with useLocation hook works</h1> | ||
<p data-testid="location-pathname-in-template">{location.pathname}</p> | ||
</> | ||
) | ||
} | ||
|
||
export function Head() { | ||
const location = useLocation(); | ||
|
||
return <meta data-testid="location-pathname-in-head" name="location" content={location.pathname}/> | ||
} |
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