From 2f64f0f5fa1e72d568a5b0faaf91018a85b492d8 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 14 Sep 2017 19:07:30 +0530 Subject: [PATCH] Fixed salary structure tests --- .../salary_structure/test_salary_structure.js | 67 +++++++++---------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/erpnext/hr/doctype/salary_structure/test_salary_structure.js b/erpnext/hr/doctype/salary_structure/test_salary_structure.js index bdc766214c..040bc11f96 100644 --- a/erpnext/hr/doctype/salary_structure/test_salary_structure.js +++ b/erpnext/hr/doctype/salary_structure/test_salary_structure.js @@ -1,18 +1,18 @@ QUnit.test("test Salary Structure", function(assert) { - assert.expect(6); + assert.expect(12); let done = assert.async(); let employee_name1; - let salary_structure = (ename1,ename2) => { - frappe.run_serially([ - () => frappe.db.get_value('Employee', {'employee_name': ename1}, 'name'), + frappe.run_serially([ + () => frappe.db.get_value('Employee', {'employee_name': "Test Employee 1"}, 'name', (r) => { - employee_name1 = r.message.name; - }, - () => frappe.db.get_value('Employee', {'employee_name': ename2}, 'name'), + employee_name1 = r.name; + } + ), + () => frappe.db.get_value('Employee', {'employee_name': "Test Employee 3"}, 'name', (r) => { // Creating Salary Structure for employees); - frappe.tests.make('Salary Structure', [ + return frappe.tests.make('Salary Structure', [ { company: 'For Testing'}, { payroll_frequency: 'Monthly'}, { employees: [ @@ -22,7 +22,7 @@ QUnit.test("test Salary Structure", function(assert) { {base: 25000} ], [ - {employee: r.message.name}, + {employee: r.name}, {from_date: '2017-07-01'}, {base: 30000} ] @@ -45,37 +45,34 @@ QUnit.test("test Salary Structure", function(assert) { ]}, { payment_account: 'CASH - FT'}, ]); - }, - () => frappe.timeout(12), - () => cur_dialog.set_value('value','Test Salary Structure'), - () => frappe.timeout(2), - () => frappe.click_button('Create'), - () => { - // To check if all the fields are correctly set - assert.ok(cur_frm.doc.employees[0].employee_name.includes('Test Employee 1') && - cur_frm.doc.employees[1].employee_name.includes('Test Employee 3'), - 'Employee names are correctly set'); + } + ), + () => frappe.timeout(18), + () => cur_dialog.set_value('value','Test Salary Structure'), + () => frappe.timeout(1), + () => frappe.click_button('Create'), + () => frappe.timeout(1), + () => { + // To check if all the fields are correctly set + assert.ok(cur_frm.doc.employees[0].employee_name.includes('Test Employee 1') && + cur_frm.doc.employees[1].employee_name.includes('Test Employee 3'), + 'Employee names are correctly set'); - assert.ok(cur_frm.doc.employees[0].base==25000, - 'Base value for first employee is correctly set'); + assert.ok(cur_frm.doc.employees[0].base==25000, + 'Base value for first employee is correctly set'); - assert.ok(cur_frm.doc.employees[1].base==30000, - 'Base value for second employee is correctly set'); + assert.ok(cur_frm.doc.employees[1].base==30000, + 'Base value for second employee is correctly set'); - assert.ok(cur_frm.doc.earnings[0].formula.includes('base * .80'), - 'Formula for earnings as Basic is correctly set'); + assert.ok(cur_frm.doc.earnings[0].formula.includes('base * .80'), + 'Formula for earnings as Basic is correctly set'); - assert.ok(cur_frm.doc.earnings[1].formula.includes('B * .20'), - 'Formula for earnings as Leave Encashment is correctly set'); + assert.ok(cur_frm.doc.earnings[1].formula.includes('B * .20'), + 'Formula for earnings as Leave Encashment is correctly set'); - assert.ok(cur_frm.doc.deductions[0].formula.includes('(B+LE) * .20'), - 'Formula for deductions as Income Tax is correctly set'); - }, - ]); - }; - frappe.run_serially([ - () => salary_structure('Test Employee 1','Test Employee 3'), - () => frappe.timeout(16), + assert.ok(cur_frm.doc.deductions[0].formula.includes('(B+LE) * .20'), + 'Formula for deductions as Income Tax is correctly set'); + }, () => done() ]); });