Skip to content
Permalink
Browse files
Move header instantiation to base page
This way, all page objects have access to it without the need for
code duplication.
  • Loading branch information
Walmyr Filho committed May 28, 2020
1 parent 36ae57e commit 6a30a77648c83aa4ee7b31199593e93ebfd072df
Showing 5 changed files with 6 additions and 8 deletions.
@@ -1,4 +1,10 @@
const HeaderComponent = require('./components/header')

class Base {
constructor () {
this.header = new HeaderComponent()
}

visit () {
browser.get(this.relativeUrl)
}
@@ -1,14 +1,12 @@
const BasePage = require('./base')

const HeaderComponent = require('./components/header')
const DestinationComponent = require('./components/destination')

const randomNumberBewtweenOneAnd = require('../utils/randomNumberBewtweenOneAndN')

class Destination extends BasePage {
constructor () {
super()
this.header = new HeaderComponent()
this.self = new DestinationComponent()
this.relativeUrl = `/destinations/${randomNumberBewtweenOneAnd(15)}`
}
@@ -1,6 +1,5 @@
const BasePage = require('./base')

const HeaderComponent = require('./components/header')
const DestinationComponent = require('./components/destination')
const FormComponent = require('./components/form')

@@ -9,7 +8,6 @@ const randomNumberBewtweenOneAnd = require('../utils/randomNumberBewtweenOneAndN
class EditDestination extends BasePage {
constructor () {
super()
this.header = new HeaderComponent()
this.self = new DestinationComponent()
this.form = new FormComponent()
this.relativeUrl = `/destinations/${randomNumberBewtweenOneAnd(15)}/edit`
@@ -1,12 +1,10 @@
const BasePage = require('./base')

const HeaderComponent = require('./components/header')
const TagsComponent = require('./components/tags')

class Home extends BasePage {
constructor () {
super()
this.header = new HeaderComponent()
this.tags = new TagsComponent()
this.relativeUrl = '/'
}
@@ -1,14 +1,12 @@
const BasePage = require('./base')

const HeaderComponent = require('./components/header')
const DestinationsComponent = require('./components/destinations')

const randomNumberBewtweenOneAnd = require('../utils/randomNumberBewtweenOneAndN')

class Tag extends BasePage {
constructor () {
super()
this.header = new HeaderComponent()
this.destinations = new DestinationsComponent()
this.relativeUrl = `/tags/${randomNumberBewtweenOneAnd(5)}`
}

0 comments on commit 6a30a77

Please sign in to comment.