Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typescript to worker project #4116

Merged
merged 10 commits into from
Feb 1, 2022
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"dev:server": "lerna run --parallel dev:builder --concurrency 1 --scope @budibase/worker --scope @budibase/server",
"test": "lerna run test",
"lint:eslint": "eslint packages",
"lint:prettier": "prettier --check \"packages/**/*.{js,svelte}\"",
"lint:prettier": "prettier --check \"packages/**/*.{js,ts,svelte}\"",
"lint": "yarn run lint:eslint && yarn run lint:prettier",
"lint:fix:eslint": "eslint --fix packages",
"lint:fix:prettier": "prettier --write \"packages/**/*.{js,svelte}\"",
"lint:fix:prettier": "prettier --write \"packages/**/*.{js,ts,svelte}\"",
"lint:fix:ts": "lerna run lint:fix",
"lint:fix": "yarn run lint:fix:ts && yarn run lint:fix:prettier && yarn run lint:fix:eslint",
"test:e2e": "lerna run cy:test",
Expand Down
2 changes: 1 addition & 1 deletion packages/server/__mocks__/arangojs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module ArangoMock {
this.close = jest.fn()
}

// @ts-ignore
// @ts-ignore
arangodb.aql = (strings, ...args) => {
let str = strings.join("{}")

Expand Down
8 changes: 4 additions & 4 deletions packages/server/__mocks__/aws-sdk.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module AwsMock {
const aws: any = {}

const response = (body: any) => () => ({promise: () => body})
const response = (body: any) => () => ({ promise: () => body })

function DocumentClient() {
// @ts-ignore
Expand Down Expand Up @@ -39,9 +39,9 @@ module AwsMock {
)
}

aws.DynamoDB = {DocumentClient}
aws.DynamoDB = { DocumentClient }
aws.S3 = S3
aws.config = {update: jest.fn()}
aws.config = { update: jest.fn() }

module.exports = aws
}
}
9 changes: 4 additions & 5 deletions packages/server/__mocks__/mongodb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ module MongoMock {
this.connect = jest.fn()
this.close = jest.fn()
this.insertOne = jest.fn()
this.insertMany = jest.fn(() => ({toArray: () => []}))
this.find = jest.fn(() => ({toArray: () => []}))
this.insertMany = jest.fn(() => ({ toArray: () => [] }))
this.find = jest.fn(() => ({ toArray: () => [] }))
this.findOne = jest.fn()
this.count = jest.fn()
this.deleteOne = jest.fn()
this.deleteMany = jest.fn(() => ({toArray: () => []}))
this.deleteMany = jest.fn(() => ({ toArray: () => [] }))
this.updateOne = jest.fn()
this.updateMany = jest.fn(() => ({toArray: () => []}))

this.updateMany = jest.fn(() => ({ toArray: () => [] }))

this.collection = jest.fn(() => ({
insertOne: this.insertOne,
Expand Down
6 changes: 3 additions & 3 deletions packages/server/__mocks__/mssql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ module MsSqlMock {
],
}))

// mssql.connect = jest.fn(() => ({ recordset: [] }))
// mssql.connect = jest.fn(() => ({ recordset: [] }))

mssql.ConnectionPool = jest.fn(() => ({
connect: jest.fn(() => ({
request: jest.fn(() => ({
query: jest.fn(sql => ({ recordset: [ sql ] })),
query: jest.fn(sql => ({ recordset: [sql] })),
})),
})),
}))

module.exports = mssql
}
}
3 changes: 2 additions & 1 deletion packages/server/__mocks__/node-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ module FetchMock {
return json({
url,
opts,
value: "<!doctype html><html itemscope=\"\" itemtype=\"http://schema.org/WebPage\" lang=\"en-GB\"></html>",
value:
'<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en-GB"></html>',
})
} else if (url.includes("failonce.com")) {
failCount++
Expand Down
8 changes: 3 additions & 5 deletions packages/server/__mocks__/pg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ module PgMock {
],
}))

// constructor
function Client() {
}
// constructor
function Client() {}

Client.prototype.query = query
Client.prototype.connect = jest.fn()
Client.prototype.release = jest.fn()

function Pool() {
}
function Pool() {}

const on = jest.fn()
Pool.prototype.query = query
Expand Down
2 changes: 1 addition & 1 deletion packages/server/scripts/likeCypress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ process.env.ALLOW_DEV_AUTOMATIONS = "1"
const server = require("../src/app")
process.env.PORT = WORKER_PORT
const worker = require("../../worker/src/index")
process.env.PORT = MAIN_PORT
process.env.PORT = MAIN_PORT
Loading