Document setting up mock models with multiple rows
See original GitHub issueCurrently the examples are very limited and it is not clear how one could have multiple rows in their mock data. Neither the readme nor the documentation seem to cover how that would be possible.
For example the below example only describes the usage of a single row
var UserMock = DBConnectionMock.define('users', {
'email': 'email@example.com',
'username': 'blink',
'picture': 'user-picture.jpg',
}, {
instanceMethods: {
myTestFunc: function () {
return 'Test User';
},
},
});
Whereas directly below we have a WHERE
example which is completely unclear on how to actually reproduce. This is because there is neither information on adding multiple rows, nor is the example condition and fields valid for the above row.
UserMock.findOne({
where: {
username: 'my-user',
},
}).then(function (user) {
// `user` is a Sequelize Model-like object
user.get('id'); // Auto-Incrementing ID available on all Models
user.get('email'); // 'email@example.com'; Pulled from default values
user.get('username'); // 'my-user'; Pulled from the `where` in the query
user.myTestFunc(); // Will return 'Test User' as defined above
});
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:5
Top Results From Across the Web
Create a Model and Mock Instances | by Tom Brodhurst-Hill
Broadly speaking, an app has two facets: model and view. ... In Xcode, use the File menu's New File… command to create a...
Read more >Stubbing and Mocking with Mockito and JUnit - Semaphore CI
Learn how to create true unit tests by mocking all external dependencies in your JUnit classes with the help of Mockito.
Read more >A Unit Testing Practitioner's Guide to Everyday Mockito - Toptal
With Mockito, you create a mock, tell Mockito what to do when specific methods are ... You can also specify multiple values which...
Read more >Using Test Data With Mock Services - BlazeMeter Docs
A Service Data Model contains one or more Data Entities. You can create several data entities, each of which can contain, for example,...
Read more >Pytest with Marking, Mocking, and Fixtures in 10 Minutes
There is more than one way (and more than one Python package) to perform unit tests ... To overcome this, create a configuration...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Took me a few hours to find but I found
$queueResult
aswell. My implementation for my test was like this:There are still many unanswered questions, and this been the plug and play package I was hoping for is not the case
I met the same problem when init model with multiple records. I have tried to pass the data as an array, but the result from query was wrong. Does any way solve this?