Skip to content

Commit cd6131c

Browse files
committed
fix: Add tests for deprecation warning
1 parent 52f9d72 commit cd6131c

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
codecov_token: faketoken

test/helpers/token.test.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const path = require('path')
2+
const { expect, it } = require('@jest/globals')
23

34
const fileHelpers = require('../../src/helpers/files')
45
const tokenHelpers = require('../../src/helpers/token')
@@ -8,7 +9,15 @@ describe('Get tokens', () => {
89
fileHelpers.fetchGitRoot(),
910
'test/fixtures/yaml',
1011
)
11-
console.log(fixturesDir)
12+
const invalidFixturesDir = path.join(
13+
fileHelpers.fetchGitRoot(),
14+
'test/fixtures/invalid_yaml',
15+
)
16+
17+
afterEach(() => {
18+
jest.clearAllMocks()
19+
})
20+
1221
describe('From yaml', () => {
1322
it('Returns empty with no yaml file', () => {
1423
expect(tokenHelpers.getTokenFromYaml('.')).toBe('')
@@ -19,6 +28,19 @@ describe('Get tokens', () => {
1928
tokenHelpers.getTokenFromYaml(fixturesDir, { verbose: true }),
2029
).toBe('faketoken')
2130
})
31+
32+
it('Returns deprecation error from codecov_token', () => {
33+
jest.spyOn(console, 'error').mockImplementation(() => {
34+
// Intentionally empty
35+
})
36+
expect(
37+
tokenHelpers.getTokenFromYaml(invalidFixturesDir, { verbose: true }),
38+
).toBe('')
39+
40+
expect(console.error).toHaveBeenCalledWith(
41+
expect.stringContaining("'codecov_token' is a deprecated field"),
42+
)
43+
})
2244
})
2345

2446
describe('From right source', () => {

0 commit comments

Comments
 (0)