chore: add expect to eslintrc

This commit is contained in:
Mangesh-Khairnar 2019-03-26 16:59:34 +05:30
parent 0608c6b956
commit cb47502fb9
4 changed files with 35 additions and 33 deletions

View file

@ -137,6 +137,7 @@
"Cypress": true, "Cypress": true,
"cy": true, "cy": true,
"it": true, "it": true,
"expect": true,
"context": true, "context": true,
"before": true, "before": true,
"beforeEach": true "beforeEach": true

View file

@ -1,37 +1,38 @@
context('Rating Control', () => { context('Rating Control', () => {
beforeEach(() => { beforeEach(() => {
cy.login('Administrator', 'qwe'); cy.login('Administrator', 'qwe');
}); });
it('click on the star rating to record value', () => { it('click on the star rating to record value', () => {
cy.visit('/desk') cy.visit('/desk')
cy.dialog('Rating', { cy.dialog('Rating', {
'fieldname': 'rate', 'fieldtype': 'Rating', 'fieldname': 'rate',
}).as('dialog'); 'fieldtype': 'Rating',
}).as('dialog');
cy.get('div.rating') cy.get('div.rating')
.children('i.fa') .children('i.fa')
.first() .first()
.click() .click()
.should('have.class', 'star-click'); .should('have.class', 'star-click');
cy.get('@dialog').then(dialog => { cy.get('@dialog').then(dialog => {
var value = dialog.get_value('rate'); var value = dialog.get_value('rate');
expect(value).to.equal(1) expect(value).to.equal(1);
}) })
}); });
it('hover on the star', () => {
cy.visit('/desk')
cy.dialog('Rating', {
'fieldname': 'rate', 'fieldtype': 'Rating',
})
cy.get('div.rating')
.children('i.fa')
.first()
.invoke('trigger', 'mouseenter')
.should('have.class', 'star-hover')
.invoke('trigger', 'mouseleave')
.should('not.have.class', 'star-hover');
});
it('hover on the star', () => {
cy.visit('/desk')
cy.dialog('Rating', {
'fieldname': 'rate',
'fieldtype': 'Rating',
})
cy.get('div.rating')
.children('i.fa')
.first()
.invoke('trigger', 'mouseenter')
.should('have.class', 'star-hover')
.invoke('trigger', 'mouseleave')
.should('not.have.class', 'star-hover');
});
}); });

View file

@ -74,6 +74,6 @@ Cypress.Commands.add('dialog', (title, fields) => {
} }
}); });
d.show(); d.show();
return d return d;
}); });
}); });

View file

@ -52,12 +52,12 @@ frappe.form.formatters = {
Percent: function(value, docfield, options) { Percent: function(value, docfield, options) {
return frappe.form.formatters._right(flt(value, 2) + "%", options) return frappe.form.formatters._right(flt(value, 2) + "%", options)
}, },
Rating: function(value, docfield, options, doc) { Rating: function(value, docfield, options) {
return ` return `
<div class="rating"> <div class="rating">
${Array.from(new Array(5)).map((_, i) => ${Array.from(new Array(5)).map((_, i) =>
`<i class="fa fa-fw fa-star ${i < (value || 0) ? "star-click": "" } star-icon" data-idx="${(i+1)}"></i>` `<i class="fa fa-fw fa-star ${i < (value || 0) ? "star-click": "" } star-icon" data-idx="${(i+1)}"></i>`
).join('')} ).join('')}
</div> </div>
`; `;
}, },