36 lines
982 B
JavaScript
36 lines
982 B
JavaScript
const models = require('vn-loopback/server/server').models;
|
|
|
|
describe('Application getEnumValues()', () => {
|
|
let tx;
|
|
|
|
beforeEach(async() => {
|
|
tx = await models.Application.beginTransaction({});
|
|
const options = {transaction: tx};
|
|
|
|
await models.Application.rawSql(`
|
|
CREATE TABLE tableWithEnum (
|
|
direction enum('in', 'out', 'middle'),
|
|
PRIMARY KEY (direction)
|
|
) ENGINE=InnoDB;
|
|
`, null, options);
|
|
});
|
|
|
|
it('should return three if is ok', async() => {
|
|
try {
|
|
const options = {transaction: tx};
|
|
const response = await models.Application.getEnumValues(
|
|
'vn',
|
|
'tableWithEnum',
|
|
'direction',
|
|
options
|
|
);
|
|
|
|
expect(response.length).toEqual(3);
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
});
|