initial feedback
Signed-off-by: Yaapa Hage <hage.yaapa@in.ibm.com>
This commit is contained in:
parent
2f73a461c2
commit
d6a28f6aa1
|
@ -1,4 +1,4 @@
|
||||||
// Copyright IBM Corp. 2013,2019. All Rights Reserved.
|
// Copyright IBM Corp. 2013,2020. All Rights Reserved.
|
||||||
// Node module: loopback-datasource-juggler
|
// Node module: loopback-datasource-juggler
|
||||||
// This file is licensed under the MIT License.
|
// This file is licensed under the MIT License.
|
||||||
// License text available at https://opensource.org/licenses/MIT
|
// License text available at https://opensource.org/licenses/MIT
|
||||||
|
@ -16,9 +16,8 @@ let ds;
|
||||||
const ValidationError = require('..').ValidationError;
|
const ValidationError = require('..').ValidationError;
|
||||||
|
|
||||||
describe.only('id property', function() {
|
describe.only('id property', function() {
|
||||||
before(function(done) {
|
before(function() {
|
||||||
ds = getSchema();
|
ds = getSchema();
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
context('unspecified (defaults to generated:true)', function() {
|
context('unspecified (defaults to generated:true)', function() {
|
||||||
|
@ -33,11 +32,11 @@ describe.only('id property', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not require id value', async () => {
|
it('should not require id value', async () => {
|
||||||
await IdCheckA.create({name: 'Pablo'}).should.not.be.rejected();
|
await IdCheckA.create({name: 'Pablo'}).should.be.fulfilled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not allow id value to be specified', async () => {
|
it('should not allow id value to be specified', async () => {
|
||||||
await IdCheckA.create({id: 10, name: 'Pablo'}).should.be.rejectedWith(/can\'t be set/);
|
await IdCheckA.create({id: 10, name: 'Pablo'}).should.be.rejectedWith({statusCode: 422});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -52,11 +51,11 @@ describe.only('id property', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not require id value', async () => {
|
it('should not require id value', async () => {
|
||||||
await IdCheckB.create({name: 'Pablo'}).should.not.be.rejected();
|
await IdCheckB.create({name: 'Pablo'}).should.be.fulfilled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow id value to be specified', async () => {
|
it('should allow id value to be specified', async () => {
|
||||||
await IdCheckB.create({id: 10, name: 'Pablo'}).should.not.be.rejected();
|
await IdCheckB.create({id: 10, name: 'Pablo'}).should.be.fulfilled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -66,20 +65,21 @@ describe.only('id property', function() {
|
||||||
let IdCheckC;
|
let IdCheckC;
|
||||||
before(async () => {
|
before(async () => {
|
||||||
IdCheckC = ds.define('IdCheckC', {
|
IdCheckC = ds.define('IdCheckC', {
|
||||||
|
id: {id: true, type: String},
|
||||||
name: String,
|
name: String,
|
||||||
});
|
});
|
||||||
await ds.automigrate(IdCheckC.modelName);
|
await ds.automigrate(IdCheckC.modelName);
|
||||||
await IdCheckC.destroyAll();
|
await IdCheckC.destroyAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
// If id is not autogenerated and forceId is true, a value must be specified
|
// If id is not autogenerated, forceId is not applicable and a value must be specified
|
||||||
it('should require id value', async () => {
|
it('should require id value', async () => {
|
||||||
await IdCheckC.create({name: 'Pablo'}).should.be.rejected();
|
await IdCheckC.create({name: 'Pablo'}).should.be.rejected();
|
||||||
});
|
});
|
||||||
|
|
||||||
// If id is not autogenerated and forceId is true, a value can be specified
|
// If id is not autogenerated, forceId is not applicable and a value can be specified
|
||||||
it('should allow id value to be specified', async () => {
|
it('should allow id value to be specified', async () => {
|
||||||
await IdCheckC.create({id: 10, name: 'Pablo'}).should.not.be.rejected();
|
await IdCheckC.create({id: 10, name: 'Pablo'}).should.be.fulfilled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -87,20 +87,21 @@ describe.only('id property', function() {
|
||||||
let IdCheckD;
|
let IdCheckD;
|
||||||
before(async () => {
|
before(async () => {
|
||||||
IdCheckD = ds.define('IdCheckD', {
|
IdCheckD = ds.define('IdCheckD', {
|
||||||
|
id: {id: true, type: String},
|
||||||
name: String,
|
name: String,
|
||||||
}, {forceId: false});
|
}, {forceId: false});
|
||||||
await ds.automigrate(IdCheckD.modelName);
|
await ds.automigrate(IdCheckD.modelName);
|
||||||
await IdCheckD.destroyAll();
|
await IdCheckD.destroyAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
// If id is not autogenerated and forceId is false, a value must be specified
|
// If id is not autogenerated, forceId is not applicable and a value must be specified
|
||||||
it('should require id value', async () => {
|
it('should require id value', async () => {
|
||||||
await IdCheckD.create({name: 'Pablo'}).should.be.rejected();
|
await IdCheckD.create({name: 'Pablo'}).should.be.rejected();
|
||||||
});
|
});
|
||||||
|
|
||||||
// If id is not autogenerated and forceId is false, a value can be specified
|
// If id is not autogenerated, forceId is not applicable and a value can be specified
|
||||||
it('should allow id value to be specified', async () => {
|
it('should allow id value to be specified', async () => {
|
||||||
await IdCheckD.create({id: 10, name: 'Pablo'}).should.not.be.rejected();
|
await IdCheckD.create({id: 10, name: 'Pablo'}).should.be.fulfilled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -110,20 +111,21 @@ describe.only('id property', function() {
|
||||||
let IdCheckE;
|
let IdCheckE;
|
||||||
before(async () => {
|
before(async () => {
|
||||||
IdCheckE = ds.define('IdCheckE', {
|
IdCheckE = ds.define('IdCheckE', {
|
||||||
|
id: {id: true, type: String, generated: true},
|
||||||
name: String,
|
name: String,
|
||||||
});
|
});
|
||||||
await ds.automigrate(IdCheckE.modelName);
|
await ds.automigrate(IdCheckE.modelName);
|
||||||
await IdCheckE.destroyAll();
|
await IdCheckE.destroyAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
// If id is autogenerated and forceId is true, a value need not be specified
|
// If id is autogenerated and forceId is true, id value must not be specified
|
||||||
it('should not require id value', async () => {
|
it('should not require id value', async () => {
|
||||||
await IdCheckE.create({name: 'Pablo'}).should.not.be.rejected();
|
await IdCheckE.create({name: 'Pablo'}).should.be.fulfilled();
|
||||||
});
|
});
|
||||||
|
|
||||||
// If id is autogenerated and forceId is true, a value cannot be specified
|
// If id is autogenerated and forceId is true, a value cannot be specified
|
||||||
it('should not allow id value to be specified', async () => {
|
it('should not allow id value to be specified', async () => {
|
||||||
await IdCheckE.create({id: 10, name: 'Pablo'}).should.not.be.rejected();
|
await IdCheckE.create({id: 10, name: 'Pablo'}).should.be.rejectedWith({statusCode: 422});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -131,6 +133,7 @@ describe.only('id property', function() {
|
||||||
let IdCheckF;
|
let IdCheckF;
|
||||||
before(async () => {
|
before(async () => {
|
||||||
IdCheckF = ds.define('IdCheckF', {
|
IdCheckF = ds.define('IdCheckF', {
|
||||||
|
id: {id: true, type: String, generated: true},
|
||||||
name: String,
|
name: String,
|
||||||
}, {forceId: false});
|
}, {forceId: false});
|
||||||
await ds.automigrate(IdCheckF.modelName);
|
await ds.automigrate(IdCheckF.modelName);
|
||||||
|
@ -139,12 +142,12 @@ describe.only('id property', function() {
|
||||||
|
|
||||||
// If id is autogenerated and forceId is false, a value need not be specified
|
// If id is autogenerated and forceId is false, a value need not be specified
|
||||||
it('should not require id value', async () => {
|
it('should not require id value', async () => {
|
||||||
await IdCheckF.create({name: 'Pablo'}).should.not.be.rejected();
|
await IdCheckF.create({name: 'Pablo'}).should.be.fulfilled();
|
||||||
});
|
});
|
||||||
|
|
||||||
// If id is autogenerated and forceId is false, a value can be specified
|
// If id is autogenerated and forceId is false, a value can be specified
|
||||||
it('should allow id value to be specified', async () => {
|
it('should allow id value to be specified', async () => {
|
||||||
await IdCheckF.create({id: 10, name: 'Pablo'}).should.not.be.rejected();
|
await IdCheckF.create({id: 10, name: 'Pablo'}).should.be.fulfilled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue