Skip to content

Commit

Permalink
Add linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rnathuji committed Jan 13, 2023
1 parent 1da181e commit fb6110c
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions specs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const createContentJSON = (htmlContent: string): string => {
}

export const mockPageContentRequest = async (page: Page, htmlContent: string): Promise<void> => {
return await page.route(
await page.route(
`${TEST_CONTENT_URL_PREFIX}/test.json`,
route => {
route.fulfill({
Expand All @@ -43,7 +43,7 @@ const createVariantContentJSON = (mainContent: string, variantContent: string):
}

export const mockVariantContentRequest = async (page: Page, mainContent: string, variantContent: string): Promise<void> => {
return await page.route(
await page.route(
`${TEST_CONTENT_URL_PREFIX}/test.json`,
route => {
route.fulfill({
Expand Down
2 changes: 1 addition & 1 deletion src/lib/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class EventManager {
}
this.impressionId = this.impressionId ?? uuidv4()
const context = getCurrentContext()
const eventsEndpointMapper = ENV.OS_RAISE_EVENTSAPI_URL_MAP as { [key: string]: string | undefined }
const eventsEndpointMapper = ENV.OS_RAISE_EVENTSAPI_URL_MAP as Record<string, string | undefined>
const eventsEndpoint = eventsEndpointMapper[window.location.host]

if (context.courseId === undefined || eventsEndpoint === undefined || window.M === undefined) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const mathifyElement = (elem: Element): void => {
if (loadSuccess) {
queueMathJax(elem)
}
}).catch(error => console.error(error))
}).catch(error => { console.error(error) })
} else {
queueMathJax(elem)
}
Expand Down
22 changes: 11 additions & 11 deletions src/tests/ContentLoader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jest.mock('../lib/env.ts', () => ({
}
}))

beforeAll(() => server.listen())
afterEach(() => server.resetHandlers())
afterAll(() => server.close())
beforeAll(() => { server.listen() })
afterEach(() => { server.resetHandlers() })
afterAll(() => { server.close() })

test('content is fetched and rendered on success', async () => {
render(
Expand Down Expand Up @@ -69,8 +69,8 @@ test('OnContentLoad is called', async () => {
<ContentLoader contentId='test-content' onContentLoad={mockOnLoad} onContentLoadFailure={mockOnLoadFailed}/>
)

await waitFor(() => expect(mockOnLoad.mock.calls.length).toBe(1))
await waitFor(() => expect(mockOnLoadFailed.mock.calls.length).toBe(0))
await waitFor(() => { expect(mockOnLoad.mock.calls.length).toBe(1) })
await waitFor(() => { expect(mockOnLoadFailed.mock.calls.length).toBe(0) })
expect(mockOnLoad.mock.calls[0][0]).toBe('test-content')
expect(mockOnLoad.mock.calls[0][1]).toBe('main')
})
Expand All @@ -81,8 +81,8 @@ test('OnContentLadFailed is called when error loading content', async () => {
render(
<ContentLoader contentId='test-content-failure' onContentLoad={mockOnLoad} onContentLoadFailure={mockOnLoadFailed}/>
)
await waitFor(() => expect(mockOnLoad.mock.calls.length).toBe(0))
await waitFor(() => expect(mockOnLoadFailed.mock.calls.length).toBe(1))
await waitFor(() => { expect(mockOnLoad.mock.calls.length).toBe(0) })
await waitFor(() => { expect(mockOnLoadFailed.mock.calls.length).toBe(1) })
expect(mockOnLoadFailed.mock.calls[0][0]).toBe('test-content-failure')
expect(mockOnLoadFailed.mock.calls[0][1]).toBe('TypeError: Network request failed')
})
Expand All @@ -93,8 +93,8 @@ test('OnContentLadFailed is called when there is a 404 error', async () => {
render(
<ContentLoader contentId='test-content-404' onContentLoad={mockOnLoad} onContentLoadFailure={mockOnLoadFailed}/>
)
await waitFor(() => expect(mockOnLoad.mock.calls.length).toBe(0))
await waitFor(() => expect(mockOnLoadFailed.mock.calls.length).toBe(1))
await waitFor(() => { expect(mockOnLoad.mock.calls.length).toBe(0) })
await waitFor(() => { expect(mockOnLoadFailed.mock.calls.length).toBe(1) })
expect(mockOnLoadFailed.mock.calls[0][0]).toBe('test-content-404')
expect(mockOnLoadFailed.mock.calls[0][1]).toBe('Error: Request for content returned 404')
})
Expand All @@ -105,8 +105,8 @@ test('OnContentLadFailed is called when variant cannot be found', async () => {
render(
<ContentLoader contentId='test-nomain-content' onContentLoad={mockOnLoad} onContentLoadFailure={mockOnLoadFailed}/>
)
await waitFor(() => expect(mockOnLoad.mock.calls.length).toBe(0))
await waitFor(() => expect(mockOnLoadFailed.mock.calls.length).toBe(1))
await waitFor(() => { expect(mockOnLoad.mock.calls.length).toBe(0) })
await waitFor(() => { expect(mockOnLoadFailed.mock.calls.length).toBe(1) })
expect(mockOnLoadFailed.mock.calls[0][0]).toBe('test-nomain-content')
expect(mockOnLoadFailed.mock.calls[0][1]).toBe('Error: Could not resolve content variant')
})
6 changes: 3 additions & 3 deletions src/tests/DesmosBlock.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test('Desmos block calls script and grahing calcultor functions', async () => {

expect(loadDesmos).toBeCalled()

await waitFor(() => expect(graphingCalculator).toBeCalled())
await waitFor(() => { expect(graphingCalculator).toBeCalled() })
expect(setExpression).toBeCalled()
expect(setMathBounds).toBeCalled()
})
Expand All @@ -50,7 +50,7 @@ test('DesmosBlock does not render if waitForEvent does not fire', async () => {

expect(loadDesmos).toBeCalled()

await waitFor(() => expect(graphingCalculator).not.toBeCalled())
await waitFor(() => { expect(graphingCalculator).not.toBeCalled() })
expect(setExpression).not.toBeCalled()
expect(setMathBounds).not.toBeCalled()
})
Expand All @@ -77,7 +77,7 @@ test('DesmosBlock calculator does render if waitForEvent does fire', async () =>

fireEvent(document, new CustomEvent('event'))

await waitFor(() => expect(graphingCalculator).toBeCalled())
await waitFor(() => { expect(graphingCalculator).toBeCalled() })
expect(setExpression).toBeCalled()
expect(setMathBounds).toBeCalled()
})
6 changes: 3 additions & 3 deletions src/tests/MoodleApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const server = setupServer(
}]))
}))

beforeAll(() => server.listen())
afterEach(() => server.resetHandlers())
afterAll(() => server.close())
beforeAll(() => { server.listen() })
afterEach(() => { server.resetHandlers() })
afterAll(() => { server.close() })

test('Test getuser', async () => {
const moodleApi = new MoodleApi('http://moodle', '12345')
Expand Down
2 changes: 1 addition & 1 deletion src/tests/TooltipBlock.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ test('Tooltip Block renders math', async () => {

expect(screen.getByText('my-text'))
fireEvent.mouseOver(screen.getByText('my-text'))
await waitFor(() => expect(mathifyElement).toHaveBeenCalled())
await waitFor(() => { expect(mathifyElement).toHaveBeenCalled() })
})
4 changes: 2 additions & 2 deletions src/tests/events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ beforeAll(() => {
server.listen()
})

afterEach(() => server.resetHandlers())
afterAll(() => server.close())
afterEach(() => { server.resetHandlers() })
afterAll(() => { server.close() })

// NOTE (Hack): Due to the internal implementation of the events module, this test
// case should run first (it will otherwise pass but not exercise / validate
Expand Down

0 comments on commit fb6110c

Please sign in to comment.