dropEnum.test.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. 'use strict';
  2. const chai = require('chai');
  3. const expect = chai.expect;
  4. const Support = require('../support');
  5. const { DataTypes } = require('@sequelize/core');
  6. const dialect = Support.getTestDialect();
  7. describe(Support.getTestDialectTeaser('QueryInterface'), () => {
  8. beforeEach(function () {
  9. this.queryInterface = this.sequelize.queryInterface;
  10. });
  11. describe('dropEnum', () => {
  12. beforeEach(async function () {
  13. await this.queryInterface.createTable('menus', {
  14. structuretype: DataTypes.ENUM('menus', 'submenu', 'routine'),
  15. sequence: DataTypes.INTEGER,
  16. name: DataTypes.STRING,
  17. });
  18. });
  19. if (dialect === 'postgres') {
  20. it('should be able to drop the specified enum', async function () {
  21. await this.queryInterface.removeColumn('menus', 'structuretype');
  22. const enumList0 = await this.queryInterface.pgListEnums('menus');
  23. expect(enumList0).to.have.lengthOf(1);
  24. expect(enumList0[0]).to.have.property('enum_name').and.to.equal('enum_menus_structuretype');
  25. await this.queryInterface.dropEnum('enum_menus_structuretype');
  26. const enumList = await this.queryInterface.pgListEnums('menus');
  27. expect(enumList).to.be.an('array');
  28. expect(enumList).to.have.lengthOf(0);
  29. });
  30. }
  31. });
  32. });