From 3f55310e8e390143d5751e2f8607c48b6c847a64 Mon Sep 17 00:00:00 2001 From: "Kandasamy, Divya" Date: Thu, 21 Nov 2024 14:04:52 -0500 Subject: [PATCH 1/2] Fix for the triggering badger events in the sanity --- src/MenuBuilder.js | 2 +- src/MethodFilters.js | 2 +- src/constant.js | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/MenuBuilder.js b/src/MenuBuilder.js index c17fcf31..04b93b82 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 af715890..d05f077d 100644 --- a/src/MethodFilters.js +++ b/src/MethodFilters.js @@ -68,7 +68,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 dbc62c97..d47d4425 100644 --- a/src/constant.js +++ b/src/constant.js @@ -130,6 +130,7 @@ export const CONSTANTS = { METHODS_TO_BE_EXCLUDED_ONLY_DEVICES: [], PUBSUB_ACK: { pubSubStatus: 'Connection successful' }, SUBSCRIBE: 'Subscribe', + ADDITIONAL_SUBSCRIBE: 'Subscribing additional methods', PROVIDER_REGISTRATION: 'provider registered successfully', PROVIDER_REGISTRATION_FAILED: 'Provider registeration failed', NO_PROVIDER_SPECIFIED: 'No provider has been specified', From 983c701934237c76854bdad2a392df83035878c8 Mon Sep 17 00:00:00 2001 From: "Kandasamy, Divya" Date: Thu, 21 Nov 2024 14:23:36 -0500 Subject: [PATCH 2/2] Added unit testcase --- src/constant.js | 2 +- test/unit/MethodFilters.test.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/constant.js b/src/constant.js index d47d4425..6ad2d7e2 100644 --- a/src/constant.js +++ b/src/constant.js @@ -130,7 +130,7 @@ export const CONSTANTS = { METHODS_TO_BE_EXCLUDED_ONLY_DEVICES: [], PUBSUB_ACK: { pubSubStatus: 'Connection successful' }, SUBSCRIBE: 'Subscribe', - ADDITIONAL_SUBSCRIBE: 'Subscribing additional methods', + 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 97484647..0d18001d 100644 --- a/test/unit/MethodFilters.test.js +++ b/test/unit/MethodFilters.test.js @@ -188,16 +188,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);