/
remove-attribute.test.js
39 lines (29 loc) · 1.04 KB
/
remove-attribute.test.js
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
'use strict';
const chai = require('chai');
const expect = chai.expect;
const Support = require('../support');
const current = Support.sequelize;
const _ = require('lodash');
const DataTypes = require('sequelize/lib/data-types');
describe(Support.getTestDialectTeaser('Model'), () => {
describe('removeAttribute', () => {
it('should support removing the primary key', () => {
const Model = current.define('m', {
name: DataTypes.STRING,
});
expect(Model.primaryKeyAttribute).not.to.be.undefined;
expect(_.size(Model.primaryKeys)).to.equal(1);
Model.removeAttribute('id');
expect(Model.primaryKeyAttribute).to.be.undefined;
expect(_.size(Model.primaryKeys)).to.equal(0);
});
it('should not add undefined attribute after removing primary key', () => {
const Model = current.define('m', {
name: DataTypes.STRING,
});
Model.removeAttribute('id');
const instance = Model.build();
expect(instance.dataValues).not.to.include.keys('undefined');
});
});
});