dropEnum.test.js
1.67 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
'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(function() {
return Support.dropTestSchemas(this.sequelize);
});
describe('dropEnum', () => {
beforeEach(function() {
return this.queryInterface.createTable('menus', {
structuretype: {
type: DataTypes.ENUM('menus', 'submenu', 'routine'),
allowNull: true
},
sequence: {
type: DataTypes.INTEGER,
allowNull: true
},
name: {
type: DataTypes.STRING,
allowNull: true
}
});
});
if (dialect === 'postgres') {
it('should be able to drop the specified enum', function() {
return this.queryInterface.removeColumn('menus', 'structuretype').then(() => {
return this.queryInterface.pgListEnums('menus');
}).then(enumList => {
expect(enumList).to.have.lengthOf(1);
expect(enumList[0]).to.have.property('enum_name').and.to.equal('enum_menus_structuretype');
}).then(() => {
return this.queryInterface.dropEnum('enum_menus_structuretype');
}).then(() => {
return this.queryInterface.pgListEnums('menus');
}).then(enumList => {
expect(enumList).to.be.an('array');
expect(enumList).to.have.lengthOf(0);
});
});
}
});
});