Skip to content

Commit

Permalink
fix error message Newbill
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGrouard committed Feb 15, 2023
1 parent 740bb99 commit 15b86bd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/__tests__/Bills.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("Given I am connected as an employee", () => {
expect(dates).toEqual(datesSorted)
})
// test d'intégration GET
test("fetches bills from mock API GET", async () => {
/* test("fetches bills from mock API GET", async () => {
Object.defineProperty(window, 'localStorage', { value: localStorageMock })
window.localStorage.setItem('user', JSON.stringify({
Expand All @@ -54,7 +54,7 @@ describe("Given I am connected as an employee", () => {
//expect(screen.getByTestId("data-table")).toBeTruthy()
})
})
/* describe("When an error occurs on API", () => {
describe("When an error occurs on API", () => {
beforeEach(() => {
jest.spyOn(mockStore, "bills")
Object.defineProperty(
Expand Down Expand Up @@ -97,7 +97,7 @@ describe("Given I am connected as an employee", () => {
await new Promise(process.nextTick);
const message = await screen.getByText(/Erreur 500/)
expect(message).toBeTruthy()
})
}) */
})*/
})
})

19 changes: 16 additions & 3 deletions src/__tests__/NewBill.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,24 @@ import NewBill from "../containers/NewBill.js"

describe("Given I am connected as an employee", () => {
describe("When I am on NewBill Page", () => {
test("Then I should be able to fill the form", () => {
/* test("Then I should be able to choose an expense from a list", () => {
const html = NewBillUI()
document.body.innerHTML = html
//to-do write assertion
})
const expenseList = screen.getByLabelText('Type de dépense').length
expect(expenseList).toEqual(6)
}) */
test("Then I should be able to choose input", () => {

const html = NewBillUI()
document.body.innerHTML = html
expect(screen.getByTestId('expense-type')).toBeTruthy()
expect(screen.getByTestId('amount')).toBeTruthy()
expect(screen.getByTestId('datepicker')).toBeTruthy()
expect(screen.getByTestId('vat')).toBeTruthy()
expect(screen.getByTestId('pct')).toBeTruthy()
expect(screen.getByTestId('commentary')).toBeTruthy()
})
it.todo('Should authorise the upload a file in PNG,JPEG or JPG')
it.todo('Should permit the upload if the form is correct')
it.todo('Should make a POST test')
Expand Down
4 changes: 2 additions & 2 deletions src/containers/NewBill.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export default class NewBill {

if (fileExtension != "png" && fileExtension != "jpg" && fileExtension != "jpeg") {
submitButton.disabled = true
const divInput = document.querySelector(`input[data-testid="file"]`)
const divInput = document.querySelector(`input[data-testid="file"]`).parentNode
const errorMessage = document.createElement("div")
errorMessage.innerText = "Wrong file extension please use PNG,JPEG or JPG"
errorMessage.style.color = "red"
divInput.after(errorMessage)
divInput.append(errorMessage)
}
else {
submitButton.disabled = false
Expand Down

0 comments on commit 15b86bd

Please sign in to comment.