@@ -4,6 +4,9 @@ const { version } = require('../package.json')
44const nock = require ( 'nock' )
55const fs = require ( 'fs' )
66
7+ // Backup the env
8+ const realEnv = { ...process . env }
9+
710describe ( 'Uploader Core' , ( ) => {
811 const env = process . env
912
@@ -68,16 +71,26 @@ describe('Uploader Core', () => {
6871 expect ( log ) . toHaveBeenCalledWith ( expect . stringMatching ( / < < < < < < E N V / ) )
6972 } )
7073
71- it ( 'Can upload without token' , async ( ) => {
72- jest . spyOn ( process , 'exit' ) . mockImplementation ( ( ) => { } )
73- const log = jest . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } )
74- await app . main ( {
75- name : 'customname' ,
76- url : 'https://codecov.io' ,
77- dryRun : true ,
78- env : 'SOMETHING,ANOTHER' ,
74+ describe ( 'Token' , ( ) => {
75+ beforeEach ( ( ) => {
76+ delete process . env . CODECOV_TOKEN
77+ } )
78+
79+ afterEach ( ( ) => {
80+ process . env = realEnv
81+ } )
82+
83+ it ( 'Can upload without token' , async ( ) => {
84+ jest . spyOn ( process , 'exit' ) . mockImplementation ( ( ) => { } )
85+ const log = jest . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } )
86+ await app . main ( {
87+ name : 'customname' ,
88+ url : 'https://codecov.io' ,
89+ dryRun : true ,
90+ env : 'SOMETHING,ANOTHER' ,
91+ } )
92+ expect ( log ) . toHaveBeenCalledWith ( expect . stringMatching ( '-> No token specified or token is empty' ) )
7993 } )
80- expect ( log ) . toHaveBeenCalledWith ( expect . stringMatching ( '-> No token specified or token is empty' ) )
8194 } )
8295
8396 describe ( 'Flags' , ( ) => {
0 commit comments