Skip to content

Commit

Permalink
stripping analytics ID from onbuild test
Browse files Browse the repository at this point in the history
  • Loading branch information
colbyfayock committed Oct 11, 2023
1 parent c167304 commit e18cbd3
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion netlify-plugin-cloudinary/tests/on-build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,18 @@ describe('onBuild', () => {
deliveryType
}
});


// The analytics string that's added to the URLs is dynamic based on package version.
// The resulting value is also not static, so we can't simply add it to the end of the
// URL, so strip the analytics from the URLs as it's not important for this particular
// test, being covered elsewhere.

redirects.forEach(redirect => {
if ( redirect.to.includes('https://res.cloudinary.com') ) {
redirect.to = redirect.to.split('?')[0];
}
})

expect(redirects[0]).toEqual({
from: `${imagesPath}/*`,
to: `https://res.cloudinary.com/${process.env.CLOUDINARY_CLOUD_NAME}/image/${deliveryType}/f_auto,q_auto/${process.env.URL}/cld-assets${imagesPath}/:splat`,
Expand Down Expand Up @@ -150,6 +161,17 @@ describe('onBuild', () => {
}
});

// The analytics string that's added to the URLs is dynamic based on package version.
// The resulting value is also not static, so we can't simply add it to the end of the
// URL, so strip the analytics from the URLs as it's not important for this particular
// test, being covered elsewhere.

redirects.forEach(redirect => {
if ( redirect.to.includes('https://res.cloudinary.com') ) {
redirect.to = redirect.to.split('?')[0];
}
})

expect(redirects[0]).toEqual({
from: `${imagesPath}/*`,
to: `https://res.cloudinary.com/${process.env.CLOUDINARY_CLOUD_NAME}/image/${deliveryType}/f_auto,q_auto/${process.env.DEPLOY_PRIME_URL}/cld-assets${imagesPath}/:splat`,
Expand Down Expand Up @@ -201,6 +223,17 @@ describe('onBuild', () => {
}
});

// The analytics string that's added to the URLs is dynamic based on package version.
// The resulting value is also not static, so we can't simply add it to the end of the
// URL, so strip the analytics from the URLs as it's not important for this particular
// test, being covered elsewhere.

redirects.forEach(redirect => {
if ( redirect.to.includes('https://res.cloudinary.com') ) {
redirect.to = redirect.to.split('?')[0];
}
})

expect(redirects[0]).toEqual({
from: `${imagesPath[1]}/*`,
to: `https://res.cloudinary.com/${process.env.CLOUDINARY_CLOUD_NAME}/image/${deliveryType}/f_auto,q_auto/${process.env.DEPLOY_PRIME_URL}/cld-assets${imagesPath[1]}/:splat`,
Expand Down

0 comments on commit e18cbd3

Please sign in to comment.