2023-07-04 05:35:29 +00:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
const {channelToKState, _convertNameAndTopic} = require("./create-room")
|
2023-05-10 05:40:31 +00:00
|
|
|
const {kstateStripConditionals} = require("../../matrix/kstate")
|
2023-05-05 13:25:15 +00:00
|
|
|
const {test} = require("supertape")
|
|
|
|
const testData = require("../../test/data")
|
|
|
|
|
|
|
|
test("channel2room: general", async t => {
|
|
|
|
t.deepEqual(
|
|
|
|
kstateStripConditionals(await channelToKState(testData.channel.general, testData.guild.general).then(x => x.channelKState)),
|
|
|
|
testData.room.general
|
|
|
|
)
|
|
|
|
})
|
2023-07-04 05:35:29 +00:00
|
|
|
|
|
|
|
test("convertNameAndTopic: custom name and topic", t => {
|
|
|
|
t.deepEqual(
|
|
|
|
_convertNameAndTopic({id: "123", name: "the-twilight-zone", topic: "Spooky stuff here. :ghost:"}, {id: "456"}, "hauntings"),
|
|
|
|
["hauntings", "#the-twilight-zone | Spooky stuff here. :ghost:\n\nChannel ID: 123\nGuild ID: 456"]
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
test("convertNameAndTopic: custom name, no topic", t => {
|
|
|
|
t.deepEqual(
|
|
|
|
_convertNameAndTopic({id: "123", name: "the-twilight-zone"}, {id: "456"}, "hauntings"),
|
|
|
|
["hauntings", "#the-twilight-zone\n\nChannel ID: 123\nGuild ID: 456"]
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
test("convertNameAndTopic: original name and topic", t => {
|
|
|
|
t.deepEqual(
|
|
|
|
_convertNameAndTopic({id: "123", name: "the-twilight-zone", topic: "Spooky stuff here. :ghost:"}, {id: "456"}, null),
|
|
|
|
["the-twilight-zone", "Spooky stuff here. :ghost:\n\nChannel ID: 123\nGuild ID: 456"]
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
test("convertNameAndTopic: original name, no topic", t => {
|
|
|
|
t.deepEqual(
|
|
|
|
_convertNameAndTopic({id: "123", name: "the-twilight-zone"}, {id: "456"}, null),
|
|
|
|
["the-twilight-zone", "Channel ID: 123\nGuild ID: 456"]
|
|
|
|
)
|
|
|
|
})
|