feat(medusa, types): Improve DX of model extensions (#4398)
This commit is contained in:
@@ -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)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user