check.test.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { DataTypes } from '@sequelize/core';
  2. import {
  3. defaultValueSchemable,
  4. isWhereEmpty,
  5. } from '@sequelize/core/_non-semver-use-at-your-own-risk_/utils/query-builder-utils.js';
  6. import { expect } from 'chai';
  7. import { allowDeprecationsInSuite, sequelize } from '../../support';
  8. const dialect = sequelize.dialect;
  9. describe('utils / check', () => {
  10. describe('defaultValueSchemable', () => {
  11. allowDeprecationsInSuite(['SEQUELIZE0026']);
  12. it('should return false if the value is a NOW', () => {
  13. expect(defaultValueSchemable(DataTypes.NOW, dialect)).to.equal(false);
  14. expect(defaultValueSchemable(DataTypes.NOW(), dialect)).to.equal(false);
  15. });
  16. it('should return false if the value is a UUIDV1', () => {
  17. expect(defaultValueSchemable(DataTypes.UUIDV1, dialect)).to.equal(false);
  18. expect(defaultValueSchemable(DataTypes.UUIDV1(), dialect)).to.equal(false);
  19. });
  20. it('should return false if the value is a UUIDV4', () => {
  21. expect(defaultValueSchemable(DataTypes.UUIDV4, dialect)).to.equal(false);
  22. expect(defaultValueSchemable(DataTypes.UUIDV4(), dialect)).to.equal(false);
  23. });
  24. it('should return true otherwise', () => {
  25. expect(defaultValueSchemable('hello', dialect)).to.equal(true);
  26. expect(defaultValueSchemable(DataTypes.INTEGER(), dialect)).to.equal(true);
  27. });
  28. });
  29. describe('isWhereEmpty', () => {
  30. it('should return true if the where is empty', () => {
  31. expect(isWhereEmpty({})).to.equal(true);
  32. });
  33. it('should return false if the where is not empty', () => {
  34. expect(isWhereEmpty({ a: 1 })).to.equal(false);
  35. });
  36. it('should return false even if value is empty', () => {
  37. expect(isWhereEmpty({ a: undefined })).to.equal(false);
  38. });
  39. });
  40. });