-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
createdAt
key to json in registry (#532)
* feat: Add `created` key to json in registry * ref: createdAt * ref: Add more type safety * ref changelog * reset changelog * Add simple unit test * Add mock
- Loading branch information
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
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,48 @@ | ||
jest.mock('../../utils/githubApi.ts'); | ||
import { getGitHubClient } from '../../utils/githubApi'; | ||
import { RegistryConfig, RegistryTarget } from '../registry'; | ||
import { NoneArtifactProvider } from '../../artifact_providers/none'; | ||
import { RegistryPackageType } from '../../utils/registry'; | ||
|
||
describe('getUpdatedManifest', () => { | ||
let mockClient: jest.Mock; | ||
|
||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
mockClient = jest.fn(); | ||
(getGitHubClient as jest.MockedFunction< | ||
typeof getGitHubClient | ||
// @ts-ignore we only need to mock a subset | ||
>).mockReturnValue({ graphql: mockClient }); | ||
}); | ||
|
||
const target = new RegistryTarget( | ||
{ name: 'pypi' }, | ||
new NoneArtifactProvider(), | ||
{ owner: 'testSourceOwner', repo: 'testSourceRepo' } | ||
); | ||
|
||
it('check if createdAt exists', async () => { | ||
const registryConfig: RegistryConfig = { | ||
type: RegistryPackageType.SDK, | ||
canonicalName: 'example-package', | ||
}; | ||
const packageManifest = { | ||
canonical: 'example-package', | ||
}; | ||
const canonical = 'example-package'; | ||
const version = '1.2.3'; | ||
const revision = 'abc123'; | ||
|
||
const updatedManifest = await target.getUpdatedManifest( | ||
registryConfig, | ||
packageManifest, | ||
canonical, | ||
version, | ||
revision | ||
); | ||
|
||
// check if property createdAt exists | ||
expect(updatedManifest).toHaveProperty('createdAt'); | ||
}); | ||
}); |
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