diff --git a/src/MenuBuilder.js b/src/MenuBuilder.js index a650bb44..7adb9fc6 100644 --- a/src/MenuBuilder.js +++ b/src/MenuBuilder.js @@ -209,7 +209,7 @@ export default class MenuBuilder { const examples = methodObj.examples; if ((hasTag(methodObj, 'property') || hasTag(methodObj, 'property:readonly')) && !hasTag(methodObj, 'property:immutable')) { examples.push({ - name: CONSTANTS.SUBSCRIBE + ' ' + methodObj.name, + name: CONSTANTS.ADDITIONAL_SUBSCRIBE + ' ' + methodObj.name, schema: { type: 'number', }, diff --git a/src/MethodFilters.js b/src/MethodFilters.js index 696a64bb..935af2b5 100644 --- a/src/MethodFilters.js +++ b/src/MethodFilters.js @@ -71,7 +71,7 @@ export default class MethodFilters { isSubscribeMethod(method) { let isSubscribe = false; - if (method.name && method.name.split(' ')[0] === CONSTANTS.SUBSCRIBE) { + if (method.name && method.name.startsWith(CONSTANTS.ADDITIONAL_SUBSCRIBE)) { isSubscribe = true; } return isSubscribe; diff --git a/src/constant.js b/src/constant.js index 556239f6..6293b105 100644 --- a/src/constant.js +++ b/src/constant.js @@ -151,6 +151,7 @@ export const CONSTANTS = { METHODS_TO_BE_EXCLUDED_ONLY_DEVICES: [], PUBSUB_ACK: { pubSubStatus: 'Connection successful' }, SUBSCRIBE: 'Subscribe', + ADDITIONAL_SUBSCRIBE: 'Subscribing additional method', PROVIDER_REGISTRATION: 'provider registered successfully', PROVIDER_REGISTRATION_FAILED: 'Provider registeration failed', NO_PROVIDER_SPECIFIED: 'No provider has been specified', diff --git a/test/unit/MethodFilters.test.js b/test/unit/MethodFilters.test.js index b0701078..ba53f649 100644 --- a/test/unit/MethodFilters.test.js +++ b/test/unit/MethodFilters.test.js @@ -177,16 +177,23 @@ describe('MethodFilters', () => { describe('isSubscribeMethod', () => { test('should return true if method has Subscribe in it', () => { - method = { name: 'Subscribe device.id' }; + method = { name: 'Subscribing additional method device.id' }; result = methodFilters.isSubscribeMethod(method); expect(result).toBe(true); }); + test('should return false if method does not have subscribe in it ', () => { method = { name: 'account.id' }; result = methodFilters.isSubscribeMethod(method); expect(result).toBe(false); }); + test('should return false if method does not have subscribe in it ', () => { + method = { name: 'Subscribe to settings' }; + result = methodFilters.isSubscribeMethod(method); + expect(result).toBe(false); + }); + test('should return false if method has Subscribe but not in the beginning ', () => { method = { name: 'account.id Subscribe' }; result = methodFilters.isSubscribeMethod(method);