-
-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: adding unit tests for layout component #1914
Changes from 6 commits
5f4fb69
36a2e61
29cab0a
dc937fc
e7dcab5
d937303
dd473c9
aa1b5f4
3ffd1ea
e3e69de
a03c7fe
0b9fbdf
c774e8e
c630acc
f145b6f
4df9259
9217f3a
925ac99
2722aee
3041803
877c24b
ef1cad9
a420118
dae79c7
341b810
2ce6a2b
b9453a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,41 @@ | ||
import { useContext } from 'react' | ||
import Head from 'next/head' | ||
import AppContext from '../context/AppContext' | ||
import ReactGA from 'react-ga' | ||
import TagManager from 'react-gtm-module' | ||
import { useContext, useEffect } from 'react'; | ||
import Head from 'next/head'; | ||
import AppContext from '../context/AppContext'; | ||
import ReactGA from 'react-ga'; | ||
import TagManager from 'react-gtm-module'; | ||
|
||
export default function HeadComponent({ | ||
title, | ||
description = 'Open source tools to easily build and maintain your event-driven architecture. All powered by the AsyncAPI specification, the industry standard for defining asynchronous APIs.', | ||
image = '/img/social/website-card.jpg', | ||
rssTitle = 'RSS Feed for AsyncAPI Initiative Blog', | ||
rssLink = '/rss.xml' | ||
rssLink = '/rss.xml', | ||
}) { | ||
const url = process.env.DEPLOY_PRIME_URL || process.env.DEPLOY_URL || "http://localhost:3000" | ||
const { path = '' } = useContext(AppContext) | ||
const permalink = `${url}${path}` | ||
let type = 'website' | ||
if (path.startsWith('/docs') || path.startsWith('/blog')) type = 'article' | ||
if (!image.startsWith('http') && !image.startsWith('https')) image = `${url}${image}` | ||
const permTitle = 'AsyncAPI Initiative for event-driven APIs' | ||
title = title ? `${title} | ${permTitle}` : permTitle | ||
const url = process.env.DEPLOY_PRIME_URL || process.env.DEPLOY_URL || 'http://localhost:3000'; | ||
const appContext = useContext(AppContext); | ||
const { path = '' } = appContext || {}; | ||
|
||
//enable google analytics | ||
if (typeof window !== 'undefined') { | ||
TagManager.initialize({gtmId: 'GTM-T58BTVQ'}) | ||
ReactGA.initialize('UA-109278936-1') | ||
ReactGA.pageview(window.location.pathname + window.location.search) | ||
const permalink = `${url}${path}`; | ||
let type = 'website'; | ||
|
||
if (path.startsWith('/docs') || path.startsWith('/blog')) { | ||
type = 'article'; | ||
} | ||
|
||
if (!image.startsWith('http') && !image.startsWith('https')) { | ||
image = `${url}${image}`; | ||
} | ||
|
||
const permTitle = 'AsyncAPI Initiative for event-driven APIs'; | ||
title = title ? `${title} | ${permTitle}` : permTitle; | ||
|
||
useEffect(() => { | ||
// Enable Google Analytics | ||
TagManager.initialize({ gtmId: 'GTM-T58BTVQ' }); | ||
ReactGA.initialize('UA-109278936-1'); | ||
ReactGA.pageview(window.location.pathname + window.location.search); | ||
}, []); | ||
|
||
return ( | ||
<Head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | ||
|
@@ -50,13 +59,13 @@ export default function HeadComponent({ | |
<meta itemProp="name" content={title} /> | ||
<meta itemProp="description" content={description} /> | ||
<meta itemProp="image" content={image} /> | ||
|
||
{/* Twitter Card data */} | ||
<meta name="twitter:card" value="summary_large_image" /> | ||
<meta name="twitter:card" content="summary_large_image" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed this to some error , resolved this to previous one since it is not needed now . |
||
<meta name="twitter:title" content={title} /> | ||
<meta name="twitter:description" content={description} /> | ||
<meta name="twitter:image" content={image} /> | ||
|
||
{/* Open Graph data */} | ||
<meta property="og:title" content={title} /> | ||
<meta property="og:type" content={type} /> | ||
|
@@ -66,5 +75,5 @@ export default function HeadComponent({ | |
|
||
<title>{title}</title> | ||
</Head> | ||
) | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export default function Column ({children}) { | ||
export default function Column({ children }) { | ||
return ( | ||
<div className="mb-4 md:mb-0 md:flex-1 md:mx-1"> | ||
<div className="mb-4 md:mb-0 md:flex-1 md:mx-1" data-testid="Column-div"> | ||
{children} | ||
</div> | ||
) | ||
); | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||
export default function Container ({ | ||||||
export default function Container({ | ||||||
children, | ||||||
fluid = false, | ||||||
flex = false, | ||||||
|
@@ -9,17 +9,32 @@ export default function Container ({ | |||||
className = '', | ||||||
as, | ||||||
}) { | ||||||
const commonClassNames = `${flex ? `${cssBreakingPoint === 'lg' ? 'lg:flex' : 'md:flex'}` : 'block'} ${flexReverse ? `${cssBreakingPoint === 'lg' ? 'lg:flex-row-reverse' : 'md:flex-row-reverse'}` : ''} ${className} ${padding}` | ||||||
const wideClassNames = `max-w-screen-xl ${commonClassNames}` | ||||||
const regularClassNames = `max-w-4xl ${commonClassNames}` | ||||||
const normalClassNames = `${wide ? wideClassNames : regularClassNames} mx-auto w-full` | ||||||
const fluidClassNames = `${commonClassNames}` | ||||||
const commonClassNames = `${ | ||||||
flex ? `${cssBreakingPoint === 'lg' ? 'lg:flex' : 'md:flex'}` : 'block' | ||||||
} ${ | ||||||
flexReverse | ||||||
? `${ | ||||||
cssBreakingPoint === 'lg' | ||||||
? 'lg:flex-row-reverse' | ||||||
: 'md:flex-row-reverse' | ||||||
}` | ||||||
: '' | ||||||
} ${className} ${padding}`; | ||||||
const wideClassNames = `max-w-screen-xl ${commonClassNames}`; | ||||||
const regularClassNames = `max-w-4xl ${commonClassNames}`; | ||||||
const normalClassNames = `${ | ||||||
wide ? wideClassNames : regularClassNames | ||||||
} mx-auto w-full`; | ||||||
const fluidClassNames = `${commonClassNames}`; | ||||||
|
||||||
const Tag = as || 'div'; | ||||||
|
||||||
return ( | ||||||
<Tag className={fluid ? fluidClassNames : normalClassNames}> | ||||||
<Tag | ||||||
className={fluid ? fluidClassNames : normalClassNames} | ||||||
data-testid="Container-div" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Applicable everywhere There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||
> | ||||||
{children} | ||||||
</Tag> | ||||||
) | ||||||
} | ||||||
); | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the functions, part of React Context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done