|
| 1 | +/** |
| 2 | + * @jest-environment node |
| 3 | + */ |
| 4 | +import { AdvancedImage } from "../../src"; |
| 5 | +import { CloudinaryImage } from "@cloudinary/url-gen/assets/CloudinaryImage"; |
| 6 | +import { createSSRApp } from "vue"; |
| 7 | +import { renderToString } from "vue/server-renderer"; |
| 8 | +import { SDKAnalyticsConstants } from "../../src/internal/SDKAnalyticsConstants"; |
| 9 | +import { testIf } from "./utils"; |
| 10 | + |
| 11 | +const cloudinaryImage = new CloudinaryImage("sample", { cloudName: "demo" }); |
| 12 | + |
| 13 | +describe("analytics", () => { |
| 14 | + testIf( |
| 15 | + !(process.env.VUE3_TEST_ENV === "DIST"), |
| 16 | + "creates an img with analytics using src", |
| 17 | + async () => { |
| 18 | + // Update src analytics value |
| 19 | + SDKAnalyticsConstants.sdkSemver = "1.0.0"; |
| 20 | + SDKAnalyticsConstants.techVersion = "10.2.5"; |
| 21 | + |
| 22 | + const app = createSSRApp({ |
| 23 | + template: '<AdvancedImage :cldImg="cldImg" />', |
| 24 | + data: () => ({ |
| 25 | + cldImg: cloudinaryImage, |
| 26 | + }), |
| 27 | + components: { AdvancedImage }, |
| 28 | + }); |
| 29 | + const html = await renderToString(app); |
| 30 | + expect(html).toMatch( |
| 31 | + '<img src="https://res.cloudinary.com/demo/image/upload/sample?_a=AL' |
| 32 | + ); |
| 33 | + } |
| 34 | + ); |
| 35 | + |
| 36 | + testIf( |
| 37 | + process.env.VUE3_TEST_ENV === "DIST", |
| 38 | + "creates an img with analytics using dist", |
| 39 | + async () => { |
| 40 | + const app = createSSRApp({ |
| 41 | + template: '<AdvancedImage :cldImg="cldImg" />', |
| 42 | + data: () => ({ |
| 43 | + cldImg: cloudinaryImage, |
| 44 | + }), |
| 45 | + components: { AdvancedImage }, |
| 46 | + }); |
| 47 | + const html = await renderToString(app); |
| 48 | + expect(html).toMatch( |
| 49 | + '<img src="https://res.cloudinary.com/demo/image/upload/sample?_a=AL' |
| 50 | + ); |
| 51 | + } |
| 52 | + ); |
| 53 | +}); |
0 commit comments