restore.test.ts 624 B

123456789101112131415161718192021
  1. import { DataTypes } from '@sequelize/core';
  2. import { expect } from 'chai';
  3. import { sequelize } from '../support';
  4. describe('Model#restore', () => {
  5. it('is disallowed if no primary key is present', async () => {
  6. const User = sequelize.define(
  7. 'User',
  8. {
  9. name: { type: DataTypes.STRING },
  10. },
  11. { noPrimaryKey: true, paranoid: true },
  12. );
  13. await User.sync({ force: true });
  14. const instance = User.build({}, { isNewRecord: false });
  15. await expect(instance.restore()).to.be.rejectedWith(
  16. 'but the model does not have a primary key attribute definition.',
  17. );
  18. });
  19. });