Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
option object shouldn't be updated internally.
- Loading branch information
Showing
7 changed files
with
319 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
|
||
var chai = require('chai') | ||
, expect = chai.expect | ||
, Support = require(__dirname + '/../support') | ||
, current = Support.sequelize | ||
, Sequelize = Support.Sequelize | ||
, sinon = require('sinon'); | ||
|
||
describe(Support.getTestDialectTeaser('Instance'), function() { | ||
describe('decrement', function () { | ||
describe('options tests', function() { | ||
var stub | ||
, Model = current.define('User', { | ||
id: { | ||
type: Sequelize.BIGINT, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
} | ||
}) | ||
, instance; | ||
|
||
before(function() { | ||
stub = sinon.stub(current, 'query').returns( | ||
Sequelize.Promise.resolve({ | ||
_previousDataValues: {id: 3}, | ||
dataValues: {id: 1} | ||
}) | ||
); | ||
}); | ||
|
||
after(function() { | ||
stub.restore(); | ||
}); | ||
|
||
it('should allow decrements even if options are not given', function () { | ||
instance = Model.build({id: 3}, {isNewRecord: false}); | ||
expect(function () { | ||
instance.decrement(['id']); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('should not modify options when it given to decrement', function () { | ||
instance = Model.build({id: 3}, {isNewRecord: false}); | ||
var options = { by: 2 }; | ||
instance.decrement(['id'], options); | ||
expect(options).to.deep.equal({ by: 2 }); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
|
||
var chai = require('chai') | ||
, expect = chai.expect | ||
, Support = require(__dirname + '/../support') | ||
, current = Support.sequelize | ||
, Sequelize = Support.Sequelize | ||
, sinon = require('sinon'); | ||
|
||
describe(Support.getTestDialectTeaser('Instance'), function() { | ||
describe('destroy', function () { | ||
describe('options tests', function() { | ||
var stub | ||
, Model = current.define('User', { | ||
id: { | ||
type: Sequelize.BIGINT, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
} | ||
}) | ||
, instance; | ||
|
||
before(function() { | ||
stub = sinon.stub(current, 'query').returns( | ||
Sequelize.Promise.resolve({ | ||
_previousDataValues: {}, | ||
dataValues: {id: 1} | ||
}) | ||
); | ||
}); | ||
|
||
after(function() { | ||
stub.restore(); | ||
}); | ||
|
||
it('should allow destroies even if options are not given', function () { | ||
instance = Model.build({id: 1}, {isNewRecord: false}); | ||
expect(function () { | ||
instance.destroy(); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('should not modify options when it given to destroy', function () { | ||
instance = Model.build({id: 1}, {isNewRecord: false}); | ||
var options = { transaction: null }; | ||
instance.destroy(options); | ||
expect(options).to.deep.equal({ transaction: null }); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
|
||
var chai = require('chai') | ||
, expect = chai.expect | ||
, Support = require(__dirname + '/../support') | ||
, current = Support.sequelize | ||
, Sequelize = Support.Sequelize | ||
, sinon = require('sinon'); | ||
|
||
describe(Support.getTestDialectTeaser('Instance'), function() { | ||
describe('increment', function () { | ||
describe('options tests', function() { | ||
var stub | ||
, Model = current.define('User', { | ||
id: { | ||
type: Sequelize.BIGINT, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
} | ||
}) | ||
, instance; | ||
|
||
before(function() { | ||
stub = sinon.stub(current, 'query').returns( | ||
Sequelize.Promise.resolve({ | ||
_previousDataValues: {id: 1}, | ||
dataValues: {id: 3} | ||
}) | ||
); | ||
}); | ||
|
||
after(function() { | ||
stub.restore(); | ||
}); | ||
|
||
it('should allow increments even if options are not given', function () { | ||
instance = Model.build({id: 1}, {isNewRecord: false}); | ||
expect(function () { | ||
instance.increment(['id']); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('should not modify options when it given to increment', function () { | ||
instance = Model.build({id: 1}, {isNewRecord: false}); | ||
var options = { by: 2 }; | ||
instance.increment(['id'], options); | ||
expect(options).to.deep.equal({ by: 2 }); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
|
||
var chai = require('chai') | ||
, expect = chai.expect | ||
, Support = require(__dirname + '/../support') | ||
, current = Support.sequelize | ||
, Sequelize = Support.Sequelize | ||
, sinon = require('sinon'); | ||
|
||
describe(Support.getTestDialectTeaser('Instance'), function() { | ||
describe('reload', function () { | ||
describe('options tests', function() { | ||
var stub | ||
, Model = current.define('User', { | ||
id: { | ||
type: Sequelize.BIGINT, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
deletedAt: { | ||
type: Sequelize.DATE, | ||
} | ||
}, { | ||
paranoid: true | ||
}) | ||
, instance; | ||
|
||
before(function() { | ||
stub = sinon.stub(current, 'query').returns( | ||
Sequelize.Promise.resolve({ | ||
_previousDataValues: {id: 1}, | ||
dataValues: {id: 2} | ||
}) | ||
); | ||
}); | ||
|
||
after(function() { | ||
stub.restore(); | ||
}); | ||
|
||
it('should allow reloads even if options are not given', function () { | ||
instance = Model.build({id: 1}, {isNewRecord: false}); | ||
expect(function () { | ||
instance.reload(); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('should not modify options when it given to reload', function () { | ||
instance = Model.build({id: 1}, {isNewRecord: false}); | ||
var options = { transaction: null }; | ||
instance.reload(options); | ||
expect(options).to.deep.equal({ transaction: null }); | ||
}); | ||
|
||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
|
||
var chai = require('chai') | ||
, expect = chai.expect | ||
, Support = require(__dirname + '/../support') | ||
, current = Support.sequelize | ||
, Sequelize = Support.Sequelize | ||
, sinon = require('sinon'); | ||
|
||
describe(Support.getTestDialectTeaser('Instance'), function() { | ||
describe('restore', function () { | ||
describe('options tests', function() { | ||
var stub | ||
, Model = current.define('User', { | ||
id: { | ||
type: Sequelize.BIGINT, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
deletedAt: { | ||
type: Sequelize.DATE, | ||
} | ||
}, { | ||
paranoid: true | ||
}) | ||
, instance; | ||
|
||
before(function() { | ||
stub = sinon.stub(current, 'query').returns( | ||
Sequelize.Promise.resolve({ | ||
_previousDataValues: {id: 1}, | ||
dataValues: {id: 2} | ||
}) | ||
); | ||
}); | ||
|
||
after(function() { | ||
stub.restore(); | ||
}); | ||
|
||
it('should allow restores even if options are not given', function () { | ||
instance = Model.build({id: 1}, {isNewRecord: false}); | ||
expect(function () { | ||
instance.restore(); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('should not modify options when it given to restore', function () { | ||
instance = Model.build({id: 1}, {isNewRecord: false}); | ||
var options = { transaction: null }; | ||
instance.restore(options); | ||
expect(options).to.deep.equal({ transaction: null }); | ||
}); | ||
}); | ||
}); | ||
|
||
}); |
Oops, something went wrong.