Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
Signed-off-by: Valeriy Svydenko <[email protected]>
  • Loading branch information
svor committed Feb 7, 2024
1 parent c37102b commit 90c9c74
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions tools/build/tests/devfile-yaml/index-writer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,9 @@ describe('Test IndexWriter', () => {
fsEnsureDirSpy.mockReturnValue();
fsWriteFileSpy.mockReturnValue();

let error: any;
try {
await indexWriter.write(editors);
} catch (e: any) {
error = e;
}
expect(error.message).toBe('The metadata of {"schemaVersion":"2.2.2"} is not defined');
await expect(indexWriter.write(editors)).rejects.toThrow(
'The metadata of {"schemaVersion":"2.2.2"} is not defined',
);
});

test('throw an error if name is not defined', async () => {
Expand All @@ -156,13 +152,7 @@ describe('Test IndexWriter', () => {
fsEnsureDirSpy.mockReturnValue();
fsWriteFileSpy.mockReturnValue();

let error: any;
try {
await indexWriter.write(editors);
} catch (e: any) {
error = e;
}
expect(error.message).toBe('The id of {"displayName":"display-name"} is not defined');
await expect(indexWriter.write(editors)).rejects.toThrow('The id of {"displayName":"display-name"} is not defined');
});

test('throw an error if id is not valid', async () => {
Expand All @@ -181,13 +171,7 @@ describe('Test IndexWriter', () => {
fsEnsureDirSpy.mockReturnValue();
fsWriteFileSpy.mockReturnValue();

let error: any;
try {
await indexWriter.write(editors);
} catch (e: any) {
error = e;
}
expect(error.message).toBe(
await expect(indexWriter.write(editors)).rejects.toThrow(
'The id for my-publisher/my-name is not composed of 3 parts separated by / like <1>/<2>/<3>',
);
});
Expand Down

0 comments on commit 90c9c74

Please sign in to comment.