Add biome and initial format rules
This commit is contained in:
@@ -1,93 +1,95 @@
|
||||
import { GithubError } from "../src/GithubError"
|
||||
|
||||
describe('ErrorMessage', () => {
|
||||
|
||||
describe('has error with code', () => {
|
||||
describe("ErrorMessage", () => {
|
||||
describe("has error with code", () => {
|
||||
const error = {
|
||||
message: 'something bad happened',
|
||||
message: "something bad happened",
|
||||
errors: [
|
||||
{
|
||||
code: 'missing',
|
||||
resource: 'release'
|
||||
code: "missing",
|
||||
resource: "release",
|
||||
},
|
||||
{
|
||||
code: 'already_exists',
|
||||
resource: 'release'
|
||||
}
|
||||
code: "already_exists",
|
||||
resource: "release",
|
||||
},
|
||||
],
|
||||
status: 422
|
||||
status: 422,
|
||||
}
|
||||
|
||||
it('does not have error', () => {
|
||||
it("does not have error", () => {
|
||||
const githubError = new GithubError(error)
|
||||
expect(githubError.hasErrorWithCode('missing_field')).toBeFalsy()
|
||||
expect(githubError.hasErrorWithCode("missing_field")).toBeFalsy()
|
||||
})
|
||||
|
||||
it('has error', () => {
|
||||
it("has error", () => {
|
||||
const githubError = new GithubError(error)
|
||||
expect(githubError.hasErrorWithCode('missing')).toBeTruthy()
|
||||
expect(githubError.hasErrorWithCode("missing")).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
describe('has error with remediation', () => {
|
||||
it('provides remediation with 404 without errors', () => {
|
||||
describe("has error with remediation", () => {
|
||||
it("provides remediation with 404 without errors", () => {
|
||||
const error = { status: 404, message: "message" }
|
||||
const githubError = new GithubError(error)
|
||||
expect(githubError.toString())
|
||||
.toBe('Error 404: message\nMake sure your github token has access to the repo and has permission to author releases')
|
||||
expect(githubError.toString()).toBe(
|
||||
"Error 404: message\nMake sure your github token has access to the repo and has permission to author releases"
|
||||
)
|
||||
})
|
||||
|
||||
it('provides remediation with 404 with errors', () => {
|
||||
it("provides remediation with 404 with errors", () => {
|
||||
const error = {
|
||||
message: 'message',
|
||||
message: "message",
|
||||
errors: [
|
||||
{
|
||||
code: 'missing',
|
||||
resource: 'release'
|
||||
}
|
||||
code: "missing",
|
||||
resource: "release",
|
||||
},
|
||||
],
|
||||
status: 404
|
||||
status: 404,
|
||||
}
|
||||
const githubError = new GithubError(error)
|
||||
expect(githubError.toString())
|
||||
.toBe('Error 404: message\nErrors:\n- release does not exist.\nMake sure your github token has access to the repo and has permission to author releases')
|
||||
expect(githubError.toString()).toBe(
|
||||
"Error 404: message\nErrors:\n- release does not exist.\nMake sure your github token has access to the repo and has permission to author releases"
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it('generates message with errors', () => {
|
||||
|
||||
it("generates message with errors", () => {
|
||||
const error = {
|
||||
message: 'something bad happened',
|
||||
message: "something bad happened",
|
||||
errors: [
|
||||
{
|
||||
code: 'missing',
|
||||
resource: 'release'
|
||||
code: "missing",
|
||||
resource: "release",
|
||||
},
|
||||
{
|
||||
code: 'already_exists',
|
||||
resource: 'release'
|
||||
}
|
||||
code: "already_exists",
|
||||
resource: "release",
|
||||
},
|
||||
],
|
||||
status: 422
|
||||
status: 422,
|
||||
}
|
||||
|
||||
const githubError = new GithubError(error)
|
||||
|
||||
const expectedString = "Error 422: something bad happened\nErrors:\n- release does not exist.\n- release already exists."
|
||||
const expectedString =
|
||||
"Error 422: something bad happened\nErrors:\n- release does not exist.\n- release already exists."
|
||||
expect(githubError.toString()).toBe(expectedString)
|
||||
})
|
||||
|
||||
it('generates message without errors', () => {
|
||||
it("generates message without errors", () => {
|
||||
const error = {
|
||||
message: 'something bad happened',
|
||||
status: 422
|
||||
message: "something bad happened",
|
||||
status: 422,
|
||||
}
|
||||
|
||||
const githubError = new GithubError(error)
|
||||
|
||||
expect(githubError.toString()).toBe('Error 422: something bad happened')
|
||||
expect(githubError.toString()).toBe("Error 422: something bad happened")
|
||||
})
|
||||
|
||||
it('provides error status', () => {
|
||||
it("provides error status", () => {
|
||||
const error = { status: 404 }
|
||||
const githubError = new GithubError(error)
|
||||
expect(githubError.status).toBe(404)
|
||||
|
||||
Reference in New Issue
Block a user