P5-7496: orders tests (#3)

* P5-7495: added more db data and more designer tests

* P5-7496: rebuild for sql export, added better test control values

* changed order rows - edge from int to string

* added tests for designer order rows

* remove sql inserts

* Some cleanup and moving files

* package

* removed comments

* added base sql files to pass tests on github CI
This commit is contained in:
Arwid Thornström
2021-07-02 11:17:59 +02:00
committed by GitHub
parent 84d62c6b8a
commit c92482777d
44 changed files with 3965 additions and 62 deletions
+39
View File
@@ -0,0 +1,39 @@
import _ from 'lodash';
import { io, saveFromTemplate, padNum } from './common.js';
// INSERT INTO public.invoices (id, inserted, order_id, invoice_date, invoice_sent) VALUES (DEFAULT, '2019-06-12T16:16:50.784Z', 4, '2019-06-12', 1);
const keys = {
id: 'DEFAULT',
inserted: 'DEFAULT',
order_id: null,
invoice_date: '',
invoice_sent: '',
};
const inserts = [];
const N = 10;
for (const id of [...Array(N + 1).keys()].slice(1)) {
const now = new Date();
const key = Object.assign({}, keys, {
order_id: id,
invoice_date: `'${now.getFullYear()}-${padNum(now.getMonth())}-${padNum(
now.getDay(),
)}'`,
invoice_sent: io(),
});
const insertString = `INSERT INTO public.invoices (id, inserted, order_id, invoice_date, invoice_sent) VALUES (${Object.values(
key,
).join(', ')});`;
inserts.push(insertString);
}
saveFromTemplate(
'templates/invoices.sql',
'../db/data/invoices.sql',
'{x}',
inserts.join('\n'),
);