chore: Migrate jest expectation function

* Replace toBeCalledWith with toHaveBeenCalledWith
This commit is contained in:
Thomas Ruggeri
2025-12-22 20:35:52 +00:00
parent 33c7a0bfc8
commit fa144c97df
2 changed files with 104 additions and 104 deletions

View File

@@ -54,18 +54,18 @@ test('when given a single dependency it sets its values', async () => {
expect(core.setOutput).toHaveBeenCalledWith('updated-dependencies-json', updatedDependencies)
expect(core.setOutput).toBeCalledWith('dependency-names', 'coffee-rails')
expect(core.setOutput).toBeCalledWith('dependency-type', 'direct:production')
expect(core.setOutput).toBeCalledWith('update-type', 'version-update:semver-minor')
expect(core.setOutput).toBeCalledWith('directory', 'wwwroot')
expect(core.setOutput).toBeCalledWith('package-ecosystem', 'nuget')
expect(core.setOutput).toBeCalledWith('target-branch', 'main')
expect(core.setOutput).toBeCalledWith('previous-version', '1.0.2')
expect(core.setOutput).toBeCalledWith('new-version', '1.1.3-beta')
expect(core.setOutput).toBeCalledWith('compatibility-score', 43)
expect(core.setOutput).toBeCalledWith('alert-state', 'FIXED')
expect(core.setOutput).toBeCalledWith('ghsa-id', 'VERY_LONG_ID')
expect(core.setOutput).toBeCalledWith('cvss', 4.6)
expect(core.setOutput).toHaveBeenCalledWith('dependency-names', 'coffee-rails')
expect(core.setOutput).toHaveBeenCalledWith('dependency-type', 'direct:production')
expect(core.setOutput).toHaveBeenCalledWith('update-type', 'version-update:semver-minor')
expect(core.setOutput).toHaveBeenCalledWith('directory', 'wwwroot')
expect(core.setOutput).toHaveBeenCalledWith('package-ecosystem', 'nuget')
expect(core.setOutput).toHaveBeenCalledWith('target-branch', 'main')
expect(core.setOutput).toHaveBeenCalledWith('previous-version', '1.0.2')
expect(core.setOutput).toHaveBeenCalledWith('new-version', '1.1.3-beta')
expect(core.setOutput).toHaveBeenCalledWith('compatibility-score', 43)
expect(core.setOutput).toHaveBeenCalledWith('alert-state', 'FIXED')
expect(core.setOutput).toHaveBeenCalledWith('ghsa-id', 'VERY_LONG_ID')
expect(core.setOutput).toHaveBeenCalledWith('cvss', 4.6)
})
test('when given a multiple dependencies, it uses the highest values for types', async () => {
@@ -100,18 +100,18 @@ test('when given a multiple dependencies, it uses the highest values for types',
expect(core.setOutput).toHaveBeenCalledWith('updated-dependencies-json', updatedDependencies)
expect(core.setOutput).toBeCalledWith('dependency-names', 'rspec, coffee-rails, coffeescript, rspec-coffeescript')
expect(core.setOutput).toBeCalledWith('dependency-type', 'direct:development')
expect(core.setOutput).toBeCalledWith('update-type', 'version-update:semver-major')
expect(core.setOutput).toBeCalledWith('directory', '')
expect(core.setOutput).toBeCalledWith('package-ecosystem', '')
expect(core.setOutput).toBeCalledWith('target-branch', '')
expect(core.setOutput).toBeCalledWith('previous-version', '')
expect(core.setOutput).toBeCalledWith('new-version', '')
expect(core.setOutput).toBeCalledWith('compatibility-score', 0)
expect(core.setOutput).toBeCalledWith('alert-state', '')
expect(core.setOutput).toBeCalledWith('ghsa-id', '')
expect(core.setOutput).toBeCalledWith('cvss', 0)
expect(core.setOutput).toHaveBeenCalledWith('dependency-names', 'rspec, coffee-rails, coffeescript, rspec-coffeescript')
expect(core.setOutput).toHaveBeenCalledWith('dependency-type', 'direct:development')
expect(core.setOutput).toHaveBeenCalledWith('update-type', 'version-update:semver-major')
expect(core.setOutput).toHaveBeenCalledWith('directory', '')
expect(core.setOutput).toHaveBeenCalledWith('package-ecosystem', '')
expect(core.setOutput).toHaveBeenCalledWith('target-branch', '')
expect(core.setOutput).toHaveBeenCalledWith('previous-version', '')
expect(core.setOutput).toHaveBeenCalledWith('new-version', '')
expect(core.setOutput).toHaveBeenCalledWith('compatibility-score', 0)
expect(core.setOutput).toHaveBeenCalledWith('alert-state', '')
expect(core.setOutput).toHaveBeenCalledWith('ghsa-id', '')
expect(core.setOutput).toHaveBeenCalledWith('cvss', 0)
})
test('when the dependency has no update type', async () => {
@@ -131,18 +131,18 @@ test('when the dependency has no update type', async () => {
expect(core.setOutput).toHaveBeenCalledWith('updated-dependencies-json', updatedDependencies)
expect(core.setOutput).toBeCalledWith('dependency-names', 'coffee-rails')
expect(core.setOutput).toBeCalledWith('dependency-type', 'direct:production')
expect(core.setOutput).toBeCalledWith('update-type', null)
expect(core.setOutput).toBeCalledWith('directory', '')
expect(core.setOutput).toBeCalledWith('package-ecosystem', '')
expect(core.setOutput).toBeCalledWith('target-branch', '')
expect(core.setOutput).toBeCalledWith('previous-version', '')
expect(core.setOutput).toBeCalledWith('new-version', '')
expect(core.setOutput).toBeCalledWith('compatibility-score', 0)
expect(core.setOutput).toBeCalledWith('alert-state', '')
expect(core.setOutput).toBeCalledWith('ghsa-id', '')
expect(core.setOutput).toBeCalledWith('cvss', 0)
expect(core.setOutput).toHaveBeenCalledWith('dependency-names', 'coffee-rails')
expect(core.setOutput).toHaveBeenCalledWith('dependency-type', 'direct:production')
expect(core.setOutput).toHaveBeenCalledWith('update-type', null)
expect(core.setOutput).toHaveBeenCalledWith('directory', '')
expect(core.setOutput).toHaveBeenCalledWith('package-ecosystem', '')
expect(core.setOutput).toHaveBeenCalledWith('target-branch', '')
expect(core.setOutput).toHaveBeenCalledWith('previous-version', '')
expect(core.setOutput).toHaveBeenCalledWith('new-version', '')
expect(core.setOutput).toHaveBeenCalledWith('compatibility-score', 0)
expect(core.setOutput).toHaveBeenCalledWith('alert-state', '')
expect(core.setOutput).toHaveBeenCalledWith('ghsa-id', '')
expect(core.setOutput).toHaveBeenCalledWith('cvss', 0)
})
test('when given a multiple dependencies, and some do not have update types', async () => {
@@ -175,16 +175,16 @@ test('when given a multiple dependencies, and some do not have update types', as
expect(core.setOutput).toHaveBeenCalledWith('updated-dependencies-json', updatedDependencies)
expect(core.setOutput).toBeCalledWith('dependency-names', 'rspec, coffee-rails, coffeescript, rspec-coffeescript')
expect(core.setOutput).toBeCalledWith('dependency-type', 'direct:development')
expect(core.setOutput).toBeCalledWith('update-type', 'version-update:semver-minor')
expect(core.setOutput).toBeCalledWith('directory', '')
expect(core.setOutput).toBeCalledWith('package-ecosystem', '')
expect(core.setOutput).toBeCalledWith('target-branch', '')
expect(core.setOutput).toBeCalledWith('previous-version', '')
expect(core.setOutput).toBeCalledWith('new-version', '')
expect(core.setOutput).toBeCalledWith('compatibility-score', 0)
expect(core.setOutput).toBeCalledWith('alert-state', '')
expect(core.setOutput).toBeCalledWith('ghsa-id', '')
expect(core.setOutput).toBeCalledWith('cvss', 0)
expect(core.setOutput).toHaveBeenCalledWith('dependency-names', 'rspec, coffee-rails, coffeescript, rspec-coffeescript')
expect(core.setOutput).toHaveBeenCalledWith('dependency-type', 'direct:development')
expect(core.setOutput).toHaveBeenCalledWith('update-type', 'version-update:semver-minor')
expect(core.setOutput).toHaveBeenCalledWith('directory', '')
expect(core.setOutput).toHaveBeenCalledWith('package-ecosystem', '')
expect(core.setOutput).toHaveBeenCalledWith('target-branch', '')
expect(core.setOutput).toHaveBeenCalledWith('previous-version', '')
expect(core.setOutput).toHaveBeenCalledWith('new-version', '')
expect(core.setOutput).toHaveBeenCalledWith('compatibility-score', 0)
expect(core.setOutput).toHaveBeenCalledWith('alert-state', '')
expect(core.setOutput).toHaveBeenCalledWith('ghsa-id', '')
expect(core.setOutput).toHaveBeenCalledWith('cvss', 0)
})

View File

@@ -133,20 +133,20 @@ test('it sets the updated dependency as an output for subsequent actions when gi
]
)
expect(core.setOutput).toBeCalledWith('dependency-names', 'coffee-rails')
expect(core.setOutput).toBeCalledWith('dependency-type', 'direct:production')
expect(core.setOutput).toBeCalledWith('update-type', 'version-update:semver-minor')
expect(core.setOutput).toBeCalledWith('directory', '/')
expect(core.setOutput).toBeCalledWith('package-ecosystem', 'nuget')
expect(core.setOutput).toBeCalledWith('target-branch', 'main')
expect(core.setOutput).toBeCalledWith('previous-version', '4.0.1')
expect(core.setOutput).toBeCalledWith('new-version', '4.2.2')
expect(core.setOutput).toBeCalledWith('compatibility-score', 0)
expect(core.setOutput).toBeCalledWith('maintainer-changes', false)
expect(core.setOutput).toBeCalledWith('dependency-group', '')
expect(core.setOutput).toBeCalledWith('alert-state', '')
expect(core.setOutput).toBeCalledWith('ghsa-id', '')
expect(core.setOutput).toBeCalledWith('cvss', 0)
expect(core.setOutput).toHaveBeenCalledWith('dependency-names', 'coffee-rails')
expect(core.setOutput).toHaveBeenCalledWith('dependency-type', 'direct:production')
expect(core.setOutput).toHaveBeenCalledWith('update-type', 'version-update:semver-minor')
expect(core.setOutput).toHaveBeenCalledWith('directory', '/')
expect(core.setOutput).toHaveBeenCalledWith('package-ecosystem', 'nuget')
expect(core.setOutput).toHaveBeenCalledWith('target-branch', 'main')
expect(core.setOutput).toHaveBeenCalledWith('previous-version', '4.0.1')
expect(core.setOutput).toHaveBeenCalledWith('new-version', '4.2.2')
expect(core.setOutput).toHaveBeenCalledWith('compatibility-score', 0)
expect(core.setOutput).toHaveBeenCalledWith('maintainer-changes', false)
expect(core.setOutput).toHaveBeenCalledWith('dependency-group', '')
expect(core.setOutput).toHaveBeenCalledWith('alert-state', '')
expect(core.setOutput).toHaveBeenCalledWith('ghsa-id', '')
expect(core.setOutput).toHaveBeenCalledWith('cvss', 0)
})
test('it sets the updated dependency as an output for subsequent actions when there is a leading v in the commit message version', async () => {
@@ -206,20 +206,20 @@ test('it sets the updated dependency as an output for subsequent actions when th
]
)
expect(core.setOutput).toBeCalledWith('dependency-names', 'coffee-rails')
expect(core.setOutput).toBeCalledWith('dependency-type', 'direct:production')
expect(core.setOutput).toBeCalledWith('update-type', 'version-update:semver-minor')
expect(core.setOutput).toBeCalledWith('directory', '/')
expect(core.setOutput).toBeCalledWith('package-ecosystem', 'nuget')
expect(core.setOutput).toBeCalledWith('target-branch', 'main')
expect(core.setOutput).toBeCalledWith('previous-version', 'v4.0.1')
expect(core.setOutput).toBeCalledWith('new-version', 'v4.2.2')
expect(core.setOutput).toBeCalledWith('compatibility-score', 0)
expect(core.setOutput).toBeCalledWith('maintainer-changes', false)
expect(core.setOutput).toBeCalledWith('dependency-group', '')
expect(core.setOutput).toBeCalledWith('alert-state', '')
expect(core.setOutput).toBeCalledWith('ghsa-id', '')
expect(core.setOutput).toBeCalledWith('cvss', 0)
expect(core.setOutput).toHaveBeenCalledWith('dependency-names', 'coffee-rails')
expect(core.setOutput).toHaveBeenCalledWith('dependency-type', 'direct:production')
expect(core.setOutput).toHaveBeenCalledWith('update-type', 'version-update:semver-minor')
expect(core.setOutput).toHaveBeenCalledWith('directory', '/')
expect(core.setOutput).toHaveBeenCalledWith('package-ecosystem', 'nuget')
expect(core.setOutput).toHaveBeenCalledWith('target-branch', 'main')
expect(core.setOutput).toHaveBeenCalledWith('previous-version', 'v4.0.1')
expect(core.setOutput).toHaveBeenCalledWith('new-version', 'v4.2.2')
expect(core.setOutput).toHaveBeenCalledWith('compatibility-score', 0)
expect(core.setOutput).toHaveBeenCalledWith('maintainer-changes', false)
expect(core.setOutput).toHaveBeenCalledWith('dependency-group', '')
expect(core.setOutput).toHaveBeenCalledWith('alert-state', '')
expect(core.setOutput).toHaveBeenCalledWith('ghsa-id', '')
expect(core.setOutput).toHaveBeenCalledWith('cvss', 0)
})
test('it supports returning information about grouped updates', async () => {
@@ -390,20 +390,20 @@ test('it sets the updated dependency as an output for subsequent actions when gi
]
)
expect(core.setOutput).toBeCalledWith('dependency-names', 'rubocop')
expect(core.setOutput).toBeCalledWith('dependency-type', 'direct:development')
expect(core.setOutput).toBeCalledWith('update-type', 'version-update:semver-minor')
expect(core.setOutput).toBeCalledWith('directory', '/')
expect(core.setOutput).toBeCalledWith('package-ecosystem', 'bundler')
expect(core.setOutput).toBeCalledWith('target-branch', 'main')
expect(core.setOutput).toBeCalledWith('previous-version', '1.30.1')
expect(core.setOutput).toBeCalledWith('new-version', '1.31.0')
expect(core.setOutput).toBeCalledWith('compatibility-score', 0)
expect(core.setOutput).toBeCalledWith('maintainer-changes', false)
expect(core.setOutput).toBeCalledWith('dependency-group', '')
expect(core.setOutput).toBeCalledWith('alert-state', '')
expect(core.setOutput).toBeCalledWith('ghsa-id', '')
expect(core.setOutput).toBeCalledWith('cvss', 0)
expect(core.setOutput).toHaveBeenCalledWith('dependency-names', 'rubocop')
expect(core.setOutput).toHaveBeenCalledWith('dependency-type', 'direct:development')
expect(core.setOutput).toHaveBeenCalledWith('update-type', 'version-update:semver-minor')
expect(core.setOutput).toHaveBeenCalledWith('directory', '/')
expect(core.setOutput).toHaveBeenCalledWith('package-ecosystem', 'bundler')
expect(core.setOutput).toHaveBeenCalledWith('target-branch', 'main')
expect(core.setOutput).toHaveBeenCalledWith('previous-version', '1.30.1')
expect(core.setOutput).toHaveBeenCalledWith('new-version', '1.31.0')
expect(core.setOutput).toHaveBeenCalledWith('compatibility-score', 0)
expect(core.setOutput).toHaveBeenCalledWith('maintainer-changes', false)
expect(core.setOutput).toHaveBeenCalledWith('dependency-group', '')
expect(core.setOutput).toHaveBeenCalledWith('alert-state', '')
expect(core.setOutput).toHaveBeenCalledWith('ghsa-id', '')
expect(core.setOutput).toHaveBeenCalledWith('cvss', 0)
})
test('if there are multiple dependencies, it summarizes them', async () => {
@@ -484,20 +484,20 @@ test('if there are multiple dependencies, it summarizes them', async () => {
]
)
expect(core.setOutput).toBeCalledWith('dependency-names', 'coffee-rails, coffeescript')
expect(core.setOutput).toBeCalledWith('dependency-type', 'direct:production')
expect(core.setOutput).toBeCalledWith('update-type', 'version-update:semver-major')
expect(core.setOutput).toBeCalledWith('directory', '/api/main')
expect(core.setOutput).toBeCalledWith('package-ecosystem', 'npm_and_yarn')
expect(core.setOutput).toBeCalledWith('target-branch', 'trunk')
expect(core.setOutput).toBeCalledWith('previous-version', '4.0.1')
expect(core.setOutput).toBeCalledWith('new-version', '4.2.2')
expect(core.setOutput).toBeCalledWith('compatibility-score', 34)
expect(core.setOutput).toBeCalledWith('maintainer-changes', false)
expect(core.setOutput).toBeCalledWith('dependency-group', '')
expect(core.setOutput).toBeCalledWith('alert-state', '')
expect(core.setOutput).toBeCalledWith('ghsa-id', '')
expect(core.setOutput).toBeCalledWith('cvss', 0)
expect(core.setOutput).toHaveBeenCalledWith('dependency-names', 'coffee-rails, coffeescript')
expect(core.setOutput).toHaveBeenCalledWith('dependency-type', 'direct:production')
expect(core.setOutput).toHaveBeenCalledWith('update-type', 'version-update:semver-major')
expect(core.setOutput).toHaveBeenCalledWith('directory', '/api/main')
expect(core.setOutput).toHaveBeenCalledWith('package-ecosystem', 'npm_and_yarn')
expect(core.setOutput).toHaveBeenCalledWith('target-branch', 'trunk')
expect(core.setOutput).toHaveBeenCalledWith('previous-version', '4.0.1')
expect(core.setOutput).toHaveBeenCalledWith('new-version', '4.2.2')
expect(core.setOutput).toHaveBeenCalledWith('compatibility-score', 34)
expect(core.setOutput).toHaveBeenCalledWith('maintainer-changes', false)
expect(core.setOutput).toHaveBeenCalledWith('dependency-group', '')
expect(core.setOutput).toHaveBeenCalledWith('alert-state', '')
expect(core.setOutput).toHaveBeenCalledWith('ghsa-id', '')
expect(core.setOutput).toHaveBeenCalledWith('cvss', 0)
})
test('it sets the action to failed if there is an unexpected exception', async () => {