Coder Social home page Coder Social logo

code-challenge-cypress's Introduction

Code Challenge Using Cypress

Automated test cases to remove unwanted whitespace from a string and to check the given string is palindrome or not using cypress.

Test cases to remove unwanted whitespace from a string

  • Assert the value entered should not be empty.

  • Assert the value entered should contains extra whitespace anywhere.

  • Assert that the entered value should not have extra whitespace before.

  • Assert that the entered value should not have extra whitespace after.

  • Assert that the entered value should not have extra whitespace within.

  • Assert that the entered value should not have extra whitespace before, after and within.

  • Assert that the entered value should not have any whitespace before, after and within.

remove_whitespace_spec.js

    describe('To remove unwanted whitespave from the string ', () => {
        beforeEach(() => {
            cy.visit('/');
            cy.get('[data-cy=checkInput]').as('inputValue');
            cy.get('[data-cy=removeWhitespace]').as('removeWhitespace');
            cy.get('[data-cy=removeAllWhitespace]').as('removeAllWhitespace');
            cy.get('[data-cy=result]').as('result');
        });

        it('Assert the value entered should not be empty', () => {
            cy.get('@removeWhitespace').click();
            cy.get('@result')
                .should('have.class','error')
                .invoke('text')
                .should('be.equal', 'The value should not be empty');
        });

        it('Assert the value entered should contains extra whitespace anywhere', () => {
            cy.get('@inputValue').type('string');
            cy.get('@removeWhitespace').click();
            cy.get('@result')
                .should('have.class','error')
                .invoke('text')
                .should('be.equal', 'The entered value doesn't have any whitespace');
        });
        ----------
        -------
    })

Test cases to check the given string is palindrome or not

  • Assert the value entered should not be empty.

  • Assert that the entered value is palindrome, if correctly matched.

  • Assert that the entered value is not a palindrome, if correctly matched but doesn't matched the case.

  • Assert that the entered value is not a palindrome, if wrongly matched.

  • Assert that the entered value is palindrome, if numbers/special characters matched correctly.

check_palindrome_spec.js

    describe('To check whether the entered string is palindrome or not', () => {
        beforeEach(() => {
            cy.visit('/');
            cy.get('[data-cy=checkInputPalindrome]').as('inputValue');
            cy.get('[data-cy=checkPalindrome]').as('checkPalindrome');
            cy.get('[data-cy=resultPalindrome]').as('result');
        });

        it('Assert the value entered should not be empty', () => {
            cy.get('@checkPalindrome').click();
            cy.get('@result')
                .should('have.class','error')
                .invoke('text')
                .should('be.equal', 'The value should not be empty');
        })

        it('Assert that the entered value is palindrome, if correctly matched', () => {
            cy.get('@inputValue').type('madam');
            cy.get('@checkPalindrome').click();
            cy.get('@result')
                .should('have.class','success')
                .invoke('text')
                .should('be.equal', '"madam" is a palindrome');
        })
        ----------
        -------
    )}

Built With

code-challenge-cypress's People

Contributors

kaviarasurajamanickam avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.