This commit is contained in:
parent
5a975d0b05
commit
522000cd04
|
@ -44,6 +44,3 @@ BEGIN
|
|||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
INSERT INTO `util`.`notification` (`id`, `name`,`description`)
|
||||
VALUES (3, 'supplier-pay-method-update', 'A supplier pay method has been updated');
|
||||
|
|
|
@ -2689,7 +2689,8 @@ INSERT INTO `util`.`notificationConfig`
|
|||
|
||||
INSERT INTO `util`.`notification` (`id`, `name`, `description`)
|
||||
VALUES
|
||||
(1, 'print-email', 'notification fixture one');
|
||||
(1, 'print-email', 'notification fixture one'),
|
||||
(3, 'supplier-pay-method-update', 'A supplier pay method has been updated');
|
||||
|
||||
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
|
||||
VALUES
|
||||
|
@ -2746,3 +2747,4 @@ INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
|||
INSERT INTO `vn`.`payDemDetail` (`id`, `detail`)
|
||||
VALUES
|
||||
(1, 1);
|
||||
|
||||
|
|
|
@ -2,7 +2,12 @@ const models = require('vn-loopback/server/server').models;
|
|||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('loopback model Supplier', () => {
|
||||
let supplierOne;
|
||||
let supplierTwo;
|
||||
|
||||
beforeAll(async() => {
|
||||
supplierOne = await models.Supplier.findById(1);
|
||||
supplierTwo = await models.Supplier.findById(442);
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
|
@ -25,9 +30,8 @@ describe('loopback model Supplier', () => {
|
|||
try {
|
||||
let error;
|
||||
const expectedError = 'You can not select this payment method without a registered bankery account';
|
||||
const supplier = await models.Supplier.findOne({where: {id: 1}}, options);
|
||||
|
||||
await supplier.updateAttribute('payMethodFk', 8, options)
|
||||
await supplierOne.updateAttribute('payMethodFk', 8, options)
|
||||
.catch(e => {
|
||||
error = e;
|
||||
|
||||
|
@ -48,8 +52,7 @@ describe('loopback model Supplier', () => {
|
|||
|
||||
try {
|
||||
let error;
|
||||
const supplier = await models.Supplier.findOne({where: {id: 442}}, options);
|
||||
await supplier.updateAttribute('payMethodFk', 4, options)
|
||||
await supplierTwo.updateAttribute('payMethodFk', 4, options)
|
||||
.catch(e => {
|
||||
error = e;
|
||||
});
|
||||
|
@ -67,9 +70,8 @@ describe('loopback model Supplier', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const supplier = await models.Supplier.findOne({where: {id: 442}}, options);
|
||||
await supplier.updateAttribute('isPayMethodChecked', true, options);
|
||||
await supplier.updateAttribute('payMethodFk', 5, options);
|
||||
await supplierTwo.updateAttribute('isPayMethodChecked', true, options);
|
||||
await supplierTwo.updateAttribute('payMethodFk', 5, options);
|
||||
|
||||
const result = await models.Supplier.findOne({where: {id: 442}}, options);
|
||||
|
||||
|
@ -86,9 +88,8 @@ describe('loopback model Supplier', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const supplier = await models.Supplier.findOne({where: {id: 442}}, options);
|
||||
await supplier.updateAttribute('isPayMethodChecked', true, options);
|
||||
await supplier.updateAttribute('payMethodFk', 2, options);
|
||||
await supplierTwo.updateAttribute('isPayMethodChecked', true, options);
|
||||
await supplierTwo.updateAttribute('payMethodFk', 2, options);
|
||||
|
||||
const result = await models.Supplier.findOne({where: {id: 442}}, options);
|
||||
|
||||
|
@ -105,15 +106,13 @@ describe('loopback model Supplier', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const supplier = await models.Supplier.findOne({where: {id: 442}}, options);
|
||||
await supplier.updateAttribute('payMethodFk', 2, options);
|
||||
|
||||
await supplier.updateAttribute('isPayMethodChecked', true, options);
|
||||
await supplier.updateAttribute('payDay', 5, options);
|
||||
await supplierTwo.updateAttribute('payMethodFk', 2, options);
|
||||
await supplierTwo.updateAttribute('isPayMethodChecked', true, options);
|
||||
await supplierTwo.updateAttribute('payDay', 5, options);
|
||||
const firstResult = await models.Supplier.findOne({where: {id: 442}}, options);
|
||||
|
||||
await supplier.updateAttribute('isPayMethodChecked', true, options);
|
||||
await supplier.updateAttribute('payDemFk', 1, options);
|
||||
await supplierTwo.updateAttribute('isPayMethodChecked', true, options);
|
||||
await supplierTwo.updateAttribute('payDemFk', 1, options);
|
||||
const secondResult = await models.Supplier.findOne({where: {id: 442}}, options);
|
||||
|
||||
expect(firstResult.isPayMethodChecked).toEqual(false);
|
||||
|
|
Loading…
Reference in New Issue