Get lint passing.
This commit is contained in:
parent
7a63dc9830
commit
1785f3af7e
|
@ -265,6 +265,7 @@ describe("docWritethrough", () => {
|
|||
})
|
||||
|
||||
// This is not yet supported
|
||||
// eslint-disable-next-line jest/no-disabled-tests
|
||||
it.skip("patches will execute in order", async () => {
|
||||
let incrementalValue = 0
|
||||
const keyToOverride = generator.word()
|
||||
|
|
|
@ -11,7 +11,6 @@ export const buildMatcherRegex = (
|
|||
return patterns.map(pattern => {
|
||||
let route = pattern.route
|
||||
const method = pattern.method
|
||||
const strict = pattern.strict ? pattern.strict : false
|
||||
|
||||
// if there is a param in the route
|
||||
// use a wildcard pattern
|
||||
|
@ -24,24 +23,17 @@ export const buildMatcherRegex = (
|
|||
}
|
||||
}
|
||||
|
||||
return { regex: new RegExp(route), method, strict, route }
|
||||
return { regex: new RegExp(route), method, route }
|
||||
})
|
||||
}
|
||||
|
||||
export const matches = (ctx: BBContext, options: RegexMatcher[]) => {
|
||||
return options.find(({ regex, method, strict, route }) => {
|
||||
let urlMatch
|
||||
if (strict) {
|
||||
urlMatch = ctx.request.url === route
|
||||
} else {
|
||||
urlMatch = regex.test(ctx.request.url)
|
||||
}
|
||||
|
||||
return options.find(({ regex, method, route }) => {
|
||||
const urlMatch = regex.test(ctx.request.url)
|
||||
const methodMatch =
|
||||
method === "ALL"
|
||||
? true
|
||||
: ctx.request.method.toLowerCase() === method.toLowerCase()
|
||||
|
||||
return urlMatch && methodMatch
|
||||
})
|
||||
}
|
||||
|
|
|
@ -34,23 +34,6 @@ describe("matchers", () => {
|
|||
expect(!!matchers.matches(ctx, built)).toBe(true)
|
||||
})
|
||||
|
||||
it("doesn't wildcard path with strict", () => {
|
||||
const pattern = [
|
||||
{
|
||||
route: "/api/tests",
|
||||
method: "POST",
|
||||
strict: true,
|
||||
},
|
||||
]
|
||||
const ctx = structures.koa.newContext()
|
||||
ctx.request.url = "/api/tests/id/something/else"
|
||||
ctx.request.method = "POST"
|
||||
|
||||
const built = matchers.buildMatcherRegex(pattern)
|
||||
|
||||
expect(!!matchers.matches(ctx, built)).toBe(false)
|
||||
})
|
||||
|
||||
it("matches with param", () => {
|
||||
const pattern = [
|
||||
{
|
||||
|
@ -67,23 +50,6 @@ describe("matchers", () => {
|
|||
expect(!!matchers.matches(ctx, built)).toBe(true)
|
||||
})
|
||||
|
||||
// TODO: Support the below behaviour
|
||||
// Strict does not work when a param is present
|
||||
// it("matches with param with strict", () => {
|
||||
// const pattern = [{
|
||||
// route: "/api/tests/:testId",
|
||||
// method: "GET",
|
||||
// strict: true
|
||||
// }]
|
||||
// const ctx = structures.koa.newContext()
|
||||
// ctx.request.url = "/api/tests/id"
|
||||
// ctx.request.method = "GET"
|
||||
//
|
||||
// const built = matchers.buildMatcherRegex(pattern)
|
||||
//
|
||||
// expect(!!matchers.matches(ctx, built)).toBe(true)
|
||||
// })
|
||||
|
||||
it("doesn't match by path", () => {
|
||||
const pattern = [
|
||||
{
|
||||
|
|
|
@ -245,7 +245,10 @@ describe("/queries", () => {
|
|||
expect(responseBody.rows.length).toEqual(1)
|
||||
expect(events.query.previewed).toHaveBeenCalledTimes(1)
|
||||
delete datasource.config
|
||||
expect(events.query.previewed).toHaveBeenCalledWith(datasource, queryPreview)
|
||||
expect(events.query.previewed).toHaveBeenCalledWith(
|
||||
datasource,
|
||||
queryPreview
|
||||
)
|
||||
})
|
||||
|
||||
it("should apply authorization to endpoint", async () => {
|
||||
|
|
|
@ -135,9 +135,9 @@ describe("migrations", () => {
|
|||
expect(events.backfill.tenantSucceeded).toHaveBeenCalledTimes(1)
|
||||
|
||||
// to make sure caching is working as expected
|
||||
expect(events.processors.analyticsProcessor.processEvent).toHaveBeenCalledTimes(
|
||||
19
|
||||
)
|
||||
expect(
|
||||
events.processors.analyticsProcessor.processEvent
|
||||
).toHaveBeenCalledTimes(19)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -110,9 +110,7 @@ describe("bbReferenceProcessor", () => {
|
|||
config.doInTenant(() =>
|
||||
processInputBBReferences(userIdCsv, FieldSubtype.USER)
|
||||
)
|
||||
).rejects.toThrow(
|
||||
new InvalidBBRefError(wrongId, FieldSubtype.USER)
|
||||
)
|
||||
).rejects.toThrow(new InvalidBBRefError(wrongId, FieldSubtype.USER))
|
||||
})
|
||||
|
||||
it("validate valid user object", async () => {
|
||||
|
|
|
@ -62,7 +62,9 @@ describe("rowProcessor - inputProcessing", () => {
|
|||
|
||||
const { row } = await inputProcessing(userId, table, newRow)
|
||||
|
||||
expect(bbReferenceProcessor.processInputBBReferences).toHaveBeenCalledTimes(1)
|
||||
expect(bbReferenceProcessor.processInputBBReferences).toHaveBeenCalledTimes(
|
||||
1
|
||||
)
|
||||
expect(bbReferenceProcessor.processInputBBReferences).toHaveBeenCalledWith(
|
||||
"123",
|
||||
"user"
|
||||
|
@ -150,7 +152,9 @@ describe("rowProcessor - inputProcessing", () => {
|
|||
|
||||
const { row } = await inputProcessing(userId, table, newRow)
|
||||
|
||||
expect(bbReferenceProcessor.processInputBBReferences).not.toHaveBeenCalled()
|
||||
expect(
|
||||
bbReferenceProcessor.processInputBBReferences
|
||||
).not.toHaveBeenCalled()
|
||||
expect(row).toEqual(newRow)
|
||||
}
|
||||
)
|
||||
|
|
|
@ -64,7 +64,9 @@ describe("rowProcessor - outputProcessing", () => {
|
|||
|
||||
expect(result).toEqual({ name: "Jack", user })
|
||||
|
||||
expect(bbReferenceProcessor.processOutputBBReferences).toHaveBeenCalledTimes(1)
|
||||
expect(
|
||||
bbReferenceProcessor.processOutputBBReferences
|
||||
).toHaveBeenCalledTimes(1)
|
||||
expect(bbReferenceProcessor.processOutputBBReferences).toHaveBeenCalledWith(
|
||||
"123",
|
||||
FieldSubtype.USER
|
||||
|
@ -150,7 +152,9 @@ describe("rowProcessor - outputProcessing", () => {
|
|||
|
||||
expect(result).toEqual({ name: "Jack" })
|
||||
|
||||
expect(bbReferenceProcessor.processOutputBBReferences).toHaveBeenCalledTimes(1)
|
||||
expect(
|
||||
bbReferenceProcessor.processOutputBBReferences
|
||||
).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it("does not fetch bb references when not in the schema", async () => {
|
||||
|
@ -189,6 +193,8 @@ describe("rowProcessor - outputProcessing", () => {
|
|||
|
||||
expect(result).toEqual({ name: "Jack", user: "123" })
|
||||
|
||||
expect(bbReferenceProcessor.processOutputBBReferences).not.toHaveBeenCalled()
|
||||
expect(
|
||||
bbReferenceProcessor.processOutputBBReferences
|
||||
).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
|
|
@ -8,15 +8,10 @@ export interface EndpointMatcher {
|
|||
* ALL is also accepted to cover all verbs.
|
||||
*/
|
||||
method: string
|
||||
/**
|
||||
* The route must match exactly - not just begins with
|
||||
*/
|
||||
strict?: boolean
|
||||
}
|
||||
|
||||
export interface RegexMatcher {
|
||||
regex: RegExp
|
||||
method: string
|
||||
strict: boolean
|
||||
route: string
|
||||
}
|
||||
|
|
|
@ -61,7 +61,9 @@ describe("configs", () => {
|
|||
expect(events.auth.SSOCreated).toHaveBeenCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSODeactivated).not.toHaveBeenCalled()
|
||||
expect(events.auth.SSOActivated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSOActivated).toHaveBeenCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSOActivated).toHaveBeenCalledWith(
|
||||
ConfigType.GOOGLE
|
||||
)
|
||||
await config.deleteConfig(ConfigType.GOOGLE)
|
||||
})
|
||||
|
||||
|
@ -88,7 +90,9 @@ describe("configs", () => {
|
|||
expect(events.auth.SSOUpdated).toHaveBeenCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSOActivated).not.toHaveBeenCalled()
|
||||
expect(events.auth.SSODeactivated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSODeactivated).toHaveBeenCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSODeactivated).toHaveBeenCalledWith(
|
||||
ConfigType.GOOGLE
|
||||
)
|
||||
await config.deleteConfig(ConfigType.GOOGLE)
|
||||
})
|
||||
|
||||
|
@ -104,7 +108,9 @@ describe("configs", () => {
|
|||
expect(events.auth.SSOUpdated).toHaveBeenCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSODeactivated).not.toHaveBeenCalled()
|
||||
expect(events.auth.SSOActivated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSOActivated).toHaveBeenCalledWith(ConfigType.GOOGLE)
|
||||
expect(events.auth.SSOActivated).toHaveBeenCalledWith(
|
||||
ConfigType.GOOGLE
|
||||
)
|
||||
await config.deleteConfig(ConfigType.GOOGLE)
|
||||
})
|
||||
})
|
||||
|
@ -154,7 +160,9 @@ describe("configs", () => {
|
|||
expect(events.auth.SSOUpdated).toHaveBeenCalledWith(ConfigType.OIDC)
|
||||
expect(events.auth.SSOActivated).not.toHaveBeenCalled()
|
||||
expect(events.auth.SSODeactivated).toHaveBeenCalledTimes(1)
|
||||
expect(events.auth.SSODeactivated).toHaveBeenCalledWith(ConfigType.OIDC)
|
||||
expect(events.auth.SSODeactivated).toHaveBeenCalledWith(
|
||||
ConfigType.OIDC
|
||||
)
|
||||
await config.deleteConfig(ConfigType.OIDC)
|
||||
})
|
||||
|
||||
|
|
|
@ -42,7 +42,9 @@ describe("/api/global/license", () => {
|
|||
licenseKey: "licenseKey",
|
||||
})
|
||||
expect(res.status).toBe(200)
|
||||
expect(licensing.keys.activateLicenseKey).toHaveBeenCalledWith("licenseKey")
|
||||
expect(licensing.keys.activateLicenseKey).toHaveBeenCalledWith(
|
||||
"licenseKey"
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -74,9 +76,9 @@ describe("/api/global/license", () => {
|
|||
const res = await config.api.license.activateOfflineLicense({
|
||||
offlineLicenseToken: "offlineLicenseToken",
|
||||
})
|
||||
expect(licensing.offline.activateOfflineLicenseToken).toHaveBeenCalledWith(
|
||||
"offlineLicenseToken"
|
||||
)
|
||||
expect(
|
||||
licensing.offline.activateOfflineLicenseToken
|
||||
).toHaveBeenCalledWith("offlineLicenseToken")
|
||||
expect(res.status).toBe(200)
|
||||
})
|
||||
})
|
||||
|
@ -102,7 +104,9 @@ describe("/api/global/license", () => {
|
|||
it("returns 204", async () => {
|
||||
const res = await config.api.license.deleteOfflineLicense()
|
||||
expect(res.status).toBe(204)
|
||||
expect(licensing.offline.deleteOfflineLicenseToken).toHaveBeenCalledTimes(1)
|
||||
expect(licensing.offline.deleteOfflineLicenseToken).toHaveBeenCalledTimes(
|
||||
1
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue