component-dbs-core
Version:
DTO objects shared among device backend
123 lines • 4.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const appsyncUtils_1 = require("./appsyncUtils");
describe('AppSyncUtil test suite', () => {
const appsyncUtil = new appsyncUtils_1.AppSyncUtils();
it('should be able to create gql required attributes from transaction', () => {
const transaction = {
par: 'e82db8ac-8f73-47ee-bde0-cc868c255b8d',
saleAmount: 0,
surchargeAmount: 500,
amount: 200,
maskedPan: 'masked',
scheme: "AMEX" /* AMEX */,
entityUuid: '596639a1-7cf1-4aaf-90b7-ed4cc2c26930',
tipAmount: 100,
siteName: 'befaf3dc-2062-4052-ae70-6bea7b2b8545',
deviceName: '001a8772-c4bb-4fd5-9ddd-adc3ccfa2e53',
reference: '2ac7fdb1-b82a-4f05-b29b-22fbbf39ec9c',
transactionType: "PURCHASE" /* PURCHASE */,
feeAmount: 400,
depositDate: '2020-07-12T05:22:46.913Z',
panToken: '3d57d993-b17d-490c-8054-304059ceaac7',
taxAmounts: [{ name: 'name1', amount: 100 }],
id: '51c3b11c-bcee-48ad-bd4f-95b86c15d5d1',
siteUuid: '49ecdc0f-e3cf-40c3-b210-4c08c062973f',
depositUuid: 'e6141ce2-b7db-435d-913c-6aa4641784ae',
status: "APPROVED" /* APPROVED */,
timestamp: '2020-07-12T05:22:46.913Z',
deviceUuid: '65c3140c-b6d0-4675-9e7e-fbc4750910cd',
};
const gqlKeys = appsyncUtil.getGqlResponseKeys(transaction);
expect(gqlKeys).toEqual([
'par',
'saleAmount',
'surchargeAmount',
'amount',
'maskedPan',
'scheme',
'entityUuid',
'tipAmount',
'siteName',
'deviceName',
'reference',
'transactionType',
'feeAmount',
'depositDate',
'panToken',
'taxAmounts {name amount}',
'id',
'siteUuid',
'depositUuid',
'status',
'timestamp',
'deviceUuid',
]);
});
it('should be able to create gql required attributes from deposit', () => {
const deposit = {
id: '65c3140c-b6d0-4675-9e7e-fbc4750910cd',
depositUuid: 'b6b0abd4-9e7b-4304-8d49-6f24f9b02cc5',
entityUuid: 'b6b0abd4-9e7b-4304-8d49-6f24f9b02cc5',
timestamp: '2020-07-13T02:49:06.752Z',
status: 'DEPOSITED',
dailyTotals: [{
amount: 100,
date: '2020-07-13',
}],
account: 'account',
reference: 'reference',
totalAmount: 100,
feeAmount: 100,
refundsAmount: 100,
chargeBacksAmount: 100,
owingAmount: 100,
adjustedAmount: 100,
depositAmount: 100,
};
const gqlKeys = appsyncUtil.getGqlResponseKeys(deposit);
expect(gqlKeys).toEqual([
'id',
'depositUuid',
'entityUuid',
'timestamp',
'status',
'dailyTotals {amount date}',
'account',
'reference',
'totalAmount',
'feeAmount',
'refundsAmount',
'chargeBacksAmount',
'owingAmount',
'adjustedAmount',
'depositAmount',
]);
});
it('should be able to create gql required attributes from deviceSettings', () => {
const deviceSettings = {
id: "deviceUuid",
name: 'zeller device name',
site: {
name: 'zeller site name',
pin: '1203',
siteUuid: "uuidv4",
},
receipt: {
businessAddress: 'Victoria, Australia',
businessName: 'NPCO ltd.',
footer: 'link://footer_changed',
logo: 'link://logo',
enabled: true,
},
};
const gqlKeys = appsyncUtil.getGqlResponseKeys(deviceSettings);
expect(gqlKeys).toEqual([
'id',
'name',
'site {name pin siteUuid}',
'receipt {businessAddress businessName footer logo enabled}',
]);
});
});
//# sourceMappingURL=appsyncUtils.spec.js.map