-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for BasePackageLoader and DefaultPackageLoader (#39 part 1)
- BasePackageLoader tests - DefaultPackageLoader tests - Additional json files used taken from fpl and sushi
- Loading branch information
1 parent
6fc82fa
commit a7dca5b
Showing
12 changed files
with
9,263 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,35 @@ | ||
import { loggerSpy } from '../testhelpers'; | ||
import { mock } from 'jest-mock-extended'; | ||
import { BasePackageLoader, BasePackageLoaderOptions } from '../../src/loader/BasePackageLoader'; | ||
import { LoadStatus } from '../../src/loader/PackageLoader'; | ||
import { PackageDB } from '../../src/db'; | ||
import { PackageCache } from '../../src/cache'; | ||
import { RegistryClient } from '../../src/registry'; | ||
import { CurrentBuildClient } from '../../src/current'; | ||
|
||
describe('DefaultPackageLoader', () => { | ||
|
||
async function makeMyDefaultPackageLoader(options: BasePackageLoaderOptions) : Promise<BasePackageLoader> { | ||
const packageDBMock = mock<PackageDB>(); | ||
const packageCacheMock = mock<PackageCache>(); | ||
const registryClientMock = mock<RegistryClient>(); | ||
const currentBuildClientMock = mock<CurrentBuildClient>(); | ||
const loader = new BasePackageLoader( | ||
packageDBMock, | ||
packageCacheMock, | ||
registryClientMock, | ||
currentBuildClientMock, | ||
{ log: options.log } | ||
); | ||
return loader; | ||
} | ||
|
||
it('should create a package loader with mock default package loader' , async () => { | ||
const loader = await makeMyDefaultPackageLoader({log: loggerSpy.log}); | ||
loader.getPackageLoadStatus = jest.fn().mockReturnValueOnce(LoadStatus.LOADED); | ||
|
||
const result = await loader.loadPackage('some.ig', '1.2.3'); | ||
expect(result).toBe(LoadStatus.LOADED); | ||
expect(loader.getPackageLoadStatus).toHaveBeenCalledWith('some.ig', '1.2.3'); | ||
}); | ||
}); |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.