Socket
Socket
Sign inDemoInstall

sequelize-fixtures

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sequelize-fixtures - npm Package Compare versions

Comparing version 0.4.8 to 0.4.9

6

lib/loader.js

@@ -97,2 +97,8 @@ var Promise = require('bluebird');

many2many = {};
// Allows an external caller to modify the data
// before it is evaluated
if (this.options.modifyFixtureDataFn) {
data = this.options.modifyFixtureDataFn(data, Model);
}

@@ -99,0 +105,0 @@ // Allows an external caller to do some transforms to the data

2

package.json
{
"name": "sequelize-fixtures",
"version": "0.4.8",
"version": "0.4.9",
"description": "sequelize fixture loader",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -68,2 +68,14 @@ [![Build Status](https://travis-ci.org/domasx2/sequelize-fixtures.svg?branch=master)](https://travis-ci.org/domasx2/sequelize-fixtures)

//modify each model being loaded
sequelize_fixtures.loadFile('fixtures/*.json', models, {
modifyFixtureDataFn: function (data) {
if(!data.createdAt) {
data.createdAt = new Date();
}
return data;
}
}).then(function() {
doStuffAfterLoad();
});
//from array

@@ -70,0 +82,0 @@ var fixtures = [

@@ -513,2 +513,38 @@ var sf = require('../index'),

});
it('should load fixtures and then transform their values', function() {
return sf.loadFile('tests/fixtures/fixture1.json', models, {
transformFixtureDataFn: function (data, model) {
if (model.name === 'bar') {
data.propB = 99;
}
return data;
}
}).then(function() {
return models.Bar.findAll();
}).then(function(bars){
bars.forEach(function(bar) {
bar.propB.should.equal(99);
});
});
});
it('should load user modified fixtures', function() {
return sf.loadFile('tests/fixtures/fixture1.json', models, {
modifyFixtureDataFn: function (data, model) {
if (model.name === 'foo') {
delete data.propB;
data.status = true;
}
return data;
}
}).then(function() {
return models.Foo.findAll();
}).then(function(foos){
foos.forEach(function(foo) {
(foo.propB === null).should.equal(true);
foo.status.should.equal(true);
});
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc