-
-
Notifications
You must be signed in to change notification settings - Fork 725
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into add-maya-as-codeowner
- Loading branch information
Showing
22 changed files
with
424 additions
and
67 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
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
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,22 @@ | ||
import React from 'react'; | ||
import { mount } from 'cypress/react'; | ||
import ApplyJobButton from '../../../components/buttons/ApplyJob'; | ||
|
||
describe('ApplyJobButton', () => { | ||
const job = { | ||
contact: 'https://www.asyncapi.com/', | ||
}; | ||
|
||
beforeEach(() => { | ||
mount(<ApplyJobButton job={job} />); | ||
}); | ||
|
||
it('renders the ApplyJobButton component', () => { | ||
cy.contains('Apply for this job').should('exist'); | ||
}); | ||
|
||
it('sets the correct href and target attributes', () => { | ||
cy.get('[data-testid="Button-link"]').should('have.attr', 'href', 'https://www.asyncapi.com/'); | ||
cy.get('[data-testid="Button-link"]').should('have.attr', 'target', '_blank'); | ||
}); | ||
}); |
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,64 @@ | ||
import React from 'react'; | ||
import { mount } from 'cypress/react'; | ||
import Button from '../../../components/buttons/Button'; | ||
import IconGithub from '../../../components/icons/Github' | ||
describe('Button component', () => { | ||
it('renders a button without href', () => { | ||
const text = 'Click me'; | ||
const type = 'button'; | ||
const icon = <IconGithub />; | ||
mount( | ||
<Button text={text} type={type} icon={icon} /> | ||
); | ||
cy.get('[data-testid="Button-main"]').should('have.text', text); | ||
cy.get('[data-testid="Button-main"]').should('have.attr', 'type', type); | ||
cy.get('[data-testid="Button-link"]').should('not.exist'); | ||
}); | ||
|
||
it('renders a button with href', () => { | ||
const text = 'Click me'; | ||
const href = '/link'; | ||
const target = '_blank'; | ||
mount( | ||
<Button text={text} href={href} target={target} /> | ||
); | ||
cy.get('[data-testid="Button-link"]').should('have.text', text); | ||
cy.get('[data-testid="Button-link"]').should('have.attr', 'href', href); | ||
cy.get('[data-testid="Button-link"]').should('have.attr', 'target', target); | ||
cy.get('[data-testid="Button-main"]').should('not.exist'); | ||
}); | ||
|
||
it('renders a small button', () => { | ||
const text = 'Click me'; | ||
const buttonSize = 'small'; | ||
mount( | ||
<Button text={text} buttonSize={buttonSize} /> | ||
); | ||
cy.get('[data-testid="Button-main"]').should('have.class', 'px-3 py-2 text-sm'); | ||
}); | ||
it('renders a button with custom class', () => { | ||
const text = 'Click me'; | ||
const className = 'custom-button'; | ||
|
||
mount( | ||
<Button text={text} className={className} /> | ||
); | ||
cy.get('[data-testid="Button-main"]').should('have.class', className); | ||
}); | ||
|
||
it('does not render an icon with position left in the button', () => { | ||
const text = 'Click me'; | ||
mount( | ||
<Button text={text} /> | ||
); | ||
cy.get('[data-testid="Button-icon-left"]').should('not.exist'); | ||
}); | ||
|
||
it('does not render an icon with position left in the button', () => { | ||
const text = 'Click me'; | ||
mount( | ||
<Button text={text} /> | ||
); | ||
cy.get('[data-testid="Button-icon-right"]').should('not.exist'); | ||
}); | ||
}); |
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,40 @@ | ||
import React from 'react'; | ||
import { mount } from 'cypress/react'; | ||
import ChapterSuggestion from '../../../components/buttons/ChapterSuggestion'; | ||
describe('ChapterSuggestion', () => { | ||
const chapter = { | ||
href: 'https://www.asyncapi.com/', | ||
target: '_self', | ||
title: 'Chapter Title', | ||
description: 'Chapter Description', | ||
linkText: 'Read More', | ||
className: 'custom-class', | ||
}; | ||
beforeEach(() => { | ||
mount(<ChapterSuggestion {...chapter} />); | ||
}); | ||
|
||
it('renders the ChapterSuggestion component', () => { | ||
cy.contains(chapter.title).should('exist'); | ||
cy.contains(chapter.description).should('exist'); | ||
cy.contains(chapter.linkText).should('exist'); | ||
cy.get('[data-testid="ChapterSuggestion-link"]').should('have.attr', 'href', chapter.href); | ||
}); | ||
|
||
it('applies the correct className', () => { | ||
cy.get('[data-testid="ChapterSuggestion-link"]').should('have.class', chapter.className); | ||
}); | ||
|
||
it('sets the target attribute', () => { | ||
cy.get('[data-testid="ChapterSuggestion-link"]').should('have.attr', 'target', chapter.target); | ||
}); | ||
|
||
it('sets the title attribute', () => { | ||
cy.get('[data-testid="ChapterSuggestion-link"]').should('have.attr', 'title', chapter.description); | ||
}); | ||
|
||
it('renders the link text and IconArrowRight', () => { | ||
cy.contains(chapter.linkText).should('exist'); | ||
cy.get('svg').should('have.class', 'h-4'); | ||
}); | ||
}); |
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,32 @@ | ||
import {mount} from 'cypress/react'; | ||
import DocsButton from '../../../components/buttons/DocsButton'; | ||
describe('DocsButton', () => { | ||
|
||
it('does not render buttons without post data', () => { | ||
mount(<DocsButton />); | ||
cy.get('[data-testid="DocsButton-div"]').should('not.exist'); | ||
cy.get('[data-testid="DocsButton-PrevPage"]').should('not.exist'); | ||
cy.get('[data-testid="DocsButton-div"]').should('not.exist'); | ||
cy.get('[data-testid="DocsButton-NextPage"]').should('not.exist'); | ||
}); | ||
|
||
it('renders correctly with post data', () => { | ||
// mock post object with dummy data | ||
const post = { | ||
prevPage: { | ||
href: 'https://www.asyncapi.com/', | ||
title: 'Previous Page', | ||
}, | ||
nextPage: { | ||
href: 'https://www.asyncapi.com/', | ||
title: 'Next Page', | ||
}, | ||
}; | ||
mount(<DocsButton post={post} />); | ||
cy.get('[data-testid="DocsButton-Prevdiv"]').should('contain', 'Go Back'); | ||
cy.get('[data-testid="DocsButton-PrevPage"]').should('contain', 'Previous Page'); | ||
cy.get('[data-testid="DocsButton-Nextdiv"]').should('contain', 'Up Next'); | ||
cy.get('[data-testid="DocsButton-NextPage"]').should('contain', 'Next Page'); | ||
}); | ||
}); | ||
|
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,27 @@ | ||
import {mount} from 'cypress/react'; | ||
import GithubButton from '../../../components/buttons/GithubButton' | ||
describe('GithubButton', () => { | ||
it('renders correctly with default props', () => { | ||
mount(<GithubButton />); | ||
cy.contains('View on Github').should('be.visible'); | ||
cy.get('[ data-testid="Button-link"]').should('have.attr', 'href', 'https://github.com/asyncapi'); | ||
cy.get('[ data-testid="Button-link"]').should('have.attr', 'target', '_blank'); | ||
}); | ||
|
||
it('renders correctly with custom props', () => { | ||
mount( | ||
<GithubButton | ||
text="Custom Text" | ||
href="https://example.com" | ||
target="_self" | ||
iconPosition="right" | ||
className="custom-class" | ||
inNav="true" | ||
/> | ||
); | ||
cy.contains('Custom Text').should('be.visible'); | ||
cy.get('[data-testid="Button-link"]').should('have.attr', 'href', 'https://example.com'); | ||
cy.get('[data-testid="Button-link"]').should('have.attr', 'target', '_self'); | ||
}); | ||
}); | ||
|
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 {mount} from 'cypress/react' | ||
import GitHubIssue from '../../../components/buttons/GitHubIssue'; | ||
describe('GitHubIssue', () => { | ||
it('renders correctly with default props', () => { | ||
mount(<GitHubIssue />); | ||
cy.contains('Create Issue on GitHub').should('be.visible'); | ||
cy.get('[data-testid="GithubIssue-Link"]') | ||
.should('have.attr', 'href', 'https://github.com/asyncapi/website/issues/new?assignees=alequetzalli+-&labels=%F0%9F%93%91+docs&template=docs.yml&title=%5B%F0%9F%93%91+Docs%5D%3A+') | ||
.should('have.attr', 'target', '_blank') | ||
.should('have.attr', 'rel', 'noopener noreferrer'); | ||
}); | ||
|
||
it('renders correctly with custom class', () => { | ||
mount(<GitHubIssue className="custom-class" />); | ||
//data-testid was not working here | ||
cy.get('.bg-black').should('have.class', 'custom-class'); | ||
}); | ||
}); | ||
|
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,24 @@ | ||
import {mount} from 'cypress/react' | ||
import GoogleCalendarButton from '../../../components/buttons/GoogleCalendarButton' | ||
describe('GoogleCalendarButton', () => { | ||
it('renders correctly with default props', () => { | ||
mount(<GoogleCalendarButton />); | ||
cy.contains('Add to Google Calendar').should('be.visible'); | ||
}); | ||
|
||
it('renders correctly with custom props', () => { | ||
mount( | ||
<GoogleCalendarButton | ||
text="Custom Text" | ||
href="https://example.com" | ||
target="_self" | ||
iconPosition="right" | ||
className="custom-class" | ||
/> | ||
); | ||
cy.contains('Custom Text').should('be.visible'); | ||
cy.get('[data-testid="Button-link"]').should('have.attr', 'href', 'https://example.com').and('have.attr', 'target', '_self'); | ||
}); | ||
}); | ||
|
||
|
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,26 @@ | ||
import { mount } from 'cypress/react'; | ||
import ICSFButton from '../../../components/buttons/ICSFileButton'; | ||
|
||
describe('ICSFButton', () => { | ||
|
||
it('renders correctly with custom props', () => { | ||
const customHref = 'https://example.com'; | ||
|
||
mount( | ||
< ICSFButton | ||
text="Custom Text" | ||
href={customHref} | ||
target="_self" | ||
iconPosition="right" | ||
/> | ||
); | ||
cy.contains('Custom Text').should('be.visible'); | ||
cy.get('[data-testid="Button-link"]').should('have.attr', 'href', customHref); | ||
cy.get('[data-testid="Button-link"]').should('have.attr', 'target', '_self'); | ||
}); | ||
|
||
it('renders correctly with default props', () => { | ||
mount(<ICSFButton />); | ||
cy.contains('Download ICS File').should('be.visible'); | ||
}); | ||
}); |
Oops, something went wrong.