svelte-cloudinary icon indicating copy to clipboard operation
svelte-cloudinary copied to clipboard

feat: #147 GetCldOgImageUrl Tests

Open sccalabr opened this issue 1 year ago • 11 comments

Description

Creating basic tests for GetCldOgImageUrl

Issue Ticket Number

Fixes #147

Type of change

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] Fix or improve the documentation
  • [ ] This change requires a documentation update

Checklist

  • [x] I have followed the contributing guidelines of this project as mentioned in CONTRIBUTING.md
  • [x] I have created an issue ticket for this PR
  • [x] I have checked to ensure there aren't other open Pull Requests for the same update/change?
  • [x] I have performed a self-review of my own code
  • [x] I have run tests locally to ensure they all pass
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] I have made corresponding changes needed to the documentation

sccalabr avatar Oct 01 '24 23:10 sccalabr

⚠️ No Changeset found

Latest commit: 122a5de771e4db7dcac984d01be28b58843591fa

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Oct 01 '24 23:10 changeset-bot[bot]

@sccalabr is attempting to deploy a commit to the Cloudinary DevX Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Oct 01 '24 23:10 vercel[bot]

I am having a hard time testing this. I am running the pnpm run tests but I am getting

if (!config.cloud?.cloudName) {
     20|   throw new Error('[svelte-cloudinary] unable to find a cloud name');
       |         ^
     21|  }

My .env has

VITE_CLOUDINARY_CLOUD_NAME
VITE_CLOUDINARY_API_KEY

so not really sure what I am missing

sccalabr avatar Oct 01 '24 23:10 sccalabr

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
svelte-cloudinary ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 2, 2024 10:18am

vercel[bot] avatar Oct 02 '24 10:10 vercel[bot]

My .env has

Is the cloud name filled out with your cloud name from the dashboard?

ghostdevv avatar Oct 02 '24 10:10 ghostdevv

Oh I think I see - for tests we don't use a real cloud name, as we aren't actually making any requests to cloudinary. We're only testing the output to see if it's what we expect, for example that it contains the correct width. When testing a component you can use the config prop (example), but here we use the second argument to getCldOgImage to pass the cloud.cloudName arg, which can be anything as it's not real. I've been using testing as a dummy cloud name.

Does that make sense?

ghostdevv avatar Oct 02 '24 10:10 ghostdevv

My .env has

Is the cloud name filled out with your cloud name from the dashboard?

Im pretty sure it is. I got it from the api account dashboard. I'll double check later today

sccalabr avatar Oct 03 '24 16:10 sccalabr

Oh I think I see - for tests we don't use a real cloud name, as we aren't actually making any requests to cloudinary. We're only testing the output to see if it's what we expect, for example that it contains the correct width. When testing a component you can use the config prop (example), but here we use the second argument to getCldOgImage to pass the cloud.cloudName arg, which can be anything as it's not real. I've been using testing as a dummy cloud name.

Does that make sense?

I see, let me give that a try :)

sccalabr avatar Oct 03 '24 16:10 sccalabr

awesome! let me know if you need any more help :pray:

ghostdevv avatar Oct 04 '24 01:10 ghostdevv

I think I got it working. Let me know what you think!

sccalabr avatar Oct 05 '24 19:10 sccalabr

Last things! Are you getting an error in your IDE about missing an alt property in any of these options?

I am not seeing any errors in vscode for that. Should I be?

sccalabr avatar Oct 08 '24 03:10 sccalabr

I am not seeing any errors in vscode for that. Should I be?

Ah, no you're right - I was getting confused with the component version :sweat_smile:

ghostdevv avatar Oct 09 '24 13:10 ghostdevv

perfect, thank you!

ghostdevv avatar Oct 11 '24 02:10 ghostdevv

@all-contributors please add @sccalabr for test

ghostdevv avatar Oct 11 '24 02:10 ghostdevv

@ghostdevv

I've put up a pull request to add @sccalabr! :tada:

allcontributors[bot] avatar Oct 11 '24 02:10 allcontributors[bot]

@sccalabr thanks for your contribution. This PR is eligible for free Cloudinary Hacktoberfest swag. Please send me an email to [email protected] with your name, GitHub username, a link to this PR. Happy Hacktoberfest!

colbyfayock avatar Oct 12 '24 02:10 colbyfayock