-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1c348c
commit 4888693
Showing
1 changed file
with
37 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,39 @@ | ||
'use strict'; | ||
|
||
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', () => { | ||
expect(header) | ||
.toBeInstanceOf(Header); | ||
}); | ||
|
||
it('should contain a logo element', () => { | ||
expect(header.logo) | ||
.toBe(logo); | ||
}); | ||
}); | ||
|
||
describe('PageObject class', () => { | ||
it('should create an instance of PageObject', () => { | ||
expect(page) | ||
.toBeInstanceOf(PageObject); | ||
}); | ||
|
||
it('should contain a url property', () => { | ||
expect(page.url) | ||
.toBe(url); | ||
}); | ||
|
||
it('should contain a header element as an instanse of Header', () => { | ||
expect(page.header) | ||
.toBeInstanceOf(Header); | ||
}); | ||
|
||
it('should contain a "clickOnLogo" method', () => { | ||
expect(page.clickOnLogo()) | ||
.toBe(`Click on the ${page.header.logo}`); | ||
}); | ||
}); | ||
|
||
describe('ArticlePage class', () => { | ||
it('should create an instance of ArticlePage', () => { | ||
expect(articlePage) | ||
.toBeInstanceOf(ArticlePage); | ||
}); | ||
|
||
it('should extend the PageObject class', () => { | ||
expect(articlePage) | ||
.toBeInstanceOf(PageObject); | ||
|
||
expect(articlePage.url).toBe(url + slug); | ||
}); | ||
|
||
it('should contain a "url" property contatenated with slug', () => { | ||
expect(articlePage.url) | ||
.toBe(url + slug); | ||
}); | ||
|
||
it('should contain a "commentButton" property', () => { | ||
expect(articlePage.commentButton) | ||
.toBe(`[Publish comment] button`); | ||
}); | ||
|
||
it('should contain a "clickOnCommentButton" method', () => { | ||
expect(articlePage.clickOnCommentButton()) | ||
.toBe(`Click on the ${articlePage.commentButton}`); | ||
}); | ||
|
||
it('should contain a "assertPageOpened" method', () => { | ||
expect(articlePage.assertPageOpened()) | ||
.toBe(`The ${articlePage.url} is opened`); | ||
}); | ||
}); | ||
class Header { | ||
get logo() { | ||
return 'Conduit logo'; | ||
} | ||
}; | ||
|
||
class PageObject { | ||
constructor(url) { | ||
this.url = url; | ||
this.header = new Header(); | ||
} | ||
clickOnLogo() { | ||
return 'Click on the ' + this.header.logo; | ||
} | ||
}; | ||
|
||
class ArticlePage extends PageObject { | ||
constructor(url, slug) { | ||
super(url + slug); | ||
this.slug = slug; | ||
} | ||
get commentButton() { | ||
return '[Publish comment] button'; | ||
} | ||
clickOnCommentButton() { | ||
return 'Click on the ' + this.commentButton; | ||
} | ||
assertPageOpened() { | ||
return 'The ' + this.url + ' is opened'; | ||
} | ||
}; | ||
|
||
module.exports = { | ||
Header, | ||
PageObject, | ||
ArticlePage, | ||
}; |