Skip to content
Snippets Groups Projects
Commit 1c1da85f authored by Lehtinen Teemu's avatar Lehtinen Teemu
Browse files

Add button event test

parent cf234faa
No related branches found
No related tags found
No related merge requests found
let chai = require('chai');
chai.should();
function PointsContent(browser) {
let points = browser.$$('.guide-column .points');
points.should.have.lengthOf(1);
return {
text: points[0].getText(),
class: points[0].getAttribute('class'),
isZero: function () {
this.text.should.contain('0 / 10');
this.text.should.not.contain('10 / 10');
this.class.should.not.contain('yellow');
this.class.should.not.contain('green');
},
isInitial: function () {
this.isZero();
this.class.should.not.contain('red');
}
};
}
describe('Content module acos-webdev-inspector', () => {
describe('Frontpage block', () => {
......@@ -18,6 +37,32 @@ describe('Content module acos-webdev-inspector', () => {
});
describe('Exercise click_for_points', () => {
it('exercise page should open', () => {
browser.url('/html/webdev/webdev-inspector/fix_typo');
browser.waitUntil(() => $('.instructions').getText().length > 0, 4000, 'expected instructions to appear');
});
it('should start with zero grade', () => {
PointsContent(browser).isInitial();
});
it('should include button and click it', () => {
let button = browser.$$('.exercise button');
button.should.have.lengthOf(1);
button.click();
browser.waitUntil(() => $$('.explosion').length == 0, 4000, 'expected explosion effect to pass');
});
it('should now display full grade', () => {
let points = PointsContent(browser);
points.text.should.contain('10 / 10');
points.class.should.contain('green');
});
});
describe('Exercise fix_typo', () => {
it('exercise page should open', () => {
......@@ -25,10 +70,7 @@ describe('Content module acos-webdev-inspector', () => {
});
it('should start with zero grade', () => {
let points = browser.$$('.guide-column .points');
points.should.have.lengthOf(1);
points[0].getText().should.contain('0 / 10');
points[0].getText().should.not.contain('10 / 10');
PointsContent(browser).isInitial();
});
it('should include text paragraph', () => {
......@@ -45,11 +87,10 @@ describe('Content module acos-webdev-inspector', () => {
});
it('should now display half grade', () => {
let points = browser.$$('.guide-column .points');
points.should.have.lengthOf(1);
points[0].getText().should.contain('5 / 10');
points[0].getAttribute('class').should.contain('yellow');
points[0].getAttribute('class').should.not.contain('green');
let points = PointsContent(browser);
points.text.should.contain('5 / 10');
points.class.should.contain('yellow');
points.class.should.not.contain('green');
});
it('fix text', () => {
......@@ -60,11 +101,10 @@ describe('Content module acos-webdev-inspector', () => {
});
it('should now display full grade', () => {
let points = browser.$$('.guide-column .points');
points.should.have.lengthOf(1);
points[0].getText().should.contain('10 / 10');
points[0].getAttribute('class').should.contain('green');
points[0].getAttribute('class').should.not.contain('yellow');
let points = PointsContent(browser);
points.text.should.contain('10 / 10');
points.class.should.contain('green');
points.class.should.not.contain('yellow');
});
it('reset button should exist and be clicked', () => {
......@@ -80,11 +120,7 @@ describe('Content module acos-webdev-inspector', () => {
let p = browser.$$('.exercise p');
p.should.have.lengthOf(1);
p[0].getText().should.equal('Hello Wordl!');
let points = browser.$$('.guide-column .points');
points.should.have.lengthOf(1);
points[0].getText().should.contain('0 / 10');
points[0].getText().should.not.contain('10 / 10');
points[0].getAttribute('class').should.not.contain('green');
PointsContent(browser).isInitial();
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment