feat(medusa, types): Improve DX of model extensions (#4398)

This commit is contained in:
Riqwan Thamir
2023-06-29 13:45:16 +02:00
committed by GitHub
parent 1e88b4d5d9
commit 9760d4a96c
17 changed files with 405 additions and 39 deletions
@@ -0,0 +1,36 @@
import { toCamelCase } from "../to-camel-case"
describe("toCamelCase", function () {
it("should convert all cases to camel case", function () {
const expectations = [
{
input: "testing-camelize",
output: "testingCamelize",
},
{
input: "testing-Camelize",
output: "testingCamelize",
},
{
input: "TESTING-CAMELIZE",
output: "testingCamelize",
},
{
input: "this_is-A-test",
output: "thisIsATest",
},
{
input: "this_is-A-test ANOTHER",
output: "thisIsATestAnother",
},
{
input: "testingAlreadyCamelized",
output: "testingAlreadyCamelized",
},
]
expectations.forEach((expectation) => {
expect(toCamelCase(expectation.input)).toEqual(expectation.output)
})
})
})
@@ -0,0 +1,36 @@
import { upperCaseFirst } from "../upper-case-first"
describe("upperCaseFirst", function () {
it("should convert first letter of the word to capital letter", function () {
const expectations = [
{
input: "testing capitalize",
output: "Testing capitalize",
},
{
input: "testing",
output: "Testing",
},
{
input: "Testing",
output: "Testing",
},
{
input: "TESTING",
output: "TESTING",
},
{
input: "t",
output: "T",
},
{
input: "",
output: "",
},
]
expectations.forEach((expectation) => {
expect(upperCaseFirst(expectation.input)).toEqual(expectation.output)
})
})
})