From 760ce2b7ca4ef667a747816820b600018ca2e8fc Mon Sep 17 00:00:00 2001 From: Daniel McCartney Date: Wed, 17 Aug 2016 16:23:42 -0700 Subject: [PATCH] fix upper-under formatting --- lib/helper.js | 2 +- tests/project_test.js | 5 +++-- tests/protos/services.proto | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/helper.js b/lib/helper.js index e6394ba..76f54c1 100644 --- a/lib/helper.js +++ b/lib/helper.js @@ -85,7 +85,7 @@ exports.toTitleCase = function(str) { * @return {string} */ exports.toUpperUnderscoreCase = function(str) { - return String(str).replace(/([A-Z])/g, '_$1').toUpperCase() + return String(str).replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase() } diff --git a/tests/project_test.js b/tests/project_test.js index 4127125..ace566d 100644 --- a/tests/project_test.js +++ b/tests/project_test.js @@ -174,8 +174,9 @@ builder.add(function testServiceTypeResolution(test) { var running = shoes.services[0] test.equal('shoes.RunningShoe', running.fullName) - test.equal('Lace', running.methods[0].name) - test.equal('lace', running.methods[0].camelName) + test.equal('LaceShoe', running.methods[0].name) + test.equal('laceShoe', running.methods[0].camelName) + test.equal('LACE_SHOE', running.methods[0].upperUnderscoreName) var laceMethod = running.methods[0] test.equal('shoes.Shoe', laceMethod.inputTypeDescriptor.fullName) test.equal('shoes.FullShoe', laceMethod.outputTypeDescriptor.fullName) diff --git a/tests/protos/services.proto b/tests/protos/services.proto index 7ace0f0..2bbc24a 100644 --- a/tests/protos/services.proto +++ b/tests/protos/services.proto @@ -12,6 +12,6 @@ message FullShoe { } service RunningShoe { - rpc Lace (Shoe) returns (FullShoe); + rpc LaceShoe (Shoe) returns (FullShoe); rpc Stride (Shoe) returns (FullShoe); } \ No newline at end of file