Skip to content

Commit

Permalink
feat: made changes to unit test. Added to test to check gradient butt…
Browse files Browse the repository at this point in the history
…on for passed style, linear gradient.
  • Loading branch information
Amirah Chamble authored and Amirah Chamble committed Sep 11, 2018
1 parent 58e2ba1 commit 7610382
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 31 deletions.
2 changes: 2 additions & 0 deletions dev/views/Buttons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<div><ButtonDestructive>Button Destructive</ButtonDestructive></div>
<br>
<div><ButtonGradient :color-direction="colorDirection" :gradient-start="colorStart" :gradient-end="colorEnd" >Button Gradient</ButtonGradient></div>
<div><ButtonGradient >Button Gradient</ButtonGradient></div>

<br>


Expand Down
6 changes: 2 additions & 4 deletions src/components/ButtonGradient.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ export default Vue.extend({
},
computed:{
returnGradientStyle(): string {
const colorDirection = this.colorDirection === undefined? "to right" : this.colorDirection
const gradientStart = this.gradientStart === undefined? "#000000" : this.gradientStart
const gradientEnd = this.gradientEnd === undefined? "#000000" : this.gradientEnd
return `background-image: linear-gradient(${colorDirection}, ${gradientStart}, ${gradientEnd} );`
return `background-image: linear-gradient(${this.colorDirection}, ${this.gradientStart}, ${this.gradientEnd} );`
}
}
Expand Down
68 changes: 41 additions & 27 deletions tests/unit/Buttons.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,41 +185,55 @@ describe('Buttons', () => {
expect(base.classes()).to.include('ft-button--disabled')
})
})
})

describe('ButtonGradient',() =>{
describe('ButtonGradient',() =>{

it('Takes is required props and appropiate value', () => {
let props = { gradientStart: "#000" , gradientEnd: "#fff", colorDirection: "to right" }

let start = props.gradientStart
let end = props.gradientEnd
let direction = props.colorDirection
it('Takes is required props and appropiate value', () => {
let props = { gradientStart: "#000" , gradientEnd: "#fff", colorDirection: "to right" }

expect(start).to.be.eql("#000")
expect(start).to.include('#')
let start = props.gradientStart
let end = props.gradientEnd
let direction = props.colorDirection

expect(start).to.be.eql("#000")
expect(start).to.include('#')

expect(end).to.be.eql("#fff")
expect(end).to.include('#')

expect(end).to.be.eql("#fff")
expect(end).to.include('#')

expect(direction).to.include('to')
})
it('Undefined required props are undefined', () =>{
let props = { gradientStart: undefined , gradientEnd: undefined, colorDirection: "to right" }

let start = props.gradientStart
let end = props.gradientEnd
let direction = props.colorDirection
expect(direction).to.include('to')
})
it('Undefined required props are undefined', () =>{
let props = { gradientStart: undefined , gradientEnd: undefined, colorDirection: "to right" }

expect(start).to.be.eql(undefined)
let start = props.gradientStart
let end = props.gradientEnd
let direction = props.colorDirection

expect(start).to.be.eql(undefined)

expect(end).to.be.eql(undefined)

expect(end).to.be.eql(undefined)

expect(direction).to.include('to')
expect(direction).to.include('to')
})


})
describe(buttonName, () => {


it("Mounts gradient button and checks if it contains the background image style attribute with a linear gradient. " ,() =>{
let wrapper = mount(Button)
let gradientwrap = wrapper.find("a")
expect(gradientwrap. hasStyle("background-image", "linear-gradient(to right, rgb(0, 0, 0), rgb(0, 0, 0));"))

})


})

})





})

0 comments on commit 7610382

Please sign in to comment.