-
-
Notifications
You must be signed in to change notification settings - Fork 525
Expand file tree
/
Copy pathwrite.test.js
More file actions
62 lines (55 loc) · 1.64 KB
/
write.test.js
File metadata and controls
62 lines (55 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const fs = require('fs');
const { describe, before, after, it } = require('mocha');
const { expect } = require('chai');
const { AutoRelater } = require('../lib/auto-relater');
const { SequelizeAuto } = require('../lib/auto');
const buildTableData = require('./tabledata').buildRelatedTableData;
/** @type {string[]} */
let written = [];
/**
* @param {import("../src/types").TableData} tableData
* @param {import("../src/types").AutoOptions} options
* @returns {Promise<void>}
*/
function write(tableData, options) {
written = Object.keys(tableData.tables);
return Promise.resolve();
}
describe("sequelize-auto write", function() {
let td;
before(async function() {
td = buildTableData();
const options = {
// directory: './models',
additional: {},
dialect: 'mysql',
lang: 'ts',
caseModel: 'p',
caseFile: 'l',
caseProp: 'c',
singularize: false,
write,
}
// we've already done the build and relate steps, so we just need to write
let auto = new SequelizeAuto(null, null, null, options);
const tt = auto.generate(td);
td.text = tt;
await auto.write(td);
return td;
});
after(function() {
});
describe("should write the data", function() {
it("has written data", function() {
let has = written.length > 0;
expect(has).to.be.true;
});
it("has the models", function() {
const modelFiles = ['customer', 'order', 'order_item', 'other_tag', 'product', 'product_tag', 'related_product', 'supplier', 'tag'];
modelFiles.forEach(function(mf) {
let has = written.includes(mf);
expect(has).to.be.true;
});
});
});
});