Skip to content

Commit

Permalink
feat(medusa): Convert ShippingProfileService to TypeScript (#1963)
Browse files Browse the repository at this point in the history
  • Loading branch information
pKorsholm committed Aug 8, 2022
1 parent 40ae535 commit 152934f
Show file tree
Hide file tree
Showing 8 changed files with 519 additions and 512 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-papayas-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

Convert ShippingProfileService to TypeScript
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default (app) => {
return app
}

export const defaultAdminShippingProfilesFields = [
export const defaultAdminShippingProfilesFields: (keyof ShippingProfile)[] = [
"id",
"name",
"type",
Expand All @@ -43,10 +43,8 @@ export const defaultAdminShippingProfilesFields = [

export type AdminDeleteShippingProfileRes = DeleteResponse

export const defaultAdminShippingProfilesRelations = [
"products",
"shipping_options",
]
export const defaultAdminShippingProfilesRelations: (keyof ShippingProfile)[] =
["products", "shipping_options"]

export type AdminShippingProfilesRes = {
shipping_profile: ShippingProfile
Expand Down
18 changes: 9 additions & 9 deletions packages/medusa/src/services/__tests__/shipping-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ describe("ShippingProfileService", () => {

describe("update", () => {
const profRepo = MockRepository({
findOne: q => {
findOne: (q) => {
return Promise.resolve({ id: q.where.id })
},
})

const productService = {
update: jest.fn(),
withTransaction: function() {
withTransaction: function () {
return this
},
}

const shippingOptionService = {
update: jest.fn(),
withTransaction: function() {
withTransaction: function () {
return this
},
}
Expand Down Expand Up @@ -98,7 +98,7 @@ describe("ShippingProfileService", () => {

describe("delete", () => {
const profRepo = MockRepository({
findOne: q => {
findOne: (q) => {
return Promise.resolve({ id: q.where.id })
},
})
Expand Down Expand Up @@ -126,7 +126,7 @@ describe("ShippingProfileService", () => {

const productService = {
update: jest.fn(),
withTransaction: function() {
withTransaction: function () {
return this
},
}
Expand Down Expand Up @@ -156,7 +156,7 @@ describe("ShippingProfileService", () => {

describe("fetchCartOptions", () => {
const profRepo = MockRepository({
find: q => {
find: (q) => {
switch (q.where.id) {
default:
return Promise.resolve([
Expand Down Expand Up @@ -188,8 +188,8 @@ describe("ShippingProfileService", () => {
},
])
}),
validateCartOption: jest.fn().mockImplementation(s => s),
withTransaction: function() {
validateCartOption: jest.fn().mockImplementation((s) => s),
withTransaction: function () {
return this
},
}
Expand Down Expand Up @@ -301,7 +301,7 @@ describe("ShippingProfileService", () => {

const shippingOptionService = {
update: jest.fn(),
withTransaction: function() {
withTransaction: function () {
return this
},
}
Expand Down

0 comments on commit 152934f

Please sign in to comment.