Skip to content

Commit f866125

Browse files
Robin BuschmannRobin Buschmann
authored andcommitted
Model.prototype.constructor and Sequelize.prototype.constructor referenced base models instead of Model/Sequelize
1 parent 20bfeb0 commit f866125

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

lib/models/BaseModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export abstract class BaseModel {
3434

3535
// copies all prototype members of this to target.prototype
3636
Object
37-
.getOwnPropertyNames(this.prototype)
37+
.keys(this.prototype)
3838
.forEach(name => target.prototype[name] = this.prototype[name])
3939
;
4040

lib/models/BaseSequelize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export abstract class BaseSequelize {
2424

2525
// copies all prototype members of this to target.prototype
2626
Object
27-
.getOwnPropertyNames(this.prototype)
27+
.keys(this.prototype)
2828
.forEach(name => target.prototype[name] = this.prototype[name])
2929
;
3030

test/specs/models/model.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {expect} from 'chai';
2+
import {Model} from "../../../lib/models/Model";
3+
4+
describe('model', () => {
5+
6+
describe('constructor', () => {
7+
8+
it('should equal Model class', () => {
9+
expect(Model.prototype.constructor).to.equal(Model);
10+
});
11+
12+
});
13+
14+
});

test/specs/sequelize.spec.ts renamed to test/specs/models/sequelize.spec.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
11
import {expect} from 'chai';
2-
import {createSequelize} from "../utils/sequelize";
3-
import {Game} from "../models/exports/Game";
4-
import Gamer from "../models/exports/gamer.model";
2+
import {createSequelize} from "../../utils/sequelize";
3+
import {Game} from "../../models/exports/Game";
4+
import Gamer from "../../models/exports/gamer.model";
5+
import {Sequelize} from "../../../lib/models/Sequelize";
56

67
describe('sequelize', () => {
78

89
const sequelize = createSequelize(false);
910

11+
describe('constructor', () => {
12+
13+
it('should equal Sequelize class', () => {
14+
expect(sequelize.constructor).to.equal(Sequelize);
15+
});
16+
17+
});
18+
1019
describe('addModels', () => {
1120

1221
it('should not throw', () => {
1322

14-
expect(() => sequelize.addModels([__dirname + '/../models/exports/'])).not.to.throw();
23+
expect(() => sequelize.addModels([__dirname + '/../../models/exports/'])).not.to.throw();
1524
});
1625

1726
it('should throw', () => {
1827

19-
expect(() => sequelize.addModels([__dirname + '/../models/exports/throws'])).to.throw();
28+
expect(() => sequelize.addModels([__dirname + '/../../models/exports/throws'])).to.throw();
2029
});
2130

2231
describe('default exported models', () => {
2332

2433
it('should work as expected', () => {
2534

26-
sequelize.addModels([__dirname + '/../models/exports/']);
35+
sequelize.addModels([__dirname + '/../../models/exports/']);
2736

2837
expect(() => Gamer.build({})).not.to.throw;
2938

@@ -38,7 +47,7 @@ describe('sequelize', () => {
3847

3948
it('should work as expected', () => {
4049

41-
sequelize.addModels([__dirname + '/../models/exports/']);
50+
sequelize.addModels([__dirname + '/../../models/exports/']);
4251

4352
expect(() => Game.build({})).not.to.throw;
4453

0 commit comments

Comments
 (0)