import * as React from "react"
import { composeStories } from "@storybook/testing-react"
import { mount } from "@cypress/react"
import * as stories from "./Button.stories"
const { Default, Large, Small, Action, Disabled, Loading, WithLink } = composeStories(stories)
describe('Button tests', () => {
it('Default', () => {
mount()
cy.get('button').contains('Default Button').click()
})
it('Large', () => {
mount()
cy.get('button').should('have.class', 'h-14')
})
it('Small', () => {
mount()
cy.get('button').should('have.class', 'h-8')
})
it('Action', () => {
mount()
let alerted = ''
cy.on('window:alert', msg => alerted = msg)
cy.get('button').click().then(() => expect(alerted).to.match(/Clicked!/))
})
it('Disabled', () => {
mount()
cy.get('button').should('be.disabled')
})
it('Loading', () => {
mount()
cy.get('button').should('have.class', 'bg-base-3')
cy.get('button svg').should('have.class', 'icon-loading')
})
it('WithLink', () => {
mount()
cy.get('a').should('have.attr', 'href').and('include', 'google')
})
it('WithIcon', () => {
mount()
cy.get('button svg').should('have.class', 'icon-edit')
})
it('Variants', () => {
mount()
cy.get('button').should('have.class', 'bg-secondary')
mount()
cy.get('button').should('have.class', 'bg-inverted-2 text-on-primary')
mount()
cy.get('button').should('have.class', 'bg-secondary-dark text-base-1')
mount()
cy.get('button').should('have.class', 'bg-warning text-on-base')
mount()
cy.get('button').should('have.class', 'bg-danger text-base-1')
})
})