Skip to content

Commit

Permalink
test(desktop): update topic tree utils test case
Browse files Browse the repository at this point in the history
  • Loading branch information
ysfscream committed Oct 16, 2024
1 parent bca9fb2 commit 524c2a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/views/viewer/TopicTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export default class TopicTree extends Vue {
packet,
connectionInfo,
})
console.log(JSON.stringify(this.data, null, 2))
}
created() {
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/utils/topicTree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
findSubTopics,
findFullTopicPath,
getAllIDs,
isPayloadEmpty,
} from '@/utils/topicTree'
import { IPublishPacket } from 'mqtt-packet'

Expand Down Expand Up @@ -405,4 +406,13 @@ describe('Topic Tree Functions', () => {
const fullPath = findFullTopicPath(tree, 'non-existent')
expect(fullPath).to.be.null
})

it('should correctly identify empty payloads', () => {
expect(isPayloadEmpty(null)).to.be.true
expect(isPayloadEmpty(undefined)).to.be.true
expect(isPayloadEmpty('')).to.be.false
expect(isPayloadEmpty('non-empty')).to.be.false
expect(isPayloadEmpty(Buffer.from(''))).to.be.false
expect(isPayloadEmpty(Buffer.from('non-empty'))).to.be.false
})
})

0 comments on commit 524c2a2

Please sign in to comment.