@@ -250,4 +250,100 @@ describe('DevicesComponent', () => {
250250 component . tagFilterChange ( matSelectChange )
251251 expect ( component . filteredTags ( ) ) . toBe ( mockValue )
252252 } )
253+
254+ describe ( 'getProductType' , ( ) => {
255+ it ( 'should return ISM when bit 4 (0x10) is set' , ( ) => {
256+ const device = { ...device01 , deviceInfo : { fwSku : '16' } } as Device // 0x10 = 16
257+ expect ( component . getProductType ( device ) ) . toBe ( 'ISM' )
258+ } )
259+
260+ it ( 'should return vPro when bit 3 (0x08) is set and bit 4 is not' , ( ) => {
261+ const device = { ...device01 , deviceInfo : { fwSku : '8' } } as Device // 0x08 = 8
262+ expect ( component . getProductType ( device ) ) . toBe ( 'vPro' )
263+ } )
264+
265+ it ( 'should return ISM when both bit 4 and bit 3 are set (ISM takes priority)' , ( ) => {
266+ const device = { ...device01 , deviceInfo : { fwSku : '24' } } as Device // 0x18 = 24
267+ expect ( component . getProductType ( device ) ) . toBe ( 'ISM' )
268+ } )
269+
270+ it ( 'should return empty string when neither bit is set' , ( ) => {
271+ const device = { ...device01 , deviceInfo : { fwSku : '4' } } as Device // 0x04 = 4
272+ expect ( component . getProductType ( device ) ) . toBe ( '' )
273+ } )
274+
275+ it ( 'should return empty string when fwSku is undefined' , ( ) => {
276+ const device = { ...device01 , deviceInfo : undefined } as Device
277+ expect ( component . getProductType ( device ) ) . toBe ( '' )
278+ } )
279+
280+ it ( 'should return empty string when fwSku is not a number' , ( ) => {
281+ const device = { ...device01 , deviceInfo : { fwSku : 'notanumber' } } as Device
282+ expect ( component . getProductType ( device ) ) . toBe ( '' )
283+ } )
284+ } )
285+
286+ describe ( 'onTabChange / applyTabFilter' , ( ) => {
287+ beforeEach ( ( ) => {
288+ const baseInfo = { fwVersion : '' , fwBuild : '' , fwSku : '0' , features : '' , ipAddress : '' }
289+ component . allDevicesData = [
290+ { ...device01 , deviceInfo : { ...baseInfo , currentMode : 'acm' , discovered : false } } ,
291+ { ...device02 , deviceInfo : { ...baseInfo , currentMode : 'not activated' , discovered : true } }
292+ ]
293+ } )
294+
295+ it ( 'should show all devices on tab 0' , ( ) => {
296+ component . onTabChange ( 0 )
297+ expect ( component . devices . data . length ) . toBe ( 2 )
298+ } )
299+
300+ it ( 'should filter to activated devices on tab 1' , ( ) => {
301+ component . onTabChange ( 1 )
302+ expect ( component . devices . data . length ) . toBe ( 1 )
303+ expect ( component . devices . data [ 0 ] . guid ) . toBe ( device01 . guid )
304+ } )
305+
306+ it ( 'should filter to discovered devices on tab 2' , ( ) => {
307+ component . onTabChange ( 2 )
308+ expect ( component . devices . data . length ) . toBe ( 1 )
309+ expect ( component . devices . data [ 0 ] . guid ) . toBe ( device02 . guid )
310+ } )
311+
312+ it ( 'should set totalCount to serverTotalCount on tab 0' , ( ) => {
313+ ; ( component as any ) . serverTotalCount = 42
314+ component . onTabChange ( 0 )
315+ expect ( component . totalCount ( ) ) . toBe ( 42 )
316+ } )
317+
318+ it ( 'should set totalCount to filtered length on tab 1' , ( ) => {
319+ component . onTabChange ( 1 )
320+ expect ( component . totalCount ( ) ) . toBe ( 1 )
321+ } )
322+
323+ it ( 'should set totalCount to filtered length on tab 2' , ( ) => {
324+ component . onTabChange ( 2 )
325+ expect ( component . totalCount ( ) ) . toBe ( 1 )
326+ } )
327+ } )
328+
329+ describe ( 'isNoData' , ( ) => {
330+ it ( 'should return false when allDevicesData has entries regardless of totalCount' , ( ) => {
331+ component . allDevicesData = [ device01 ]
332+ component . isLoading . set ( false )
333+ component . totalCount . set ( 0 ) // filtered tab has 0 — should not trigger no-data
334+ expect ( component . isNoData ( ) ) . toBeFalse ( )
335+ } )
336+
337+ it ( 'should return true only when allDevicesData is empty and not loading' , ( ) => {
338+ component . allDevicesData = [ ]
339+ component . isLoading . set ( false )
340+ expect ( component . isNoData ( ) ) . toBeTrue ( )
341+ } )
342+
343+ it ( 'should return false when loading even if allDevicesData is empty' , ( ) => {
344+ component . allDevicesData = [ ]
345+ component . isLoading . set ( true )
346+ expect ( component . isNoData ( ) ) . toBeFalse ( )
347+ } )
348+ } )
253349} )
0 commit comments