Making progress on getting the eslint-jest plugin working.
This commit is contained in:
parent
1f63f0bddf
commit
7a63dc9830
|
@ -34,6 +34,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"files": ["**/*.ts"],
|
"files": ["**/*.ts"],
|
||||||
|
"excludedFiles": ["qa-core/**"],
|
||||||
"parser": "@typescript-eslint/parser",
|
"parser": "@typescript-eslint/parser",
|
||||||
"extends": ["eslint:recommended"],
|
"extends": ["eslint:recommended"],
|
||||||
"rules": {
|
"rules": {
|
||||||
|
@ -48,6 +49,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"files": ["**/*.spec.ts"],
|
"files": ["**/*.spec.ts"],
|
||||||
|
"excludedFiles": ["qa-core/**"],
|
||||||
"parser": "@typescript-eslint/parser",
|
"parser": "@typescript-eslint/parser",
|
||||||
"plugins": ["jest"],
|
"plugins": ["jest"],
|
||||||
"extends": ["eslint:recommended", "plugin:jest/recommended"],
|
"extends": ["eslint:recommended", "plugin:jest/recommended"],
|
||||||
|
@ -63,7 +65,13 @@
|
||||||
"no-prototype-builtins": "off",
|
"no-prototype-builtins": "off",
|
||||||
"local-rules/no-test-com": "error",
|
"local-rules/no-test-com": "error",
|
||||||
"local-rules/email-domain-example-com": "error",
|
"local-rules/email-domain-example-com": "error",
|
||||||
"no-console": "warn"
|
"no-console": "warn",
|
||||||
|
// We have a lot of tests that don't have assertions, they use our test
|
||||||
|
// API client that does the assertions for them
|
||||||
|
"jest/expect-expect": "off",
|
||||||
|
// We do this in some tests where the behaviour of internal tables
|
||||||
|
// differs to external, but the API is broadly the same
|
||||||
|
"jest/no-conditional-expect": "off"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,10 +4,10 @@ set -e
|
||||||
if [[ -n $CI ]]
|
if [[ -n $CI ]]
|
||||||
then
|
then
|
||||||
# --runInBand performs better in ci where resources are limited
|
# --runInBand performs better in ci where resources are limited
|
||||||
echo "jest --coverage --runInBand --forceExit"
|
echo "jest --coverage --runInBand --forceExit $@"
|
||||||
jest --coverage --runInBand --forceExit
|
jest --coverage --runInBand --forceExit $@
|
||||||
else
|
else
|
||||||
# --maxWorkers performs better in development
|
# --maxWorkers performs better in development
|
||||||
echo "jest --coverage --detectOpenHandles"
|
echo "jest --coverage --forceExit --detectOpenHandles $@"
|
||||||
jest --coverage --detectOpenHandles
|
jest --coverage --forceExit --detectOpenHandles $@
|
||||||
fi
|
fi
|
|
@ -147,17 +147,6 @@ describe("redis", () => {
|
||||||
expect(results).toEqual([1, 2, 3, 4, 5])
|
expect(results).toEqual([1, 2, 3, 4, 5])
|
||||||
})
|
})
|
||||||
|
|
||||||
it("can increment on a new key", async () => {
|
|
||||||
const key1 = structures.uuid()
|
|
||||||
const key2 = structures.uuid()
|
|
||||||
|
|
||||||
const result1 = await redis.increment(key1)
|
|
||||||
expect(result1).toBe(1)
|
|
||||||
|
|
||||||
const result2 = await redis.increment(key2)
|
|
||||||
expect(result2).toBe(1)
|
|
||||||
})
|
|
||||||
|
|
||||||
it("can increment multiple times in parallel", async () => {
|
it("can increment multiple times in parallel", async () => {
|
||||||
const key = structures.uuid()
|
const key = structures.uuid()
|
||||||
const results = await Promise.all(
|
const results = await Promise.all(
|
||||||
|
|
|
@ -25,8 +25,8 @@ describe("/applications/:appId/import", () => {
|
||||||
.expect(200)
|
.expect(200)
|
||||||
const appPackage = await config.api.application.get(appId!)
|
const appPackage = await config.api.application.get(appId!)
|
||||||
expect(appPackage.navigation?.links?.length).toBe(2)
|
expect(appPackage.navigation?.links?.length).toBe(2)
|
||||||
expect(expect(appPackage.navigation?.links?.[0].url).toBe("/blank"))
|
expect(appPackage.navigation?.links?.[0].url).toBe("/blank")
|
||||||
expect(expect(appPackage.navigation?.links?.[1].url).toBe("/derp"))
|
expect(appPackage.navigation?.links?.[1].url).toBe("/derp")
|
||||||
const screens = await config.api.screen.list()
|
const screens = await config.api.screen.list()
|
||||||
expect(screens.length).toBe(2)
|
expect(screens.length).toBe(2)
|
||||||
expect(screens[0].routing.route).toBe("/derp")
|
expect(screens[0].routing.route).toBe("/derp")
|
||||||
|
|
|
@ -30,7 +30,9 @@ describe("/applications", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
app = await config.api.application.create({ name: utils.newid() })
|
app = await config.api.application.create({ name: utils.newid() })
|
||||||
const deployment = await config.api.application.publish(app.appId)
|
const deployment = await config.api.application.publish(app.appId)
|
||||||
expect(deployment.status).toBe("SUCCESS")
|
if (deployment.status !== "SUCCESS") {
|
||||||
|
throw new Error("Failed to publish app")
|
||||||
|
}
|
||||||
jest.clearAllMocks()
|
jest.clearAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ describe("MySQL Integration", () => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it.skip("parses strings matching a valid date format", async () => {
|
it("parses strings matching a valid date format", async () => {
|
||||||
const sql = "select * from users;"
|
const sql = "select * from users;"
|
||||||
await config.integration.read({
|
await config.integration.read({
|
||||||
sql,
|
sql,
|
||||||
|
|
|
@ -22,11 +22,6 @@ describe("Oracle Integration", () => {
|
||||||
config = new TestConfiguration()
|
config = new TestConfiguration()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
expect(oracledb.closeMock).toHaveBeenCalled()
|
|
||||||
expect(oracledb.closeMock).toHaveBeenCalledTimes(1)
|
|
||||||
})
|
|
||||||
|
|
||||||
it("calls the create method with the correct params", async () => {
|
it("calls the create method with the correct params", async () => {
|
||||||
const sql = "insert into users (name, age) values ('Joe', 123);"
|
const sql = "insert into users (name, age) values ('Joe', 123);"
|
||||||
await config.integration.create({
|
await config.integration.create({
|
||||||
|
@ -34,6 +29,7 @@ describe("Oracle Integration", () => {
|
||||||
})
|
})
|
||||||
expect(oracledb.executeMock).toHaveBeenCalledWith(sql, [], options)
|
expect(oracledb.executeMock).toHaveBeenCalledWith(sql, [], options)
|
||||||
expect(oracledb.executeMock).toHaveBeenCalledTimes(1)
|
expect(oracledb.executeMock).toHaveBeenCalledTimes(1)
|
||||||
|
expect(oracledb.closeMock).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("calls the read method with the correct params", async () => {
|
it("calls the read method with the correct params", async () => {
|
||||||
|
@ -43,6 +39,7 @@ describe("Oracle Integration", () => {
|
||||||
})
|
})
|
||||||
expect(oracledb.executeMock).toHaveBeenCalledWith(sql, [], options)
|
expect(oracledb.executeMock).toHaveBeenCalledWith(sql, [], options)
|
||||||
expect(oracledb.executeMock).toHaveBeenCalledTimes(1)
|
expect(oracledb.executeMock).toHaveBeenCalledTimes(1)
|
||||||
|
expect(oracledb.closeMock).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("calls the update method with the correct params", async () => {
|
it("calls the update method with the correct params", async () => {
|
||||||
|
@ -52,6 +49,7 @@ describe("Oracle Integration", () => {
|
||||||
})
|
})
|
||||||
expect(oracledb.executeMock).toHaveBeenCalledWith(sql, [], options)
|
expect(oracledb.executeMock).toHaveBeenCalledWith(sql, [], options)
|
||||||
expect(oracledb.executeMock).toHaveBeenCalledTimes(1)
|
expect(oracledb.executeMock).toHaveBeenCalledTimes(1)
|
||||||
|
expect(oracledb.closeMock).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("calls the delete method with the correct params", async () => {
|
it("calls the delete method with the correct params", async () => {
|
||||||
|
@ -61,6 +59,7 @@ describe("Oracle Integration", () => {
|
||||||
})
|
})
|
||||||
expect(oracledb.executeMock).toHaveBeenCalledWith(sql, [], options)
|
expect(oracledb.executeMock).toHaveBeenCalledWith(sql, [], options)
|
||||||
expect(oracledb.executeMock).toHaveBeenCalledTimes(1)
|
expect(oracledb.executeMock).toHaveBeenCalledTimes(1)
|
||||||
|
expect(oracledb.closeMock).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("no rows returned", () => {
|
describe("no rows returned", () => {
|
||||||
|
@ -75,6 +74,7 @@ describe("Oracle Integration", () => {
|
||||||
})
|
})
|
||||||
expect(response).toEqual([{ created: true }])
|
expect(response).toEqual([{ created: true }])
|
||||||
expect(oracledb.executeMock).toHaveBeenCalledTimes(1)
|
expect(oracledb.executeMock).toHaveBeenCalledTimes(1)
|
||||||
|
expect(oracledb.closeMock).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("returns the correct response when the update response has no rows", async () => {
|
it("returns the correct response when the update response has no rows", async () => {
|
||||||
|
@ -84,6 +84,7 @@ describe("Oracle Integration", () => {
|
||||||
})
|
})
|
||||||
expect(response).toEqual([{ updated: true }])
|
expect(response).toEqual([{ updated: true }])
|
||||||
expect(oracledb.executeMock).toHaveBeenCalledTimes(1)
|
expect(oracledb.executeMock).toHaveBeenCalledTimes(1)
|
||||||
|
expect(oracledb.closeMock).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("returns the correct response when the delete response has no rows", async () => {
|
it("returns the correct response when the delete response has no rows", async () => {
|
||||||
|
@ -93,6 +94,7 @@ describe("Oracle Integration", () => {
|
||||||
})
|
})
|
||||||
expect(response).toEqual([{ deleted: true }])
|
expect(response).toEqual([{ deleted: true }])
|
||||||
expect(oracledb.executeMock).toHaveBeenCalledTimes(1)
|
expect(oracledb.executeMock).toHaveBeenCalledTimes(1)
|
||||||
|
expect(oracledb.closeMock).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -418,9 +418,9 @@ describe("REST Integration", () => {
|
||||||
})
|
})
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const sentData = fetch.mock.calls[0][1].body
|
const sentData = fetch.mock.calls[0][1].body
|
||||||
expect(sentData.has(pageParam))
|
expect(sentData.has(pageParam)).toEqual(true)
|
||||||
expect(sentData.get(pageParam)).toEqual(pageValue.toString())
|
expect(sentData.get(pageParam)).toEqual(pageValue.toString())
|
||||||
expect(sentData.has(sizeParam))
|
expect(sentData.has(pageParam)).toEqual(true)
|
||||||
expect(sentData.get(sizeParam)).toEqual(sizeValue.toString())
|
expect(sentData.get(sizeParam)).toEqual(sizeValue.toString())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -551,9 +551,9 @@ describe("REST Integration", () => {
|
||||||
})
|
})
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const sentData = fetch.mock.calls[0][1].body
|
const sentData = fetch.mock.calls[0][1].body
|
||||||
expect(sentData.has(pageParam))
|
expect(sentData.has(pageParam)).toEqual(true)
|
||||||
expect(sentData.get(pageParam)).toEqual(pageValue.toString())
|
expect(sentData.get(pageParam)).toEqual(pageValue.toString())
|
||||||
expect(sentData.has(sizeParam))
|
expect(sentData.has(pageParam)).toEqual(true)
|
||||||
expect(sentData.get(sizeParam)).toEqual(sizeValue.toString())
|
expect(sentData.get(sizeParam)).toEqual(sizeValue.toString())
|
||||||
expect(res.pagination.cursor).toEqual(123)
|
expect(res.pagination.cursor).toEqual(123)
|
||||||
})
|
})
|
||||||
|
|
|
@ -342,25 +342,6 @@ describe("SQL query builder", () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should use greater than when only low range specified", () => {
|
|
||||||
const date = new Date()
|
|
||||||
const query = sql._query(
|
|
||||||
generateReadJson({
|
|
||||||
filters: {
|
|
||||||
range: {
|
|
||||||
property: {
|
|
||||||
low: date,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
)
|
|
||||||
expect(query).toEqual({
|
|
||||||
bindings: [date, limit],
|
|
||||||
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" > $1 limit $2) as "${TABLE_NAME}"`,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it("should use AND like expression for MS-SQL when filter is contains", () => {
|
it("should use AND like expression for MS-SQL when filter is contains", () => {
|
||||||
const query = new Sql(SqlClient.MS_SQL, 10)._query(
|
const query = new Sql(SqlClient.MS_SQL, 10)._query(
|
||||||
generateReadJson({
|
generateReadJson({
|
||||||
|
|
|
@ -294,7 +294,7 @@ describe("Captures of real examples", () => {
|
||||||
type: "datasource",
|
type: "datasource",
|
||||||
isSQL: false,
|
isSQL: false,
|
||||||
})
|
})
|
||||||
)
|
).toEqual(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should disable when no fields", () => {
|
it("should disable when no fields", () => {
|
||||||
|
|
|
@ -360,7 +360,10 @@ describe("/api/global/auth", () => {
|
||||||
|
|
||||||
const res = await config.api.configs.OIDCCallback(configId, preAuthRes)
|
const res = await config.api.configs.OIDCCallback(configId, preAuthRes)
|
||||||
|
|
||||||
expect(events.auth.login).toHaveBeenCalledWith("oidc", "oauth@example.com")
|
expect(events.auth.login).toHaveBeenCalledWith(
|
||||||
|
"oidc",
|
||||||
|
"oauth@example.com"
|
||||||
|
)
|
||||||
expect(events.auth.login).toHaveBeenCalledTimes(1)
|
expect(events.auth.login).toHaveBeenCalledTimes(1)
|
||||||
expect(res.status).toBe(302)
|
expect(res.status).toBe(302)
|
||||||
const location: string = res.get("location")
|
const location: string = res.get("location")
|
||||||
|
@ -368,13 +371,5 @@ describe("/api/global/auth", () => {
|
||||||
expectSetAuthCookie(res)
|
expectSetAuthCookie(res)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// SINGLE TENANT
|
|
||||||
|
|
||||||
describe("GET /api/global/auth/oidc/callback", () => {})
|
|
||||||
|
|
||||||
describe("GET /api/global/auth/oidc/callback", () => {})
|
|
||||||
|
|
||||||
describe("GET /api/admin/auth/oidc/callback", () => {})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
import { TestConfiguration } from "../../../../tests"
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
|
|
||||||
describe("/api/global/workspaces", () => {
|
|
||||||
const config = new TestConfiguration()
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
await config.beforeAll()
|
|
||||||
})
|
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
await config.afterAll()
|
|
||||||
})
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
jest.clearAllMocks()
|
|
||||||
})
|
|
||||||
|
|
||||||
describe("GET /api/global/workspaces", () => {
|
|
||||||
it("retrieves workspaces", () => {})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe("DELETE /api/global/workspaces/:id", () => {})
|
|
||||||
|
|
||||||
describe("GET /api/global/workspaces", () => {})
|
|
||||||
|
|
||||||
describe("GET /api/global/workspaces/:id", () => {})
|
|
||||||
})
|
|
Loading…
Reference in New Issue