medusa icon indicating copy to clipboard operation
medusa copied to clipboard

Rfc/testing repositories

Open richardwardza opened this issue 2 years ago • 1 comments

This is a request for comment and not to be merged.

I want to check a pattern I'm using when converting the tests to typescript.

With the update some of the data being used needs to be actual repositories and no longer "loose data". eg:

 const discount = {
        rule: {
          type: "percentage",
          value: 10,
        },
      }
     
      res = totalsService.getAllocationItemDiscounts(discount, cart)

Now needs to be :

      const discount = discountRepositoryMock.create({
        rule: {
          type: DiscountRuleType.PERCENTAGE,
          value: 10,
        },
      })

      res = totalsService.getAllocationItemDiscounts(discount, cart)

Is the pattern I have in this PR correct - I'm putting the discountRepositoryMock in the src/repositories/__mocks__/discount.js file (obviously that needs to be changed to ts too) ?

richardwardza avatar Aug 10 '22 07:08 richardwardza

⚠️ No Changeset found

Latest commit: ccd7db52e8dbd34d8ca1b63c8abbb36fef661ae1

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 Aug 10 '22 07:08 changeset-bot[bot]