diff --git a/test/client-unit/components/bhBarcoderScanner.spec.js b/test/client-unit/components/bhBarcoderScanner.spec.js index 500cf4fe70..8919fb9b9d 100644 --- a/test/client-unit/components/bhBarcoderScanner.spec.js +++ b/test/client-unit/components/bhBarcoderScanner.spec.js @@ -1,9 +1,8 @@ /* eslint no-unused-expressions:off */ /* global inject, expect, chai */ -describe('test/client-unit/components/bhBarcodeScanner', bhBarcodeScannerTests); +describe('test/client-unit/components/bhBarcodeScanner', () => { -function bhBarcodeScannerTests() { const template = ` @@ -143,4 +142,5 @@ function bhBarcodeScannerTests() { const span = find(element, '.text-danger'); expect(angular.element(span).attr('data-error')).to.equal('READ_ERROR'); }); -} + +}); diff --git a/test/client-unit/components/bhCardList.spec.js b/test/client-unit/components/bhCardList.spec.js index 01519eb39c..9893757699 100644 --- a/test/client-unit/components/bhCardList.spec.js +++ b/test/client-unit/components/bhCardList.spec.js @@ -1,8 +1,6 @@ /* eslint no-unused-expressions:off */ /* global inject expect */ -describe('test/client-unit/components/bhCardList', bhCardListTests); - -function bhCardListTests() { +describe('test/client-unit/components/bhCardList', () => { let $compile; let $rootScope; let $templateCache; @@ -172,4 +170,5 @@ function bhCardListTests() { firstCardTitle = find(firstCard, '[data-test-card-title]'); expect(firstCardTitle).to.contain.text('A: Test Card'); }); -} + +}); diff --git a/test/client-unit/components/bhCheckboxTree/bhCheckboxTree.spec.js b/test/client-unit/components/bhCheckboxTree/bhCheckboxTree.spec.js index 026208c18e..411baf808e 100644 --- a/test/client-unit/components/bhCheckboxTree/bhCheckboxTree.spec.js +++ b/test/client-unit/components/bhCheckboxTree/bhCheckboxTree.spec.js @@ -1,9 +1,8 @@ /* eslint no-unused-expressions:off */ /* global inject, expect, chai */ -describe('test/client-unit/components/bhCheckboxTree', bhCheckboxTree); +describe('test/client-unit/components/bhCheckboxTree', () => { -function bhCheckboxTree() { beforeEach(module( 'pascalprecht.translate', 'bhima.services', @@ -96,4 +95,5 @@ function bhCheckboxTree() { expect($scope.callback).to.have.been.called(); }); -} + +}); diff --git a/test/client-unit/components/bhDateEditor.spec.js b/test/client-unit/components/bhDateEditor.spec.js index 8ff9e50cb6..ba6d12d523 100644 --- a/test/client-unit/components/bhDateEditor.spec.js +++ b/test/client-unit/components/bhDateEditor.spec.js @@ -1,9 +1,8 @@ /* eslint no-unused-expressions:off */ /* global inject, expect, chai */ -describe('test/client-unit/components/bhDateEditor', bhDateEditorTests); +describe('test/client-unit/components/bhDateEditor', () => { -function bhDateEditorTests() { const template = ` @@ -25,7 +24,7 @@ function bhDateEditorTests() { 'bhima.constants', 'templates', 'bhima.mocks', - 'ui.router' + 'ui.router', )); let $scope; @@ -38,7 +37,7 @@ function bhDateEditorTests() { const enterpriseFiscalStartDate = '2015-01-01T00:00:00.000Z'; const futureDate = '2200-01-20'; - const invalidOldDate = '2001-01-20'; + // ??? const invalidOldDate = '2001-01-20'; // utility fns const find = (elm, selector) => elm[0].querySelector(selector); @@ -95,7 +94,6 @@ function bhDateEditorTests() { it('changing the date value should fire the onChange event', () => { const input = find(element, '[data-date-editor-input]'); - // make sure the input is not readonly clickOnCalendarButton(element); @@ -106,7 +104,6 @@ function bhDateEditorTests() { expect($scope.callback).to.have.been.called(); }); - it('Should not allow future date to be selected', () => { const input = find(element, '[data-date-editor-input]'); clickOnCalendarButton(element); @@ -138,7 +135,7 @@ function bhDateEditorTests() { }); describe('limit-min-fiscal flag', () => { - let fiscalLimitElement = ` + const fiscalLimitElement = ` `; let fiscalElement; @@ -151,4 +148,5 @@ function bhDateEditorTests() { expect(spy).to.have.been.called.exactly(1); }); }); -} + +}); diff --git a/test/client-unit/components/bhFilterToggle.spec.js b/test/client-unit/components/bhFilterToggle.spec.js index c9f5bd7760..7b240e5c09 100644 --- a/test/client-unit/components/bhFilterToggle.spec.js +++ b/test/client-unit/components/bhFilterToggle.spec.js @@ -1,8 +1,6 @@ /* eslint no-unused-expressions:off */ /* global inject, expect, chai */ -describe('test/client-unit/components/bhFilterToggle', bhFilterToggleTests); - -function bhFilterToggleTests() { +describe('test/client-unit/components/bhFilterToggle', () => { let $scope; let element; @@ -29,4 +27,5 @@ function bhFilterToggleTests() { angular.element(btn).click(); expect($scope.callback).to.have.been.called.once; }); -} + +}); diff --git a/test/client-unit/components/bhFindInvoice.spec.js b/test/client-unit/components/bhFindInvoice.spec.js index 92e1b071db..80d541413f 100644 --- a/test/client-unit/components/bhFindInvoice.spec.js +++ b/test/client-unit/components/bhFindInvoice.spec.js @@ -1,9 +1,8 @@ /* eslint no-unused-expressions:off */ /* global inject, expect, chai */ -describe('test/client-unit/components/bhFindInvoice', bhFindInvoiceTests); +describe('test/client-unit/components/bhFindInvoice', () => { -function bhFindInvoiceTests() { const patient = { uuid : '234c51ae-efcc-4238-98c6-f402bfb39866', reference : 'TPA17', @@ -206,4 +205,5 @@ function bhFindInvoiceTests() { btn.click(); $scope.$digest(); } -} + +}); diff --git a/test/client-unit/components/bhHiddenField.spec.js b/test/client-unit/components/bhHiddenField.spec.js index ef86a2c496..6b95c8ed16 100644 --- a/test/client-unit/components/bhHiddenField.spec.js +++ b/test/client-unit/components/bhHiddenField.spec.js @@ -1,9 +1,8 @@ /* eslint no-unused-expressions:off */ /* global inject, expect */ -describe('test/client-unit/components/bhHiddenField', bhHiddenFieldTests); +describe('test/client-unit/components/bhHiddenField', () => { -function bhHiddenFieldTests() { const template = `

TEST

@@ -70,4 +69,5 @@ function bhHiddenFieldTests() { transclusion = find(element, '[bh-hidden-field-transclude]'); expect(transclusion).not.to.exist; }); -} + +}); diff --git a/test/client-unit/components/bhModalNotify.spec.js b/test/client-unit/components/bhModalNotify.spec.js index f045c5bdfb..690ffb0e37 100644 --- a/test/client-unit/components/bhModalNotify.spec.js +++ b/test/client-unit/components/bhModalNotify.spec.js @@ -1,9 +1,8 @@ /* eslint no-unused-expressions:off */ /* global inject, expect */ -describe('test/client-unit/components/bhModalNotify', bhModalNotifyTests); +describe('test/client-unit/components/bhModalNotify', () => { -function bhModalNotifyTests() { const template = ` `; @@ -178,4 +177,5 @@ function bhModalNotifyTests() { const successComponentLoaded = find(dangerComponentAsked, '.notification-success'); expect(successComponentLoaded).to.equal(null); }); -} + +}); diff --git a/test/client-unit/services/StockService.spec.js b/test/client-unit/services/StockService.spec.js index 417d748da3..0525b3d9b9 100644 --- a/test/client-unit/services/StockService.spec.js +++ b/test/client-unit/services/StockService.spec.js @@ -1,8 +1,7 @@ /* global inject, expect */ -describe('test/client-unit/services/StockService', StockServiceTests); +describe('test/client-unit/services/StockService', () => { -function StockServiceTests() { // define modules beforeEach(module( 'bhima.services', diff --git a/test/integration/patientInvoice.js b/test/integration/patientInvoice.js index d2643bad64..1998752ab9 100644 --- a/test/integration/patientInvoice.js +++ b/test/integration/patientInvoice.js @@ -311,7 +311,6 @@ function InvoicingFeeScenario() { .catch(helpers.handler); }); - /* * This scenario tests that subsidies work properly. The simple subsidy will * absorb some of a patient's cost into a subsidy account. The API only diff --git a/test/integration/reports/finance/open_debtors.js b/test/integration/reports/finance/open_debtors.js index 2e7a5c8663..ed489115b0 100644 --- a/test/integration/reports/finance/open_debtors.js +++ b/test/integration/reports/finance/open_debtors.js @@ -1,4 +1,5 @@ const RenderingTests = require('../rendering'); + const target = '/reports/finance/debtors/open'; const options = { currencyId : 1, diff --git a/test/server-unit/bhMoment.spec.js b/test/server-unit/bhMoment.spec.js index 0bc65a225b..587ea6dcca 100644 --- a/test/server-unit/bhMoment.spec.js +++ b/test/server-unit/bhMoment.spec.js @@ -19,34 +19,30 @@ function evaluate(startDate, endDate, dateBhMoment) { expect(formated).to.deep.equal(expected); } -describe('test/server-unit', () => { - - describe('bhMoment', () => { - - it('#day() should return the start and stop dates of the given date', () => { - const startDate = '2019-08-24'; - const endDate = '2019-08-24'; - evaluate(startDate, endDate, date.day()); - }); - - it('#week() should return the start and stop dates of the week for the given date', () => { - const startDate = '2019-08-18'; - const endDate = '2019-08-24'; - evaluate(startDate, endDate, date.week()); - }); - - it('#month() should return the start and stop dates of the month for the given date', () => { - const startDate = '2019-08-01'; - const endDate = '2019-08-31'; - evaluate(startDate, endDate, date.month()); - }); - - it('#year() should return the start and stop dates of the year for the given date', () => { - const startDate = '2019-01-01'; - const endDate = '2019-12-31'; - evaluate(startDate, endDate, date.year()); - }); +describe('test/server-unit bhMoment', () => { + it('#day() should return the start and stop dates of the given date', () => { + const startDate = '2019-08-24'; + const endDate = '2019-08-24'; + evaluate(startDate, endDate, date.day()); + }); + + it('#week() should return the start and stop dates of the week for the given date', () => { + const startDate = '2019-08-18'; + const endDate = '2019-08-24'; + evaluate(startDate, endDate, date.week()); + }); + + it('#month() should return the start and stop dates of the month for the given date', () => { + const startDate = '2019-08-01'; + const endDate = '2019-08-31'; + evaluate(startDate, endDate, date.month()); + }); + + it('#year() should return the start and stop dates of the year for the given date', () => { + const startDate = '2019-01-01'; + const endDate = '2019-12-31'; + evaluate(startDate, endDate, date.year()); }); }); diff --git a/test/server-unit/csv.spec.js b/test/server-unit/csv.spec.js index 5321c0e4c9..cbf2ce8b07 100644 --- a/test/server-unit/csv.spec.js +++ b/test/server-unit/csv.spec.js @@ -1,67 +1,65 @@ const { expect } = require('chai'); const csv = require('../../server/lib/renderers/csv'); -context('test/server-unit', () => { - - describe('renderers/csv.js', () => { - - const data = [ - { id : 1, name : 'jniles', score : 12 }, - { id : 2, name : 'mbayopanda', score : 37 }, - { - id : 3, name : 'lomamech', dob : new Date(2019, 10, 3, 5, 2, 1), score : 18, - }, - { - id : 4, name : 'jeremielodi', dob : new Date(2010, 11, 6, 1, 2, 3), score : 72, - }, - ]; - - it('exposes render, extension, and headers properties', () => { - expect(csv.headers).to.be.a('object'); - expect(csv.render).to.be.a('function'); - expect(csv.extension).to.be.a('string'); - }); +describe('test/server-unit renderers/csv.js', () => { + + const data = [ + { id : 1, name : 'jniles', score : 12 }, + { id : 2, name : 'mbayopanda', score : 37 }, + { + id : 3, name : 'lomamech', dob : new Date(2019, 10, 3, 5, 2, 1), score : 18, + }, + { + id : 4, name : 'jeremielodi', dob : new Date(2010, 11, 6, 1, 2, 3), score : 72, + }, + ]; + + it('exposes render, extension, and headers properties', () => { + expect(csv.headers).to.be.a('object'); + expect(csv.render).to.be.a('function'); + expect(csv.extension).to.be.a('string'); + }); - it('#render() should return a known string output for known input', async () => { + it('#render() should return a known string output for known input', async () => { - const renderedRaw = await csv.render({ csv : data }); + const renderedRaw = await csv.render({ csv : data }); - // Remove BOM from rendered csv data (if present) - const rendered = renderedRaw.replace(/^\uFEFF/, ''); + // Remove BOM from rendered csv data (if present) + const rendered = renderedRaw.replace(/^\uFEFF/, ''); - const output = ` + const output = ` id,name,score,dob 1,jniles,12,undefined 2,mbayopanda,37,undefined 3,lomamech,18,03/11/2019 5:02:1 4,jeremielodi,72,06/12/2010 1:02:3`.trim(); - expect(rendered).to.equal(output); - }); + expect(rendered).to.equal(output); + }); - it('#render() uses options.csvKey to determine which array to process', async () => { - const otherData = [{ id : 3, check : true }]; - const renderedRaw = await csv.render({ rows : data, csv : otherData }, null, { csvKey : 'rows' }); + it('#render() uses options.csvKey to determine which array to process', async () => { + const otherData = [{ id : 3, check : true }]; + const renderedRaw = await csv.render({ rows : data, csv : otherData }, null, { csvKey : 'rows' }); - // Remove BOM from rendered csv data (if present) - const rendered = renderedRaw.replace(/^\uFEFF/, ''); + // Remove BOM from rendered csv data (if present) + const rendered = renderedRaw.replace(/^\uFEFF/, ''); - const output = ` + const output = ` id,name,score,dob 1,jniles,12,undefined 2,mbayopanda,37,undefined 3,lomamech,18,03/11/2019 5:02:1 4,jeremielodi,72,06/12/2010 1:02:3`.trim(); - expect(rendered).to.equal(output); - }); + expect(rendered).to.equal(output); + }); - it('#render() does not remove empty rows', async () => { - const cloned = [...data, {}]; - const renderedRaw = await csv.render({ csv : cloned }); - // Remove BOM from rendered csv data (if present) - const rendered = renderedRaw.replace(/^\uFEFF/, ''); - const output = ` + it('#render() does not remove empty rows', async () => { + const cloned = [...data, {}]; + const renderedRaw = await csv.render({ csv : cloned }); + // Remove BOM from rendered csv data (if present) + const rendered = renderedRaw.replace(/^\uFEFF/, ''); + const output = ` id,name,score,dob 1,jniles,12,undefined 2,mbayopanda,37,undefined @@ -69,35 +67,33 @@ id,name,score,dob 4,jeremielodi,72,06/12/2010 1:02:3 undefined,undefined,undefined,undefined`.trim(); - expect(rendered).to.equal(output); - }); + expect(rendered).to.equal(output); + }); - it('#render() should convert dates if dates are passed in by default', async () => { - const ds = [{ start : new Date(2019, 4, 2, 7, 2, 33) }]; - const renderedRaw = await csv.render({ csv : ds }); - // Remove BOM from rendered csv data (if present) - const rendered = renderedRaw.replace(/^\uFEFF/, ''); - const output = ` + it('#render() should convert dates if dates are passed in by default', async () => { + const ds = [{ start : new Date(2019, 4, 2, 7, 2, 33) }]; + const renderedRaw = await csv.render({ csv : ds }); + // Remove BOM from rendered csv data (if present) + const rendered = renderedRaw.replace(/^\uFEFF/, ''); + const output = ` start 02/05/2019 7:02:33`.trim(); - expect(rendered).to.equal(output); - }); + expect(rendered).to.equal(output); + }); - it('#render() should not convert dates if dates are passed with the suppressDefaultFormatting option', async () => { - const start = new Date(Date.UTC(2019, 2, 5, 7, 2, 33)); + it('#render() should not convert dates if dates are passed with the suppressDefaultFormatting option', async () => { + const start = new Date(Date.UTC(2019, 2, 5, 7, 2, 33)); - const ds = [{ start }]; - const renderedRaw = await csv.render({ csv : ds }, null, { suppressDefaultFormatting : true }); - // Remove BOM from rendered csv data (if present) - const rendered = renderedRaw.replace(/^\uFEFF/, ''); - const output = ` + const ds = [{ start }]; + const renderedRaw = await csv.render({ csv : ds }, null, { suppressDefaultFormatting : true }); + // Remove BOM from rendered csv data (if present) + const rendered = renderedRaw.replace(/^\uFEFF/, ''); + const output = ` start ${start.toString()}`.trim(); - expect(rendered).to.equal(output); - }); - + expect(rendered).to.equal(output); }); }); diff --git a/test/server-unit/dates.spec.js b/test/server-unit/dates.spec.js index 71c56dc3ee..3e6e8d2626 100644 --- a/test/server-unit/dates.spec.js +++ b/test/server-unit/dates.spec.js @@ -1,68 +1,64 @@ const { expect } = require('chai'); const dates = require('../../server/lib/template/helpers/dates'); -context('test/server-unit', () => { +describe('test/server-unit dates', () => { - describe('dates', () => { - - it('#date() should format a date is "DD/MM/YYYY" format.', () => { - const date = new Date('2015-03-25 12:00:00'); - const expected = '25/03/2015'; - const formated = dates.date(date); - expect(formated).to.equal(expected); - }); - - it('#date() should return an empty string ("") if the date is null.', () => { - const dat = null; - const expected = ''; - const formated = dates.date(dat); - expect(formated).to.equal(expected); - }); + it('#date() should format a date is "DD/MM/YYYY" format.', () => { + const date = new Date('2015-03-25 12:00:00'); + const expected = '25/03/2015'; + const formated = dates.date(date); + expect(formated).to.equal(expected); + }); - it('#date() should allow you to specify a custom format.', () => { - const dat = new Date('2015-03-25'); - const expected = '03/2015'; - const format = 'MM/YYYY'; - const formated = dates.date(dat, format); - expect(formated).to.equal(expected); - }); + it('#date() should return an empty string ("") if the date is null.', () => { + const dat = null; + const expected = ''; + const formated = dates.date(dat); + expect(formated).to.equal(expected); + }); - it('#timestamp() should return an empty string ("") if the date is null.', () => { - const dat = null; - const expected = ''; - const formated = dates.timestamp(dat); - expect(formated).to.deep.equal(expected); - }); + it('#date() should allow you to specify a custom format.', () => { + const dat = new Date('2015-03-25'); + const expected = '03/2015'; + const format = 'MM/YYYY'; + const formated = dates.date(dat, format); + expect(formated).to.equal(expected); + }); - it('#timestamp() should format a date as DD/MM/YYYY HH:mm:ss.', () => { - const dat = new Date('2015-03-25 10:05:15'); - const expected = '25/03/2015 10:05:15'; - const formated = dates.timestamp(dat); - expect(formated).to.equal(expected); - }); + it('#timestamp() should return an empty string ("") if the date is null.', () => { + const dat = null; + const expected = ''; + const formated = dates.timestamp(dat); + expect(formated).to.deep.equal(expected); + }); - it('#age() should return 0 for the current date.', () => { - const dat = new Date(); - const expected = 0; - const formated = dates.age(dat); - expect(formated).to.equal(expected); - }); + it('#timestamp() should format a date as DD/MM/YYYY HH:mm:ss.', () => { + const dat = new Date('2015-03-25 10:05:15'); + const expected = '25/03/2015 10:05:15'; + const formated = dates.timestamp(dat); + expect(formated).to.equal(expected); + }); - it('#age() should return 3 for the current date.', () => { - const current = new Date(); - const dob = new Date((current.getFullYear() - 3), current.getMonth()); - const formated = dates.age(dob); - const expected = 3; - expect(formated).to.equal(expected); - }); + it('#age() should return 0 for the current date.', () => { + const dat = new Date(); + const expected = 0; + const formated = dates.age(dat); + expect(formated).to.equal(expected); + }); - it('#month should return the full month name in English for a given month.', () => { - const dat = new Date('2015-03-25 10:05:15'); - const formated = dates.month(dat); - const expected = 'March'; - expect(formated).to.equal(expected); - }); + it('#age() should return 3 for the current date.', () => { + const current = new Date(); + const dob = new Date((current.getFullYear() - 3), current.getMonth()); + const formated = dates.age(dob); + const expected = 3; + expect(formated).to.equal(expected); + }); + it('#month should return the full month name in English for a given month.', () => { + const dat = new Date('2015-03-25 10:05:15'); + const formated = dates.month(dat); + const expected = 'March'; + expect(formated).to.equal(expected); }); }); diff --git a/test/server-unit/pdf.spec.js b/test/server-unit/pdf.spec.js index fefecbeea2..756911c4a0 100644 --- a/test/server-unit/pdf.spec.js +++ b/test/server-unit/pdf.spec.js @@ -61,7 +61,6 @@ describe('test/server-unit/PDF renderer', () => { }); - /** * hasValidPdfVersion * @description check if the pdf version is valid @@ -81,4 +80,3 @@ function hasValidPdfVersion(fileInString) { function isBufferInstance(file) { return file instanceof Buffer; } -