Closed chriscamicas closed 4 years ago
Hi
I don't know, I have not use yet association.
Could you extend on of the example (mocha, jasmine, tape) with a model with an association. I try to check it when I have enough time
Many thanks
Also having this problem. For example, if you add the following to the models.js
:
UserModel.belongsTo(UserModel, { foreignKey: 'managerId', as: 'Manager', constraints: false });
Objects should then have a managerId
field and the methods getManager
and setManager
should be added but they are not. To test this, I then added the following to the service-with-sequelize-mocking-mochaSpec
:
describe('return an object with a', function () {
describe('getManager method', function () {
it('to exist', function () {
return UserService
.find(1)
.then(function (user) {
chai.expect(user.getManager).to.exist;
});
});
it('to return the target user', function () {
return UserService
.find(1)
.then(function (user) {
manager = user.getManager();
chai.expect(manager).deep.equals({
'id': 2,
'firstName': 'Joe',
'lastName': 'Bloggs',
'age': 56,
'description': null,
'managerId': null
});
});
});
});
});
Having updated the fake-users-database.json
to:
[
{
"model": "user",
"data": {
"id": 1,
"firstName": "John",
"lastName": "Doe",
"age": 25,
"description": null,
"managerId": 2
}
},
{
"model": "user",
"data": {
"id": 2,
"firstName": "Joe",
"lastName": "Bloggs",
"age": 56,
"description": null,
"managerId": null
}
}
]
If I have time I will make a full example for you.
Hi @flungo
Many thanks for your feedback
If you could provide me an example, this is fine.
Otherwise, when I have some times, I try to look on it
Thanks again
close due to inactivity
Does your mocking module work with association ? Let's say I have a parent-child model:
In my classic model, I have a Node.getChildren() navigation method, when using sequelize-mocking, the same method is undefined.
thanks