From 449a06c85cf0f8d415b916f032ce238c396ea49e Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Apr 2024 09:43:30 +0200 Subject: [PATCH] feat: refs #6636 Added tests --- .../application/spec/getEnumValues.spec.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 loopback/common/methods/application/spec/getEnumValues.spec.js diff --git a/loopback/common/methods/application/spec/getEnumValues.spec.js b/loopback/common/methods/application/spec/getEnumValues.spec.js new file mode 100644 index 000000000..edb2e76f7 --- /dev/null +++ b/loopback/common/methods/application/spec/getEnumValues.spec.js @@ -0,0 +1,35 @@ +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; + } + }); +});