Convert last few .js files in backend-core to .ts

This commit is contained in:
Sam Rose 2025-01-16 09:41:51 +00:00
parent 93c10cf17b
commit 9c7fc41913
No known key found for this signature in database
3 changed files with 14 additions and 14 deletions

View File

@ -1,6 +1,6 @@
import env from "../../environment" import env from "../../environment"
export const getCouchInfo = (connection?: string) => { export const getCouchInfo = (connection?: string | null) => {
// clean out any auth credentials // clean out any auth credentials
const urlInfo = getUrlInfo(connection) const urlInfo = getUrlInfo(connection)
let username let username
@ -45,7 +45,7 @@ export const getCouchInfo = (connection?: string) => {
} }
} }
export const getUrlInfo = (url = env.COUCH_DB_URL) => { export const getUrlInfo = (url: string | null = env.COUCH_DB_URL) => {
let cleanUrl, username, password, host let cleanUrl, username, password, host
if (url) { if (url) {
// Ensure the URL starts with a protocol // Ensure the URL starts with a protocol

View File

@ -1,5 +1,6 @@
require("../../../tests") require("../../../tests")
const getUrlInfo = require("../couch").getUrlInfo
import { getUrlInfo } from "../couch"
describe("pouch", () => { describe("pouch", () => {
describe("Couch DB URL parsing", () => { describe("Couch DB URL parsing", () => {

View File

@ -1,17 +1,17 @@
const _ = require("lodash/fp") import { range } from "lodash/fp"
const { structures } = require("../../../tests") import { structures } from "../.."
jest.mock("../../../src/context") jest.mock("../../../src/context")
jest.mock("../../../src/db") jest.mock("../../../src/db")
const context = require("../../../src/context") import * as context from "../../../src/context"
const db = require("../../../src/db") import * as db from "../../../src/db"
const { getCreatorCount } = require("../../../src/users/users") import { getCreatorCount } from "../../../src/users/users"
describe("Users", () => { describe("Users", () => {
let getGlobalDBMock let getGlobalDBMock: jest.SpyInstance
let paginationMock let paginationMock: jest.SpyInstance
beforeEach(() => { beforeEach(() => {
jest.resetAllMocks() jest.resetAllMocks()
@ -22,11 +22,10 @@ describe("Users", () => {
jest.spyOn(db, "getGlobalUserParams") jest.spyOn(db, "getGlobalUserParams")
}) })
it("Retrieves the number of creators", async () => { it("retrieves the number of creators", async () => {
const getUsers = (offset, limit, creators = false) => { const getUsers = (offset: number, limit: number, creators = false) => {
const range = _.range(offset, limit)
const opts = creators ? { builder: { global: true } } : undefined const opts = creators ? { builder: { global: true } } : undefined
return range.map(() => structures.users.user(opts)) return range(offset, limit).map(() => structures.users.user(opts))
} }
const page1Data = getUsers(0, 8) const page1Data = getUsers(0, 8)
const page2Data = getUsers(8, 12, true) const page2Data = getUsers(8, 12, true)