Skip to content

Commit 54d3120

Browse files
feat: add suitable test cases for v3 support channel title
1 parent 9cfb7e9 commit 54d3120

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

packages/parser/test/models/v3/asyncapi.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,11 @@ describe('AsyncAPIDocument model', function() {
270270
expect(d.allChannels()).toBeInstanceOf(Channels);
271271
});
272272

273+
<<<<<<< Updated upstream
273274
it('should expose channel title and hasTitle (#1067)', function() {
275+
=======
276+
it('should expose channel title and hasTitle', function() {
277+
>>>>>>> Stashed changes
274278
const doc = serializeInput<v3.AsyncAPIObject>({
275279
channels: {
276280
'user/signup': {

packages/parser/test/models/v3/channel.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ describe('Channel model', function() {
2929
});
3030
});
3131

32+
describe('.title()', function() {
33+
it('should return channel title from spec', function() {
34+
const doc = serializeInput<v3.ChannelObject>({ address: 'user/signup', title: 'User signup channel' });
35+
const d = new Channel(doc, { asyncapi: {} as any, pointer: '/channels/user~1signup', id: 'user/signup' });
36+
expect(d.hasTitle()).toEqual(true);
37+
expect(d.title()).toEqual('User signup channel');
38+
});
39+
});
40+
3241
describe('.servers()', function() {
3342
it('should return collection of servers - available on all servers', function() {
3443
const doc = serializeInput<v3.ChannelObject>({});

packages/parser/test/parse.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,26 @@ channels:
457457
expect(channel.title()).toEqual('User signup channel');
458458
});
459459

460+
it('should return channel title from allChannels()', async function () {
461+
const { document, diagnostics } = await parser.parse(`
462+
asyncapi: 3.0.0
463+
info:
464+
title: API
465+
version: 1.0.0
466+
channels:
467+
user/signup:
468+
address: user/signup
469+
title: User signup channel
470+
`);
471+
472+
expect(document).toBeDefined();
473+
expect(filterLastVersionDiagnostics(diagnostics).length === 0).toEqual(true);
474+
const channel = document!.allChannels().all()[0];
475+
expect(channel.id()).toEqual('user/signup');
476+
expect(channel.hasTitle()).toEqual(true);
477+
expect(channel.title()).toEqual('User signup channel');
478+
});
479+
460480
it('should not parse invalid v3 YAML document and give error in line 153 (#936)', async function () {
461481
const documentRaw = `asyncapi: 3.0.0
462482
info:

0 commit comments

Comments
 (0)