dropEnum.test.js
1.42 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
'use strict';
const chai = require('chai');
const expect = chai.expect;
const Support = require('../support');
const DataTypes = require('../../../lib/data-types');
const dialect = Support.getTestDialect();
describe(Support.getTestDialectTeaser('QueryInterface'), () => {
beforeEach(function() {
this.sequelize.options.quoteIdenifiers = true;
this.queryInterface = this.sequelize.getQueryInterface();
});
afterEach(async function() {
await Support.dropTestSchemas(this.sequelize);
});
describe('dropEnum', () => {
beforeEach(async function() {
await this.queryInterface.createTable('menus', {
structuretype: DataTypes.ENUM('menus', 'submenu', 'routine'),
sequence: DataTypes.INTEGER,
name: DataTypes.STRING
});
});
if (dialect === 'postgres') {
it('should be able to drop the specified enum', async function() {
await this.queryInterface.removeColumn('menus', 'structuretype');
const enumList0 = await this.queryInterface.pgListEnums('menus');
expect(enumList0).to.have.lengthOf(1);
expect(enumList0[0]).to.have.property('enum_name').and.to.equal('enum_menus_structuretype');
await this.queryInterface.dropEnum('enum_menus_structuretype');
const enumList = await this.queryInterface.pgListEnums('menus');
expect(enumList).to.be.an('array');
expect(enumList).to.have.lengthOf(0);
});
}
});
});