Commit f644cd7a by zCaesar

add test

parent 43dc2eca
var assert = require('assert')
var getTopic = require('../utils/getTopic').getTopic
describe('GetTopic', () => {
describe('realtime msg', () => {
it('should return topic that id_group have insert between @msg and topic', () => {
var topic = '@msg/any/light'
var id_group = 'bulb'
var tgConcat = '@msg/!bulb/any/light'
var _topic = getTopic(topic, id_group)
assert.equal(_topic, tgConcat)
})
})
describe('shadow', () => {
describe('update pub', () => {
it('should return topic that id have insert between @shadow/update and topic', () => {
var topic = '@shadow/update/any/light'
var id = 'd4484cdb-a47a-4936-bcfd-33c1af39b857'
var tgConcat = '@shadow/update/!d4484cdb-a47a-4936-bcfd-33c1af39b857/any/light'
var _topic = getTopic(topic, id)
assert.equal(_topic, tgConcat)
})
})
describe('update sub', () => {
it('should return topic that id have insert behind @shadow/updated', () => {
var topic = '@shadow/updated'
var id = 'd4484cdb-a47a-4936-bcfd-33c1af39b857'
var tgConcat = '@shadow/updated/!d4484cdb-a47a-4936-bcfd-33c1af39b857'
var _topic = getTopic(topic, id)
assert.equal(_topic, tgConcat)
})
})
describe('get pub', () => {
it('should return topic that id have insert between @shadow/get and topic', () => {
var topic = '@shadow/get/any/light'
var id = 'd4484cdb-a47a-4936-bcfd-33c1af39b857'
var tgConcat = '@shadow/get/!d4484cdb-a47a-4936-bcfd-33c1af39b857/any/light'
var _topic = getTopic(topic, id)
assert.equal(_topic, tgConcat)
})
})
describe('get sub', () => {
it('should return topic that id have insert between @client and #', () => {
var topic = '@client/#'
var id = 'd4484cdb-a47a-4936-bcfd-33c1af39b857'
var tgConcat = '@client/!d4484cdb-a47a-4936-bcfd-33c1af39b857/#'
var _topic = getTopic(topic, id)
assert.equal(_topic, tgConcat)
})
})
})
})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment