/**
* Parrot.js
*
* @description :: The set of parrots registered in our app.
* @docs :: http://sailsjs.com/documentation/concepts/models-and-orm/models
*/
module.exports = {
attributes: {
// e.g. "Polly"
name: {
type: 'string'
},
// e.g. 3.26
wingspan: {
type: 'number',
required: true,
columnType: 'FLOAT'
},
// e.g. "cm"
wingspanUnits: {
type: 'string',
isIn: ['cm', 'in', 'm', 'mm'],
defaultsTo: 'cm'
},
// e.g. [{...}, {...}, ...]
knownDialects: {
collection: 'Dialect'
}
}
};
-
-
Save rachaelshaw/f5bf442b2171154aa6021846d1a250f8 to your computer and use it in GitHub Desktop.
Three is a section for "Embeds" in the models generated by sails . What is it all about, and how do we use them?
What is the best testing library for a sails server?
If I had multiple Parrot.js how could I write a test using playwright, jest, or mocha and have the test start with an empty Parrot.js and then fill the model with data and verify the data is valid?
Here is what I have using mocha (I like Jest and Playwright, but can settle for Mocha if it works)
const Parrot = require('../api/models/Parrot');
describe('Helper', () => {
beforeEach(async () => {
// Clear Parrot before each test
await Parrot.destroy({});
});
it('should log a message with animal type', async () => {
const breed = 'Parrot';
await sails.helpers.data.with({
'breed': breed,
'animal': 'bird',
});
const search = await Parrot.find();
expect(Parrot[0].breed).toBe(breed);
});
I am getting errors that null is undefined and that sails is undefined. The purpose is that I am trying to understand if I can use Jest, Playwright, or Mocha to test functionality of a sails server using the models for the data types and using a helper script that has the .create() in it and keeping the ability to use sails.helpers.xx. Been at it for hours back and forth and no luck. Any recommendations?
How can I create a date type attribute?
date: {
type: 'string',
columnType: 'Date'
}
^
It may be so??