-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #139
- Loading branch information
Showing
19 changed files
with
700 additions
and
38 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { hexToRgbA } from './e2e-helper'; | ||
|
||
export const sizes = [ | ||
{ sizeKey: 'xxsmall', height: '96px' }, | ||
{ sizeKey: 'xsmall', height: '216px' }, | ||
{ sizeKey: 'small', height: '336px' }, | ||
{ sizeKey: 'medium', height: '456px' }, | ||
{ sizeKey: 'large', height: '576px' }, | ||
{ sizeKey: 'xlarge', height: '696px' }, | ||
{ sizeKey: 'xxlarge', height: '816px' }, | ||
]; | ||
|
||
export const colors = [ | ||
{ colorKey: 'primary', color: hexToRgbA('#8a7fff') }, | ||
{ colorKey: 'success', color: hexToRgbA('#40dc7e') }, | ||
{ colorKey: 'info', color: hexToRgbA('#4ca6ff') }, | ||
{ colorKey: 'warning', color: hexToRgbA('#ffa100') }, | ||
{ colorKey: 'danger', color: hexToRgbA('#ff4c6a') }, | ||
{ colorKey: 'default', color: hexToRgbA('#a4abb3') }, | ||
{ colorKey: 'disabled', color: 'rgba(255, 255, 255, 0.4)' }, | ||
]; |
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* @license | ||
* Copyright Akveo. All Rights Reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
import { browser, element, by, ExpectedConditions as ec } from 'protractor'; | ||
import { hexToRgbA } from './e2e-helper'; | ||
import { sizes } from './cards-shared'; | ||
|
||
const waitTime = 500; | ||
|
||
const cards = sizes.map((size, i) => ({ size, i })); | ||
|
||
describe('nb-flip-card', () => { | ||
beforeEach((done) => { | ||
browser.get('#/card-status').then(() => done()); | ||
}); | ||
|
||
cards.forEach(c => { | ||
describe(`${c.size.sizeKey} flip card`, () => { | ||
function shouldShowFrontCard () { | ||
const flipCard = element.all(by.tagName('nb-flip-card')).get(c.i); | ||
const frontCard = flipCard.all(by.tagName('.front-container')).first(); | ||
const backCard = flipCard.all(by.tagName('.back-container')).first(); | ||
|
||
expect(flipCard.getAttribute('class')).not.toContain('flipped', `flip card shouldn't be flipped`) | ||
expect(frontCard.isDisplayed()).toBe(true, 'front card should be visible'); | ||
} | ||
|
||
it(`should show front card`, shouldShowFrontCard); | ||
|
||
it(`should flip`, () => { | ||
const flipCard = element.all(by.tagName('nb-flip-card')).get(c.i); | ||
const frontCardFlipButton = flipCard.all(by.css('.flip-button')).first(); | ||
|
||
frontCardFlipButton.click().then(() => { | ||
expect(flipCard.getAttribute('class')).toContain('flipped', 'flip card should be flipped'); | ||
}); | ||
}); | ||
|
||
it(`should flip again`, () => { | ||
const flipCard = element.all(by.tagName('nb-flip-card')).get(c.i); | ||
const frontCardFlipButton = flipCard.all(by.css('.front-container .flip-button')).first(); | ||
const backCardFlipButton = flipCard.all(by.css('.back-container .flip-button')).first(); | ||
|
||
frontCardFlipButton.click() | ||
.then(() => { | ||
browser.sleep(waitTime); | ||
return backCardFlipButton.click() | ||
}) | ||
.then(() => { | ||
browser.sleep(waitTime); | ||
shouldShowFrontCard(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* @license | ||
* Copyright Akveo. All Rights Reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
import { browser, element, by, ExpectedConditions as ec } from 'protractor'; | ||
import { hexToRgbA } from './e2e-helper'; | ||
import { sizes } from './cards-shared'; | ||
import { protractor } from 'protractor/built/ptor'; | ||
|
||
function toInt(cssValue) { | ||
return parseInt(cssValue, 10); | ||
} | ||
|
||
const waitTime = 1000; | ||
|
||
const cards = sizes.map((size, i) => ({ | ||
size, | ||
i, | ||
})); | ||
|
||
describe('nb-reveal-card', () => { | ||
beforeEach((done) => { | ||
browser.get('#/card-status').then(() => done()); | ||
}); | ||
|
||
cards.forEach(c => { | ||
describe(`${c.size.sizeKey} reveal card`, () => { | ||
function showOnlyFrontCard () { | ||
const revealCard = element.all(by.tagName('nb-reveal-card')).get(c.i); | ||
const frontCard = revealCard.all(by.tagName('nb-card-front')).first(); | ||
const backCardContainer = revealCard.all(by.css('.second-card-container')).first(); | ||
|
||
protractor.promise.all([ | ||
backCardContainer.getCssValue('top'), | ||
revealCard.getCssValue('height'), | ||
revealCard.getCssValue('margin-bottom'), | ||
]).then(([ backCardTop, cardHeight, cardMargin ]) => { | ||
expect(revealCard.getAttribute('class')).not.toContain('revealed', `card shouldn't has 'revealed' class`); | ||
expect(frontCard.isDisplayed()).toBe(true, 'front card should be visible'); | ||
expect(toInt(backCardTop)).toEqual(toInt(cardHeight) - toInt(cardMargin), 'back card should be hidden'); | ||
}); | ||
} | ||
|
||
it(`should show only front card`, showOnlyFrontCard); | ||
|
||
it(`should reveal back card`, () => { | ||
const revealCard = element.all(by.tagName('nb-reveal-card')).get(c.i); | ||
const backCardContainer = revealCard.all(by.css('.second-card-container')).first(); | ||
const revealButton = revealCard.all(by.css('.reveal-button')).first(); | ||
|
||
revealButton.click().then(() => { | ||
expect(revealCard.getAttribute('class')).toContain('revealed', `card should has 'revealed' class`); | ||
backCardContainer | ||
.getCssValue('top') | ||
.then(top => expect(toInt(top)).toEqual(0, 'revealed card should be visible')); | ||
}); | ||
}); | ||
|
||
it(`should hide back card`, () => { | ||
const revealCard = element.all(by.tagName('nb-reveal-card')).get(c.i); | ||
const backCardContainer = revealCard.all(by.css('.second-card-container')).first(); | ||
const revealButton = revealCard.all(by.css('.reveal-button')).first(); | ||
|
||
revealButton.click() | ||
.then(() => revealButton.click()) | ||
.then(() => { | ||
browser.sleep(waitTime); | ||
showOnlyFrontCard(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.