-
Notifications
You must be signed in to change notification settings - Fork 901
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests and refine dependency checks
- Loading branch information
1 parent
c00b44d
commit a7ee439
Showing
2 changed files
with
71 additions
and
9 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
packages/cli-doctor/src/tools/healthchecks/__tests__/dependencies.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import fs from 'fs'; | ||
import dependencies from '../dependencies'; | ||
import {EnvironmentInfo} from '../../../types'; | ||
|
||
describe('dependencies', () => { | ||
let environmentInfo: EnvironmentInfo; | ||
let dependenciesJSON: string; | ||
|
||
beforeEach(() => { | ||
jest.spyOn(fs, 'readFileSync').mockImplementation(() => dependenciesJSON); | ||
}); | ||
|
||
it('returns false if dependencies are correct', async () => { | ||
dependenciesJSON = JSON.stringify({ | ||
name: 'AwesomeProject', | ||
dependencies: { | ||
'react-native': '0.72.1', | ||
}, | ||
}); | ||
|
||
const diagnostics = await dependencies.getDiagnostics(environmentInfo); | ||
expect(diagnostics.needsToBeFixed).toBe(false); | ||
}); | ||
|
||
it('returns true if dependencies contains an incompatible version react native package', async () => { | ||
dependenciesJSON = JSON.stringify({ | ||
name: 'AwesomeProject', | ||
dependencies: { | ||
'react-native': '0.72.1', | ||
'@react-native/codegen': '1.72.3', | ||
'@react-native/gradle-plugin': '0.69.10', | ||
}, | ||
}); | ||
|
||
const diagnostics = await dependencies.getDiagnostics(environmentInfo); | ||
expect(diagnostics.needsToBeFixed).toBe(true); | ||
}); | ||
|
||
it('returns true if dependencies contains an compatible version react native package', async () => { | ||
dependenciesJSON = JSON.stringify({ | ||
name: 'AwesomeProject', | ||
dependencies: { | ||
'react-native': '0.72.1', | ||
'@react-native/codegen': '0.72.1', | ||
}, | ||
}); | ||
|
||
const diagnostics = await dependencies.getDiagnostics(environmentInfo); | ||
expect(diagnostics.needsToBeFixed).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters