helpers.test.ts 672 B

123456789101112131415161718192021222324
  1. import { expect } from 'chai';
  2. import { beforeAll2, sequelize } from '../../support';
  3. describe('Model#hasAlias', () => {
  4. const vars = beforeAll2(() => {
  5. const User = sequelize.define('user');
  6. const Task = sequelize.define('task');
  7. Task.belongsTo(User, { as: 'owner' });
  8. return { Task };
  9. });
  10. it('returns true if a model has an association with the specified alias', () => {
  11. const { Task } = vars;
  12. expect(Task.hasAlias('owner')).to.equal(true);
  13. });
  14. it('returns false if a model does not have an association with the specified alias', () => {
  15. const { Task } = vars;
  16. expect(Task.hasAlias('notOwner')).to.equal(false);
  17. });
  18. });