From 9d2ca30da74edafbe760b964fa7754d6c48d3051 Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Tue, 22 Aug 2023 17:01:17 -0700 Subject: [PATCH 1/2] Add missing lowercase and uppercase transformations --- .npmignore | 3 ++- index.js | 6 ++++++ index.test.js | 18 ++++++++++++++++++ package.json | 2 +- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.npmignore b/.npmignore index ac30482..77bad7b 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,3 @@ index.js -index.test.js \ No newline at end of file +index.test.js +.github \ No newline at end of file diff --git a/index.js b/index.js index 60f887c..40877b6 100644 --- a/index.js +++ b/index.js @@ -26,6 +26,12 @@ const createEnum = (type, options = {}) => { // Apply casing transformations switch (options.casing) { + case 'lowercase': + value = value.toLowerCase(); + break; + case 'uppercase': + value = value.toUpperCase(); + break; case 'camelCase': value = toCamelCase(value); break; diff --git a/index.test.js b/index.test.js index 1c3b685..7faf2ee 100644 --- a/index.test.js +++ b/index.test.js @@ -9,7 +9,25 @@ describe('String Enums', () => { expect(Winter).toEqual('Winter') expect(Spring).toEqual('Spring') }) + + test('creates enum with lowercase casing', () => { + const { Summer, Autumn, Winter, Spring } = Enum.String({ casing: "lowercase" }) + + expect(Summer).toEqual('summer') + expect(Autumn).toEqual('autumn') + expect(Winter).toEqual('winter') + expect(Spring).toEqual('spring') + }) + test('creates enum with uppercase casing', () => { + const { Summer, Autumn, Winter, Spring } = Enum.String({ casing: "uppercase" }) + + expect(Summer).toEqual('SUMMER') + expect(Autumn).toEqual('AUTUMN') + expect(Winter).toEqual('WINTER') + expect(Spring).toEqual('SPRING') + }) + test('creates enum with snakeCase casing', () => { const { userId, userAddress, orderNumber } = Enum.String({ casing: 'snakeCase' }) diff --git a/package.json b/package.json index 0927328..ce7665e 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "dev": "microbundle watch", "test": "NODE_OPTIONS=--experimental-vm-modules jest", "build": "microbundle", - "publish": "npm run build && npm publish" + "prepublishOnly": "npm test && npm run build" }, "license": "ISC", "devDependencies": { From dbafc01a7f7a1c37a51a6362caa0b7e484e1abce Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Tue, 22 Aug 2023 17:01:53 -0700 Subject: [PATCH 2/2] Bump version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index d06616b..e3a0b25 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "enum-xyz", - "version": "0.3.0", + "version": "0.3.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "enum-xyz", - "version": "0.3.0", + "version": "0.3.1", "license": "ISC", "devDependencies": { "jest": "^27.5.1", diff --git a/package.json b/package.json index ce7665e..e34155a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "enum-xyz", "type": "module", - "version": "0.3.0", + "version": "0.3.1", "description": "JavaScript enums using proxies.", "homepage": "https://github.com/chasefleming/enum-xyz", "author": "Chase Fleming",