diff --git a/src/targets/__tests__/registry.test.ts b/src/targets/__tests__/registry.test.ts new file mode 100644 index 00000000..1ec3a3de --- /dev/null +++ b/src/targets/__tests__/registry.test.ts @@ -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'); + }); +}); diff --git a/src/targets/registry.ts b/src/targets/registry.ts index df651845..f333b9dc 100644 --- a/src/targets/registry.ts +++ b/src/targets/registry.ts @@ -362,7 +362,15 @@ export class RegistryTarget extends BaseTarget { ); } // Update the manifest - const updatedManifest = { ...packageManifest, version }; + const updatedManifest: { + version: string; + createdAt: string; + [key: string]: any; + } = { + ...packageManifest, + version, + createdAt: new Date().toISOString(), + }; // Add file links if it's a generic app (legacy) if (registryConfig.type === RegistryPackageType.APP) {