Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/unit tests #70

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a11f830
fixed old tests
kostysh Jul 16, 2020
d239719
add tests
kostysh Jul 17, 2020
14d0911
fixed wrong GLIDER_ORGID env
kostysh Jul 19, 2020
e2e811a
added tests for parsers (used in hotels search)
kostysh Jul 19, 2020
111bdf3
added code coverage tool and configuration
kostysh Jul 20, 2020
4d1da92
added test for GliderError class
kostysh Jul 20, 2020
ba9dc90
added "code" case for the test for GliderError class
kostysh Jul 20, 2020
c49eb43
updated tests runner configuration
kostysh Jul 20, 2020
5269492
added test for searchHorel resolver
kostysh Jul 20, 2020
f8bad8f
added test for orderCreateWithOffer hotel order resolver
kostysh Jul 20, 2020
b2180f1
added test for mapFromOffer
kostysh Jul 20, 2020
eb21f7a
disabled mongo calls in testing mode
kostysh Jul 20, 2020
8e7ddca
fix lintig errors
kostysh Jul 20, 2020
edea38c
Linting enabled in CI configuration
kostysh Jul 20, 2020
cb0a918
added test for reduceContactInformation
kostysh Jul 22, 2020
647ec80
added tests for parsers: useDictionary, mergeHourAndDate
kostysh Jul 23, 2020
c303ca4
added test for parser: convertDateToAirportTime
kostysh Jul 23, 2020
4a325d4
added test for parser: reduceToProperty
kostysh Jul 23, 2020
2d003f0
added tests for parsers: roundCommissionDecimals & deepMerge
kostysh Jul 23, 2020
3ed02d9
fixed type in config; minor update for tests
kostysh Jul 23, 2020
467d9bc
added tests for utils: uniqueObjectsList & flatOneDepth
kostysh Jul 24, 2020
c5cb04d
tests structure changed
kostysh Jul 24, 2020
0929e89
tests structure update and new tests
kostysh Jul 24, 2020
5ce8f41
more tests for transformInputData
kostysh Aug 3, 2020
85f9faf
tests for transforInputData utils and soapTemplates
kostysh Aug 4, 2020
4a38881
tests for soapTemplates
kostysh Aug 18, 2020
ea08bad
more tests for soapTemplates
kostysh Aug 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tests for soapTemplates
  • Loading branch information
kostysh committed Aug 18, 2020
commit 4a388814d391533756d83ea02ae5b957b679d88d
2 changes: 1 addition & 1 deletion helpers/resolvers/flight/seatAvailability.js
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ const processResponse = async (data, offers, template) => {
prices
};
}

return a;
}, {});

9 changes: 3 additions & 6 deletions helpers/soapTemplates/ota/otaHotelAvailRQ.js
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ const mapGuestCounts = (guests) => guests
<GuestCount AgeQualifyingCode="${AgeQualifyingCode}" Count="${Count}"/>`,
''
);
module.exports.mapGuestCounts = mapGuestCounts;

const mapCriterions = (
HotelSearchCriteria,
@@ -39,9 +40,9 @@ const mapCriterions = (
</Criterion>`,
''
);
module.exports.mapCriterions = mapCriterions;


const hotelAvailRequestTemplate = ({ OTA_HotelAvailRQ }) => `
module.exports.hotelAvailRequestTemplate = ({ OTA_HotelAvailRQ }) => `
<?xml version="1.0" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
@@ -71,7 +72,3 @@ const hotelAvailRequestTemplate = ({ OTA_HotelAvailRQ }) => `
</OTA_HotelAvailRQ>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>`.trim();

module.exports = {
hotelAvailRequestTemplate
};
161 changes: 161 additions & 0 deletions test/mocks/seatmap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
{
"PointOfSale": {
"Location": {
"CountryCode": {
"@value": "CA"
}
},
"TouchPoint": {
"Device": {
"Code": "0.AAA.X",
"TableName": {}
}
}
},
"Party": {
"Participants": {
"Participant": {
"EnabledSystemParticipant": {
"@SequenceNumber": "1",
"Name": "WindingTreePOSCA",
"Category": "DC",
"SystemID": {
"@Owner": "ADS",
"@value": "mcmEL4qB"
}
}
}
}
},
"Document": {
"@id": "OneWay",
"Name": "NDC-Exchange",
"ReferenceVersion": "UAT-OTA-2010B"
},
"Query": {
"Offer": [
{
"@Owner": "AC",
"@OfferID": "HOT4YXITL4-OfferID-1",
"@ResponseID": "",
"PassengerID": [
{
"@value": "B1E9EC6A"
}
],
"SegmentID": [
{
"@value": "Z6AG2A6ZJL-SEG1"
},
{
"@value": "TY7A1U7AIM-SEG2"
}
]
}
]
},
"DataLists": {
"PassengerList": {
"Passenger": [
[
{
"@PassengerID": "B1E9EC6A",
"PTC": "ADT"
}
]
]
},
"FlightSegmentList": {
"FlightSegment": [
{
"@SegmentKey": "Z6AG2A6ZJL-SEG1",
"@refs": "M5E6W3S3VY-OD1",
"Departure": {
"AirportCode": "YYC",
"Date": "2020-09-14",
"Time": "07:00"
},
"Arrival": {
"AirportCode": "YYZ",
"Date": "2020-09-14",
"Time": "12:50",
"Terminal": {
"Name": "1"
}
},
"MarketingCarrier": {
"AirlineID": "AC",
"Name": "Air Canada",
"FlightNumber": "134",
"ResBookDesigCode": "T"
},
"OperatingCarrier": {
"Disclosures": {
"Description": {
"Text": "pJyAxvTLWDVvF8SySYd5TW2hGD96yqr9UnlLUkThnLG/17BjuAKyJQLIS8+5KZ+nWZ+eCqjGklc8V50L+k74WbqNq9ZO3IpGls6u+xccVld4Gup4vlJ+Oye7VT9dQMN4k79o+QVRFEynPWYDs9X8BA=="
}
}
},
"Equipment": {
"AircraftCode": "7M8"
},
"ClassOfService": {
"Code": "T"
},
"FlightDetail": {
"FlightDuration": {
"Value": ""
},
"Stops": {
"StopQuantity": "0"
}
}
},
{
"@SegmentKey": "TY7A1U7AIM-SEG2",
"@refs": "M5E6W3S3VY-OD1",
"Departure": {
"AirportCode": "YYZ",
"Date": "2020-09-14",
"Time": "14:50",
"Terminal": {
"Name": "1"
}
},
"Arrival": {
"AirportCode": "YYT",
"Date": "2020-09-14",
"Time": "19:19"
},
"MarketingCarrier": {
"AirlineID": "AC",
"Name": "Air Canada",
"FlightNumber": "1544",
"ResBookDesigCode": "T"
},
"OperatingCarrier": {
"Disclosures": {
"Description": {
"Text": "pJyAxvTLWDVvF8SySYd5TV8dpcsYUV67DAplC3QvK8JCV20YIAxokyvip2BMSJ7daGtED8EIJYrlpn8XB8pRX6r+QhxHHDS4OduCOeU5xip/veYLBfhQ9w=="
}
}
},
"Equipment": {
"AircraftCode": "321"
},
"ClassOfService": {
"Code": "T"
},
"FlightDetail": {
"FlightDuration": {
"Value": ""
},
"Stops": {
"StopQuantity": "0"
}
}
}
]
}
}
}
145 changes: 141 additions & 4 deletions test/spec/soapTemplates.js
Original file line number Diff line number Diff line change
@@ -18,6 +18,15 @@ const {
// mapSoapHeader,
// mapHotelResNotifSoap
} = require('../../helpers/soapTemplates/ota/otaHotelResNotifRQ');
const {
mapGuestCounts: mapGuestCountsHotelAvail,
mapCriterions,
hotelAvailRequestTemplate
} = require('../../helpers/soapTemplates/ota/otaHotelAvailRQ');
const {
seatAvailabilityRequestTemplate_AC
} = require('../../helpers/soapTemplates/seatAvailability');
const seatmapJson = require('../mocks/seatmap.json');

require('chai').should();

@@ -64,7 +73,7 @@ describe('soapTemplates', () => {
};

describe('#mapGuestCount', () => {

it('should map data', async () => {
const result = mapGuestCount(OTA_GuestCount);
(result).should.equal('<GuestCount AgeQualifyingCode="10" Count="1"/>');
@@ -79,7 +88,7 @@ describe('soapTemplates', () => {
});

describe('#mapGuestCounts', () => {

it('should map data', async () => {
const result = mapGuestCounts([
OTA_GuestCount,
@@ -117,19 +126,147 @@ describe('soapTemplates', () => {
});

describe('#mapPaymentCard', () => {

it('should map data', async () => {
const result = mapPaymentCard(OTA_PaymentCard);
(result).should.equal('<PaymentCard CardCode="VI" CardNumber="4444333322221111" CardType="1" ExpireDate="1024" SeriesCode="111"><CardHolderName>TEST</CardHolderName></PaymentCard>');
});
});

describe('#mapGuarantee', () => {

it('should map data', async () => {
const result = mapGuarantee(OTA_Guarantee);
(result).should.equal('<Guarantee\n GuaranteeType="GuaranteeRequired"\n GuaranteeCode="GCC"\n>\n <GuaranteesAccepted>\n <GuaranteeAccepted><PaymentCard CardCode="VI" CardNumber="4444333322221111" CardType="1" ExpireDate="1024" SeriesCode="111"><CardHolderName>TEST</CardHolderName></PaymentCard></GuaranteeAccepted>\n </GuaranteesAccepted>\n <GuaranteeDescription>\n <Text>Credit Card Guarantee</Text>\n </GuaranteeDescription>\n</Guarantee>');
});
});
});

describe('otaHotelAvailRQ', () => {
const guestCounts = [
{
AgeQualifyingCode: 10,
Count: 2
},
{
AgeQualifyingCode: 8,
Count: 1
}
];
const hotelSearchCriteria = [
{
HotelRef: {
HotelCode: '02034',
StayDateRange: {
Start: '2020-09-02',
Duration: 1,
RoomStayCandidates: {
RoomStayCandidate: {
Quantity: 3,
GuestCounts: guestCounts
}
}
}
}
}
];
const tpaExtensions = {
isDeepLinkRequired: {
DeepLinkType: 'URL',
isDeepLinkRequired: true
},
isContentRequired: {
isAmenityRequired: true,
isContentRequired: true
},
isCancellationPolicyRequired: {
isCancellationPolicyRequired: true
}
};
const hotelAvailRequest = {
OTA_HotelAvailRQ: {
AvailRatesOnly: true,
PrimaryLangID: 'EN',
RequestedCurrency: 'USD',
TimeStamp: '1980-03-21T00:00:00Z',
Version: '1.1',
xmlns: 'http://www.domain.com/soa/xsd/MessageHeader-V1_0',
POS: {
Source: {
RequestorID: {
ID: '17',
MessagePassword: 'Windingtree',
Name: 'Windingtree',
Type: '13',
},
BookingChannel: {
Primary: 'true',
Type: '2',
CompanyName: {
name: 'Windingtree',
Code: '245800'
}
}
}
},
AvailRequestSegments: {
AvailRequestSegment: {
AvailReqType: 'Both',
HotelSearchCriteria: hotelSearchCriteria,
}
},
TPA_Extensions: tpaExtensions
}
};

describe('#mapGuestCounts', () => {

it('should produce broken xml data if wrong count object has been provided', async () => {
const wrongGuestCounts1 = [
{
Count: 2
}
];
const wrongGuestCounts2 = [
{
AgeQualifyingCode: 10
}
];
let result = mapGuestCountsHotelAvail(wrongGuestCounts1);
(result).should.equal('\n <GuestCount AgeQualifyingCode="undefined" Count="2"/>');
result = mapGuestCountsHotelAvail(wrongGuestCounts2);
(result).should.equal('\n <GuestCount AgeQualifyingCode="10" Count="undefined"/>');
});

it('should map query to xml data', async () => {
const result = mapGuestCountsHotelAvail(guestCounts);
(result).should.equal('\n <GuestCount AgeQualifyingCode="10" Count="2"/>\n <GuestCount AgeQualifyingCode="8" Count="1"/>');
});
});

describe('#mapCriterions', () => {

it('should map query to xml data', async () => {
const result = mapCriterions(hotelSearchCriteria, tpaExtensions);
(result).should.equal('\n <Criterion>\n <StayDateRange Duration="1" Start="2020-09-02"/>\n <RoomStayCandidates>\n <RoomStayCandidate Quantity="3">\n <GuestCounts>\n \n <GuestCount AgeQualifyingCode="10" Count="2"/>\n <GuestCount AgeQualifyingCode="8" Count="1"/>\n </GuestCounts>\n </RoomStayCandidate>\n </RoomStayCandidates>\n <HotelRef HotelCode="02034"/>\n <TPA_Extensions>\n <isDeepLinkRequired DeepLinkType="URL" isDeepLinkRequired="true"/>\n <isContentRequired isAmenityRequired="true" isContentRequired="true"/>\n <isCancellationPolicyRequired CancellationPolicyRequired="true"/>\n </TPA_Extensions>\n </Criterion>');
});
});

describe('#hotelAvailRequestTemplate', () => {

it('should map query to xml data', async () => {
const result = hotelAvailRequestTemplate(hotelAvailRequest);
(result).should.equal('<?xml version="1.0" ?>\n<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">\n<SOAP-ENV:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">\n <wsse:Security SOAP-ENV:mustunderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">\n <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"/>\n </wsse:Security>\n <wsa:Action>http://www.opentravel.org/OTA/2003/05/getOTAHotelAvailability</wsa:Action>\n <wsa:MessageID>uuid:91a83ac1-8931-4618-ab49-692a25fa5a17</wsa:MessageID>\n</SOAP-ENV:Header>\n<SOAP-ENV:Body>\n <OTA_HotelAvailRQ AvailRatesOnly="true" EchoToken="TestPullWT1234" PrimaryLangID="EN" RequestedCurrency="USD" TimeStamp="1980-03-21T00:00:00Z" Version="1.1" xmlns="http://www.domain.com/soa/xsd/MessageHeader-V1_0">\n <POS>\n <Source>\n <RequestorID ID="17" MessagePassword="Windingtree" Name="Windingtree" Type="13"/>\n <BookingChannel Primary="true" Type="2">\n <CompanyName Code="245800">Windingtree</CompanyName>\n </BookingChannel>\n </Source>\n </POS>\n <AvailRequestSegments>\n <AvailRequestSegment AvailReqType="Both">\n <HotelSearchCriteria>\n \n <Criterion>\n <StayDateRange Duration="1" Start="2020-09-02"/>\n <RoomStayCandidates>\n <RoomStayCandidate Quantity="3">\n <GuestCounts>\n \n <GuestCount AgeQualifyingCode="10" Count="2"/>\n <GuestCount AgeQualifyingCode="8" Count="1"/>\n </GuestCounts>\n </RoomStayCandidate>\n </RoomStayCandidates>\n <HotelRef HotelCode="02034"/>\n <TPA_Extensions>\n <isDeepLinkRequired DeepLinkType="URL" isDeepLinkRequired="true"/>\n <isContentRequired isAmenityRequired="true" isContentRequired="true"/>\n <isCancellationPolicyRequired CancellationPolicyRequired="true"/>\n </TPA_Extensions>\n </Criterion>\n </HotelSearchCriteria>\n </AvailRequestSegment>\n </AvailRequestSegments>\n </OTA_HotelAvailRQ>\n</SOAP-ENV:Body>\n</SOAP-ENV:Envelope>');
});
});
});

describe('seatAvailability', () => {

describe('#seatAvailabilityRequestTemplate_AC', () => {
const result = seatAvailabilityRequestTemplate_AC(seatmapJson);
console.log(result);
(result).should.equal('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://sita.aero/NDC/NDCUtility/v2">\n<soapenv:Header/>\n<soapenv:Body>\n <v2:NDCMSG_Envelope>\n <NDCMSG_Header>\n <Function>SeatAvailabilityRQ</Function>\n <SchemaType>NDC</SchemaType>\n <SchemaVersion>YY.2017.2</SchemaVersion>\n <RichMedia>true</RichMedia>\n <Sender>\n <Address>\n <Company>WindingTree</Company>\n <NDCSystemId>DEV</NDCSystemId>\n </Address>\n </Sender>\n <Recipient>\n <Address>\n <Company>AC</Company>\n <NDCSystemId>DEV</NDCSystemId>\n </Address>\n </Recipient>\n </NDCMSG_Header>\n <NDCMSG_Body>\n <NDCMSG_Payload>\n <SeatAvailabilityRQ Version="2017.2" xmlns="http://www.iata.org/IATA/EDIST/2017.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\n <PointOfSale><Location><CountryCode>CA</CountryCode></Location><TouchPoint><Device><Code>0.AAA.X</Code><TableName /></Device></TouchPoint></PointOfSale><Party><Participants><Participant><EnabledSystemParticipant SequenceNumber="1"><Name>WindingTreePOSCA</Name><Category>DC</Category><SystemID Owner="ADS">mcmEL4qB</SystemID></EnabledSystemParticipant></Participant></Participants></Party><Document id="OneWay"><Name>NDC-Exchange</Name><ReferenceVersion>UAT-OTA-2010B</ReferenceVersion></Document><Query><Offer Owner="AC" OfferID="HOT4YXITL4-OfferID-1" ResponseID=""><PassengerID>B1E9EC6A</PassengerID><SegmentID>Z6AG2A6ZJL-SEG1</SegmentID><SegmentID>TY7A1U7AIM-SEG2</SegmentID></Offer></Query><DataLists><PassengerList><Passenger PassengerID="B1E9EC6A"><PTC>ADT</PTC></Passenger></PassengerList><FlightSegmentList><FlightSegment SegmentKey="Z6AG2A6ZJL-SEG1" refs="M5E6W3S3VY-OD1"><Departure><AirportCode>YYC</AirportCode><Date>2020-09-14</Date><Time>07:00</Time></Departure><Arrival><AirportCode>YYZ</AirportCode><Date>2020-09-14</Date><Time>12:50</Time><Terminal><Name>1</Name></Terminal></Arrival><MarketingCarrier><AirlineID>AC</AirlineID><Name>Air Canada</Name><FlightNumber>134</FlightNumber><ResBookDesigCode>T</ResBookDesigCode></MarketingCarrier><OperatingCarrier><Disclosures><Description><Text>pJyAxvTLWDVvF8SySYd5TW2hGD96yqr9UnlLUkThnLG/17BjuAKyJQLIS8+5KZ+nWZ+eCqjGklc8V50L+k74WbqNq9ZO3IpGls6u+xccVld4Gup4vlJ+Oye7VT9dQMN4k79o+QVRFEynPWYDs9X8BA==</Text></Description></Disclosures></OperatingCarrier><Equipment><AircraftCode>7M8</AircraftCode></Equipment><ClassOfService><Code>T</Code></ClassOfService><FlightDetail><FlightDuration><Value /></FlightDuration><Stops><StopQuantity>0</StopQuantity></Stops></FlightDetail></FlightSegment><FlightSegment SegmentKey="TY7A1U7AIM-SEG2" refs="M5E6W3S3VY-OD1"><Departure><AirportCode>YYZ</AirportCode><Date>2020-09-14</Date><Time>14:50</Time><Terminal><Name>1</Name></Terminal></Departure><Arrival><AirportCode>YYT</AirportCode><Date>2020-09-14</Date><Time>19:19</Time></Arrival><MarketingCarrier><AirlineID>AC</AirlineID><Name>Air Canada</Name><FlightNumber>1544</FlightNumber><ResBookDesigCode>T</ResBookDesigCode></MarketingCarrier><OperatingCarrier><Disclosures><Description><Text>pJyAxvTLWDVvF8SySYd5TV8dpcsYUV67DAplC3QvK8JCV20YIAxokyvip2BMSJ7daGtED8EIJYrlpn8XB8pRX6r+QhxHHDS4OduCOeU5xip/veYLBfhQ9w==</Text></Description></Disclosures></OperatingCarrier><Equipment><AircraftCode>321</AircraftCode></Equipment><ClassOfService><Code>T</Code></ClassOfService><FlightDetail><FlightDuration><Value /></FlightDuration><Stops><StopQuantity>0</StopQuantity></Stops></FlightDetail></FlightSegment></FlightSegmentList></DataLists>\n </SeatAvailabilityRQ>\n </NDCMSG_Payload>\n </NDCMSG_Body>\n </v2:NDCMSG_Envelope>\n</soapenv:Body>\n</soapenv:Envelope>');
});
});
});