1
0
Fork 0
out-of-your-element-fork-th.../test/test.js

60 lines
1.9 KiB
JavaScript
Raw Normal View History

// @ts-check
const fs = require("fs")
2023-09-30 12:24:05 +00:00
const {join} = require("path")
const sqlite = require("better-sqlite3")
2023-09-30 12:24:05 +00:00
const migrate = require("../db/migrate")
const HeatSync = require("heatsync")
2023-09-30 12:24:05 +00:00
const {test} = require("supertape")
const data = require("./data")
const config = require("../config")
const passthrough = require("../passthrough")
const db = new sqlite(":memory:")
const reg = require("../matrix/read-registration")
reg.ooye.server_origin = "https://matrix.cadence.moe" // so that tests will pass even when hard-coded
2023-05-08 05:22:20 +00:00
const sync = new HeatSync({watchFS: false})
2023-09-30 12:24:05 +00:00
const discord = {
guilds: new Map([
[data.guild.general.id, data.guild.general]
])
}
Object.assign(passthrough, { discord, config, sync, db })
2023-09-14 00:32:27 +00:00
const orm = sync.require("../db/orm")
passthrough.from = orm.from
passthrough.select = orm.select
const file = sync.require("../matrix/file")
file._actuallyUploadDiscordFileToMxc = function(url, res) { throw new Error(`Not allowed to upload files during testing.\nURL: ${url}`) }
2023-09-30 12:24:05 +00:00
;(async () => {
const p = migrate.migrate(db)
test("migrate: migration works", async t => {
await p
t.pass("it did not throw an error")
})
await p
db.exec(fs.readFileSync(join(__dirname, "ooye-test-data.sql"), "utf8"))
require("../db/orm.test")
require("../matrix/kstate.test")
require("../matrix/api.test")
require("../matrix/file.test")
require("../matrix/read-registration.test")
require("../matrix/txnid.test")
require("../d2m/converters/message-to-event.test")
require("../d2m/converters/message-to-event.embeds.test")
require("../d2m/converters/edit-to-changes.test")
require("../d2m/converters/thread-to-announcement.test")
require("../d2m/converters/user-to-mxid.test")
2023-10-07 07:58:46 +00:00
require("../d2m/converters/emoji-to-key.test")
require("../d2m/actions/create-room.test")
2023-09-30 12:24:05 +00:00
require("../d2m/actions/register-user.test")
require("../m2d/converters/event-to-message.test")
require("../m2d/converters/utils.test")
})()