UNPKG

@openactive/models-ts

Version:

JavaScript/TypeScript implementation of OpenActive's data model

192 lines (189 loc) 6.07 kB
// This file was generated using the booking_spec_examples/orderstatus_example_1.json example from @openactive/data-models import { expect } from 'chai'; import { Order, validateOrder, OaValidationError } from '../..'; describe('data-models example - booking_spec_examples/orderstatus_example_1.json', () => { /* Because the tests are also checked by `tsc`, this declaration acts as a test to ensure that the generated type correctly identifies this valid example */ const example: Order = { "@context": "https://openactive.io/", "@type": "Order", "@id": "https://example.com/api/orders/e11429ea-467f-4270-ab62-e47368996fe8", "brokerRole": "https://openactive.io/AgentBroker", "broker": { "@type": "Organization", "name": "MyFitnessApp", "url": "https://myfitnessapp.example.com", "description": "A fitness app for all the community", "logo": { "@type": "ImageObject", "url": "http://data.myfitnessapp.org.uk/images/logo.png" }, "address": { "@type": "PostalAddress", "streetAddress": "Alan Peacock Way", "addressLocality": "Village East", "addressRegion": "Middlesbrough", "postalCode": "TS4 3AE", "addressCountry": "GB" } }, "customer": { "@type": "Person", "email": "geoffcapes@example.com", "telephone": "020 811 8055", "givenName": "Geoff", "familyName": "Capes" }, "seller": { "@type": "Organization", "@id": "https://example.com/api/organisations/123", "identifier": "CRUOZWJ1", "name": "Better", "taxMode": "https://openactive.io/TaxGross", "legalName": "Greenwich Leisure Limited", "description": "A charitable social enterprise for all the community", "url": "https://www.better.org.uk", "logo": { "@type": "ImageObject", "url": "http://data.better.org.uk/images/logo.png" }, "telephone": "020 3457 8700", "email": "customerservices@gll.org", "vatID": "GB 789 1234 56", "address": { "@type": "PostalAddress", "streetAddress": "Alan Peacock Way", "addressLocality": "Village East", "addressRegion": "Middlesbrough", "postalCode": "TS4 3AE", "addressCountry": "GB" }, "termsOfService": [ { "@type": "PrivacyPolicy", "name": "Privacy Policy", "url": "https://example.com/privacy-policy", "requiresExplicitConsent": false }, { "@type": "TermsOfUse", "name": "Terms and Conditions", "url": "https://example.com/terms-and-conditions", "dateModified": "2019-04-16T20:31:13Z", "requiresExplicitConsent": true } ] }, "bookingService": { "@type": "BookingService", "name": "Playwaze", "url": "http://www.playwaze.com", "termsOfService": [ { "@type": "Terms", "name": "Terms of Service", "url": "https://brokerexample.com/terms.html", "requiresExplicitConsent": false } ] }, "orderedItem": [ { "@type": "OrderItem", "@id": "https://example.com/api/orders/e11429ea-467f-4270-ab62-e47368996fe8#/orderedItem/1234", "orderItemStatus": "https://openactive.io/OrderItemConfirmed", "unitTaxSpecification": [ { "@type": "TaxChargeSpecification", "name": "VAT at 20%", "price": 1, "priceCurrency": "GBP", "rate": 0.2 } ], "acceptedOffer": { "@type": "Offer", "@id": "https://example.com/events/452#/offers/878", "description": "Winger space for Speedball.", "name": "Speedball winger position", "price": 10, "priceCurrency": "GBP", "validFromBeforeStartDate": "P6D", "allowCustomerCancellationFullRefund": true, "latestCancellationBeforeStartDate": "P1D" }, "orderedItem": { "@type": "ScheduledSession", "@id": "https://example.com/events/452/subEvents/132", "identifier": 123, "eventStatus": "https://schema.org/EventScheduled", "startDate": "2018-10-30T11:00:00Z", "endDate": "2018-10-30T12:00:00Z", "duration": "PT1H", "superEvent": { "@type": "SessionSeries", "@id": "https://api.example.com/events/452", "name": "Bodypump", "activity": [ { "@type": "Concept", "@id": "https://openactive.io/activity-list#5e78bcbe-36db-425a-9064-bf96d09cc351", "prefLabel": "Bodypump™", "inScheme": "https://openactive.io/activity-list" } ], "url": "https://example.com/events/452", "location": { "@type": "Place", "url": "https://www.everyoneactive.com/centres/Middlesbrough-Sports-Village", "name": "Middlesbrough Sports Village", "identifier": "0140", "address": { "@type": "PostalAddress", "streetAddress": "Alan Peacock Way", "addressLocality": "Village East", "addressRegion": "Middlesbrough", "postalCode": "TS4 3AE", "addressCountry": "GB" }, "geo": { "@type": "GeoCoordinates", "latitude": 54.543964, "longitude": -1.20978500000001 } } } }, "accessPass": [ { "@type": "Barcode", "text": "0123456789" } ] } ], "totalPaymentDue": { "@type": "PriceSpecification", "price": 5, "priceCurrency": "GBP" }, "totalPaymentTax": [ { "@type": "TaxChargeSpecification", "name": "VAT at 20%", "price": 1, "priceCurrency": "GBP", "rate": 0.2 } ], "payment": { "@type": "Payment", "name": "AcmeBroker Points", "identifier": "1234567890npduy2f" } }; it('should validate correctly', () => { const result = validateOrder(example); expect(result).to.not.be.an.instanceof(OaValidationError); }); });