Skip to content

Commit cb70a38

Browse files
authored
Merge pull request #17 from chasefleming/fix/lower-upper
Add missing lowercase and uppercase transformations
2 parents 1593db4 + dbafc01 commit cb70a38

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

.npmignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
index.js
2-
index.test.js
2+
index.test.js
3+
.github

index.js

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ const createEnum = (type, options = {}) => {
2626

2727
// Apply casing transformations
2828
switch (options.casing) {
29+
case 'lowercase':
30+
value = value.toLowerCase();
31+
break;
32+
case 'uppercase':
33+
value = value.toUpperCase();
34+
break;
2935
case 'camelCase':
3036
value = toCamelCase(value);
3137
break;

index.test.js

+18
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,25 @@ describe('String Enums', () => {
99
expect(Winter).toEqual('Winter')
1010
expect(Spring).toEqual('Spring')
1111
})
12+
13+
test('creates enum with lowercase casing', () => {
14+
const { Summer, Autumn, Winter, Spring } = Enum.String({ casing: "lowercase" })
15+
16+
expect(Summer).toEqual('summer')
17+
expect(Autumn).toEqual('autumn')
18+
expect(Winter).toEqual('winter')
19+
expect(Spring).toEqual('spring')
20+
})
1221

22+
test('creates enum with uppercase casing', () => {
23+
const { Summer, Autumn, Winter, Spring } = Enum.String({ casing: "uppercase" })
24+
25+
expect(Summer).toEqual('SUMMER')
26+
expect(Autumn).toEqual('AUTUMN')
27+
expect(Winter).toEqual('WINTER')
28+
expect(Spring).toEqual('SPRING')
29+
})
30+
1331
test('creates enum with snakeCase casing', () => {
1432
const { userId, userAddress, orderNumber } = Enum.String({ casing: 'snakeCase' })
1533

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "enum-xyz",
33
"type": "module",
4-
"version": "0.3.0",
4+
"version": "0.3.1",
55
"description": "JavaScript enums using proxies.",
66
"homepage": "https://github.com/chasefleming/enum-xyz",
77
"author": "Chase Fleming",
@@ -21,7 +21,7 @@
2121
"dev": "microbundle watch",
2222
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
2323
"build": "microbundle",
24-
"publish": "npm run build && npm publish"
24+
"prepublishOnly": "npm test && npm run build"
2525
},
2626
"license": "ISC",
2727
"devDependencies": {

0 commit comments

Comments
 (0)