-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changes to getTeamsByUserRole and getRatingsByUserCohort
- Loading branch information
1 parent
5deff7a
commit e21ec0b
Showing
16 changed files
with
3,839 additions
and
950 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import React from "react" | ||
import "@testing-library/jest-dom" | ||
import { MockedProvider, MockedResponse } from "@apollo/client/testing" | ||
import { render, fireEvent, screen, cleanup, waitFor } from "@testing-library/react" | ||
import BulkRatingModal from "../../src/components/BulkRatingModal" | ||
import { GET_RATINGS_BY_USER_COHORT } from "../../src/Mutations/Ratings" | ||
import { GET_TEAMS_BY_USER_ROLE } from "../../src/Mutations/teamMutation" | ||
|
||
const getRatingsByUserCohort: MockedResponse = { | ||
request:{ | ||
query: GET_RATINGS_BY_USER_COHORT, | ||
// variables: { | ||
// orgToken: 'mocked_org_token' | ||
// } | ||
}, | ||
variableMatcher: () => true, | ||
result:{ | ||
data: { | ||
getRatingsByUserCohort: [ | ||
{ | ||
id: "1", | ||
sprint: 1, | ||
}, | ||
{ | ||
id: "2", | ||
sprint: 2, | ||
} | ||
] | ||
} | ||
} | ||
} | ||
|
||
const getTeamsByUserRole = { | ||
request: { | ||
query: GET_TEAMS_BY_USER_ROLE, | ||
// variables: { | ||
// orgToken: "mocked_org_token" | ||
// } | ||
}, | ||
variableMatcher: () => true, | ||
result:{ | ||
data: { | ||
getTeamsByUserRole: [ | ||
{ | ||
id: "1", | ||
name: "Team I", | ||
members:[ | ||
{ | ||
email: "[email protected]", | ||
role: "trainee" | ||
}, | ||
{ | ||
email: "[email protected]", | ||
role: "ttl" | ||
}, | ||
{ | ||
email: "[email protected]", | ||
role: "trainee" | ||
}, | ||
] | ||
}, | ||
{ | ||
id: "2", | ||
name: "Team II", | ||
members:[ | ||
{ | ||
email: "[email protected]", | ||
role: "trainee" | ||
}, | ||
{ | ||
email: "[email protected]", | ||
role: "ttl" | ||
}, | ||
{ | ||
email: "[email protected]", | ||
role: "trainee" | ||
}, | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
|
||
jest.mock('react-toastify', () => ({ | ||
toast: { | ||
success: jest.fn(), | ||
error: jest.fn(), | ||
} | ||
})) | ||
|
||
beforeEach(() => { | ||
localStorage.setItem('auth_token', 'mocked_auth_token') | ||
localStorage.setItem('orgToken', 'mocked_org_token') | ||
localStorage.setItem('auth', JSON.stringify({ | ||
auth: true, | ||
email: "[email protected]", | ||
firstName: "Jack", | ||
role: "admin", | ||
userId: "1" | ||
})) | ||
}) | ||
|
||
afterEach(() => { | ||
localStorage.clear() | ||
cleanup() | ||
}) | ||
|
||
describe("BulkRatingModal", () => { | ||
const setBulkRateModel = jest.fn() | ||
|
||
it("displays all sprints", async() => { | ||
render( | ||
<MockedProvider mocks={[getRatingsByUserCohort, getTeamsByUserRole]} addTypename={false}> | ||
<BulkRatingModal | ||
bulkRateModal={true} | ||
setBulkRateModal={setBulkRateModel} | ||
></BulkRatingModal> | ||
</MockedProvider> | ||
) | ||
await waitFor(()=>{ | ||
expect(screen.getByTestId("sprint-option-1")).toBeInTheDocument() | ||
expect(screen.getByTestId("sprint-option-2")).toBeInTheDocument() | ||
}) | ||
}) | ||
it("displays teams", async() => { | ||
render( | ||
<MockedProvider mocks={[getRatingsByUserCohort, getTeamsByUserRole]} addTypename={false}> | ||
<BulkRatingModal | ||
bulkRateModal={true} | ||
setBulkRateModal={setBulkRateModel} | ||
></BulkRatingModal> | ||
</MockedProvider> | ||
) | ||
await waitFor(()=>{ | ||
expect(screen.getByTestId("team-option-1")).toBeInTheDocument() | ||
expect(screen.getByTestId("team-option-2")).toBeInTheDocument() | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.