Skip to content

Commit

Permalink
added test to check concatenation url with slug
Browse files Browse the repository at this point in the history
  • Loading branch information
djtyrf312 committed Jan 19, 2024
1 parent ec5d615 commit 0189593
Showing 1 changed file with 24 additions and 32 deletions.
56 changes: 24 additions & 32 deletions src/pageObject.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,77 @@

const { Header, PageObject, ArticlePage } = require('./pageObject');

const logo = 'Conduit logo';
const url = 'http://test.com';
const slug = '/article';
const header = new Header();
const page = new PageObject(url);
const articlePage = new ArticlePage(url, slug);

describe('Header class', () => {
it('should create an instance of Header', () => {
const header = new Header();

expect(header)
.toBeInstanceOf(Header);
});

it('should contain a logo element', () => {
const header = new Header();

expect(header.logo)
.toBe('Conduit logo');
.toBe(logo);
});
});

describe('PageObject class', () => {
it('should create an instance of PageObject', () => {
const page = new PageObject('http://test.com');

expect(page)
.toBeInstanceOf(PageObject);
});

it('should contain a url property', () => {
const page = new PageObject('http://test.com');

expect(page.url)
.toBe('http://test.com');
.toBe(url);
});

it('should contain a header element as an instanse of Header', () => {
const page = new PageObject('http://test.com');

expect(page.header)
.toBeInstanceOf(Header);
});

it('should contain a "clickOnLogo" method', () => {
const page = new PageObject('http://test.com');

expect(page.clickOnLogo())
.toBe(`Click on the ${page.header.logo}`);
});
});

describe('ArticlePage class', () => {
it('should create an instance of ArticlePage', () => {
const page = new ArticlePage('http://test.com', '/test-slug');

expect(page)
expect(articlePage)
.toBeInstanceOf(ArticlePage);
});

it('should extend the PageObject class', () => {
const page = new ArticlePage('http://test.com', '/test-slug');

expect(page)
expect(articlePage)
.toBeInstanceOf(PageObject);

expect(articlePage.url).toBe(url + slug);
});

it('should contain a "commentButton" property', () => {
const page = new ArticlePage('http://test.com', '/test');
it('should contain a "url" property contatenated with slug', () => {
expect(articlePage.url)
.toBe(url + slug);
});

expect(page.commentButton)
it('should contain a "commentButton" property', () => {
expect(articlePage.commentButton)
.toBe(`[Publish comment] button`);
});

it('should contain a "clickOnCommentButton" method', () => {
const page = new ArticlePage('http://test.com', '/test');

expect(page.clickOnCommentButton())
.toBe(`Click on the ${page.commentButton}`);
expect(articlePage.clickOnCommentButton())
.toBe(`Click on the ${articlePage.commentButton}`);
});

it('should contain a "assertPageOpened" method', () => {
const page = new ArticlePage('http://test.com', '/test');

expect(page.assertPageOpened())
.toBe(`The ${page.url} is opened`);
expect(articlePage.assertPageOpened())
.toBe(`The ${articlePage.url} is opened`);
});
});
});

0 comments on commit 0189593

Please sign in to comment.