Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .eslintignore

This file was deleted.

2 changes: 1 addition & 1 deletion __tests__/ctrf/helpers.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getEmoji, normalizeSuite, stripAnsi } from '../../src/ctrf/helpers'
import { getEmoji, normalizeSuite, stripAnsi } from '../../src/ctrf/helpers.js'

describe('getEmoji', () => {
it('returns the correct emoji for "passed"', () => {
Expand Down
6 changes: 3 additions & 3 deletions __tests__/ctrf/report-preparation.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Inputs, ReportConditionals } from '../../src/types'
import { Report } from '../../src/ctrf/core/types/ctrf'
import { addFooterDisplayFlags } from '../../src/ctrf/report-conditionals'
import { Inputs, ReportConditionals } from '../../src/types/index.js'
import { Report } from '../../src/ctrf/core/types/ctrf.js'
import { addFooterDisplayFlags } from '../../src/ctrf/report-conditionals.js'

describe('addFooterDisplayFlags', () => {
const createBaseReport = (): Report => ({
Expand Down
15 changes: 8 additions & 7 deletions __tests__/github/core.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { vi, describe, it, expect, beforeEach } from 'vitest'
import * as core from '@actions/core'
import { context } from '@actions/github'
import { addReportFooters } from '../../src/github/core'
import { Report } from '../../src/ctrf/core/types/ctrf'
import { Inputs, ReportConditionals } from '../../src/types'
import { addReportFooters } from '../../src/github/core.js'
import { Report } from '../../src/ctrf/core/types/ctrf.js'
import { Inputs, ReportConditionals } from '../../src/types/index.js'

jest.mock('@actions/core')
jest.mock('@actions/github', () => ({
vi.mock('@actions/core')
vi.mock('@actions/github', () => ({
context: {
serverUrl: 'https://github.com',
repo: {
Expand All @@ -17,10 +18,10 @@ jest.mock('@actions/github', () => ({
}))

describe('addReportFooters', () => {
const mockCore = jest.mocked(core)
const mockCore = vi.mocked(core)

beforeEach(() => {
jest.clearAllMocks()
vi.clearAllMocks()
mockCore.summary.addRaw.mockReturnValue(mockCore.summary)
mockCore.summary.addEOL.mockReturnValue(mockCore.summary)
})
Expand Down
61 changes: 27 additions & 34 deletions __tests__/github/handler.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { vi, describe, it, expect, beforeEach, beforeAll } from 'vitest'
import * as core from '@actions/core'
import { context } from '@actions/github'
import { createCheckRun } from '../../src/client/github/checks'
import { createCheckRun } from '../../src/client/github/checks.js'
import {
createStatusCheck,
findExistingMarkedComment,
handleComment,
handleViewsAndComments
} from '../../src/github/handler'
import { Inputs } from '../../src/types'
import { Report } from '../../src/ctrf/core/types/ctrf'
import * as githubClient from '../../src/client/github'
} from '../../src/github/handler.js'
import { Inputs } from '../../src/types/index.js'
import { Report } from '../../src/ctrf/core/types/ctrf.js'
import * as githubClient from '../../src/client/github/index.js'
import { components } from '@octokit/openapi-types'
import Handlebars from 'handlebars'

Expand Down Expand Up @@ -92,8 +93,8 @@ beforeAll(() => {
})
})

jest.mock('@actions/core')
jest.mock('@actions/github', () => ({
vi.mock('@actions/core')
vi.mock('@actions/github', () => ({
context: {
repo: {
owner: 'test-owner',
Expand All @@ -102,17 +103,17 @@ jest.mock('@actions/github', () => ({
sha: 'test-sha'
}
}))
jest.mock('../../src/client/github/checks', () => ({
createCheckRun: jest.fn()
vi.mock('../../src/client/github/checks', () => ({
createCheckRun: vi.fn()
}))
jest.mock('../../src/client/github')
vi.mock('../../src/client/github')

describe('createStatusCheck', () => {
const mockCore = jest.mocked(core)
const mockCreateCheckRun = jest.mocked(createCheckRun)
const mockCore = vi.mocked(core)
const mockCreateCheckRun = vi.mocked(createCheckRun)

beforeEach(() => {
jest.clearAllMocks()
vi.clearAllMocks()
mockCore.summary.stringify.mockReturnValue('Test summary')
})

Expand Down Expand Up @@ -210,10 +211,10 @@ describe('createStatusCheck', () => {
})

describe('findExistingMarkedComment', () => {
const mockListComments = jest.mocked(githubClient.listComments)
const mockListComments = vi.mocked(githubClient.listComments)

beforeEach(() => {
jest.clearAllMocks()
vi.clearAllMocks()
})

it('should return undefined when no comments exist', async () => {
Expand Down Expand Up @@ -380,15 +381,15 @@ describe('findExistingMarkedComment', () => {
})

describe('handleComment', () => {
const mockAddComment = jest.fn()
const mockUpdateComment = jest.fn()
const mockListComments = jest.fn()
const mockAddComment = vi.fn()
const mockUpdateComment = vi.fn()
const mockListComments = vi.fn()

beforeEach(() => {
jest.resetAllMocks()
;(githubClient.addCommentToIssue as jest.Mock) = mockAddComment
;(githubClient.updateComment as jest.Mock) = mockUpdateComment
;(githubClient.listComments as jest.Mock) = mockListComments
vi.resetAllMocks()
vi.mocked(githubClient.addCommentToIssue).mockImplementation(mockAddComment)
vi.mocked(githubClient.updateComment).mockImplementation(mockUpdateComment)
vi.mocked(githubClient.listComments).mockImplementation(mockListComments)
})

describe('New PR - All flags disabled', () => {
Expand Down Expand Up @@ -732,21 +733,13 @@ describe('handleComment', () => {
})

describe('handleViewsAndComments', () => {
const mockCore = jest.mocked(core)
const mockCore = vi.mocked(core)
beforeEach(() => {
jest.clearAllMocks()
vi.clearAllMocks()
context.payload ||= {}
mockCore.summary.stringify.mockReturnValue('Test summary')
mockCore.summary.addRaw.mockImplementation(
jest
.requireActual<typeof core>('@actions/core')
.summary.addRaw.bind(core.summary)
)
mockCore.summary.addEOL.mockImplementation(
jest
.requireActual<typeof core>('@actions/core')
.summary.addEOL.bind(core.summary)
)
mockCore.summary.addRaw.mockReturnValue(mockCore.summary)
mockCore.summary.addEOL.mockReturnValue(mockCore.summary)
})

it('should create a check run with views and comments', async () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/reports/delta-display.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Handlebars from 'handlebars'
import { registerAllHelpers } from '../../src/handlebars/helpers'
import { registerAllHelpers } from '../../src/handlebars/helpers/index.js'
import * as fs from 'fs'
import * as path from 'path'

Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading