|
| 1 | +import type { WebApplication } from "schema-dts" |
| 2 | +import { webApp } from "./web-app" |
| 3 | + |
| 4 | +describe("webApp", () => { |
| 5 | + it("should return the correct structured data", () => { |
| 6 | + const data: WebApplication = { |
| 7 | + "@type": "WebApplication", |
| 8 | + name: "Example Web App", |
| 9 | + url: "https://example.com", |
| 10 | + browserRequirements: "Chrome 90+, Firefox 88+", |
| 11 | + offers: { |
| 12 | + "@type": "Offer", |
| 13 | + price: "0.00", |
| 14 | + priceCurrency: "USD", |
| 15 | + }, |
| 16 | + } |
| 17 | + |
| 18 | + expect(webApp(data)).toEqual({ |
| 19 | + "@context": "https://schema.org", |
| 20 | + ...data, |
| 21 | + }) |
| 22 | + }) |
| 23 | + |
| 24 | + it("should return the correct structured data with an image", () => { |
| 25 | + const data: WebApplication = { |
| 26 | + "@type": "WebApplication", |
| 27 | + name: "Example Web App", |
| 28 | + url: "https://example.com", |
| 29 | + browserRequirements: "Chrome 90+, Firefox 88+", |
| 30 | + offers: { |
| 31 | + "@type": "Offer", |
| 32 | + price: "0.00", |
| 33 | + priceCurrency: "USD", |
| 34 | + }, |
| 35 | + image: "https://example.com/example-app.jpg", |
| 36 | + } |
| 37 | + |
| 38 | + expect(webApp(data)).toEqual({ |
| 39 | + "@context": "https://schema.org", |
| 40 | + ...data, |
| 41 | + }) |
| 42 | + }) |
| 43 | + |
| 44 | + it("should return the correct structured data with a description", () => { |
| 45 | + const data: WebApplication = { |
| 46 | + "@type": "WebApplication", |
| 47 | + name: "Example Web App", |
| 48 | + url: "https://example.com", |
| 49 | + browserRequirements: "Chrome 90+, Firefox 88+", |
| 50 | + offers: { |
| 51 | + "@type": "Offer", |
| 52 | + price: "0.00", |
| 53 | + priceCurrency: "USD", |
| 54 | + }, |
| 55 | + description: "An example web application description.", |
| 56 | + } |
| 57 | + |
| 58 | + expect(webApp(data)).toEqual({ |
| 59 | + "@context": "https://schema.org", |
| 60 | + ...data, |
| 61 | + }) |
| 62 | + }) |
| 63 | +}) |
0 commit comments