52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('node:assert/strict');
|
|
|
|
function createSequelizeTypes() {
|
|
const makeType = sql => ({
|
|
toSql() {
|
|
return sql;
|
|
},
|
|
});
|
|
|
|
return {
|
|
STRING: length => makeType(`VARCHAR(${length})`),
|
|
JSON: makeType('JSON'),
|
|
};
|
|
}
|
|
|
|
function createApp() {
|
|
return {
|
|
Sequelize: createSequelizeTypes(),
|
|
model: {
|
|
define(name, attributes, options) {
|
|
return {
|
|
name,
|
|
rawAttributes: attributes,
|
|
options,
|
|
};
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
describe('test/app/model/express.test.js', () => {
|
|
it('should define wms_express fields and table options', () => {
|
|
const app = createApp();
|
|
const Express = require('../../../app/model/express')(app);
|
|
|
|
assert.equal(Express.options.tableName, 'wms_express');
|
|
assert.equal(Express.options.freezeTableName, true);
|
|
assert.equal(Express.options.timestamps, false);
|
|
assert.equal(Express.options.underscored, true);
|
|
assert.equal(Express.options.paranoid, false);
|
|
|
|
assert.equal(Express.rawAttributes.code.primaryKey, true);
|
|
assert.equal(Express.rawAttributes.code.type.toSql(), 'VARCHAR(50)');
|
|
assert.equal(Express.rawAttributes.name.type.toSql(), 'VARCHAR(255)');
|
|
assert.equal(Express.rawAttributes.polyapi_code.type.toSql(), 'VARCHAR(255)');
|
|
assert.equal(Express.rawAttributes.polyapi_extra_info.type.toSql(), 'JSON');
|
|
assert.equal(Express.rawAttributes.pdd_code.type.toSql(), 'VARCHAR(255)');
|
|
});
|
|
});
|