Skip to content

Commit 82c2120

Browse files
Merge branch 'master' into 877
2 parents 4c814bb + 15fba18 commit 82c2120

5 files changed

Lines changed: 29 additions & 2 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
2+
.npm-cache
23
.vscode
34
.DS_Store
45
/docs

packages/parser/test/models/v2/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,5 @@ export function assertTags(model: Constructor<TagsMixinInterface>) {
147147
expect(d3.tags().length).toEqual(0);
148148
});
149149
});
150-
}
150+
}
151+

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,22 @@ describe('AsyncAPIDocument model', function() {
289289
const d = new AsyncAPIDocument(doc);
290290
expect(d.allChannels()).toBeInstanceOf(Channels);
291291
});
292+
293+
it('should expose channel title and hasTitle', function() {
294+
const doc = serializeInput<v3.AsyncAPIObject>({
295+
channels: {
296+
'user/signup': {
297+
address: 'user/signup',
298+
title: 'User signup channel',
299+
},
300+
},
301+
});
302+
const d = new AsyncAPIDocument(doc);
303+
const channel = d.allChannels().all()[0];
304+
expect(channel.id()).toEqual('user/signup');
305+
expect(channel.hasTitle()).toEqual(true);
306+
expect(channel.title()).toEqual('User signup channel');
307+
});
292308
});
293309

294310
describe('.allOperations()', function() {

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ describe('parse()', function () {
436436
expect(document).toBeInstanceOf(AsyncAPIDocumentV3);
437437
expect(filterLastVersionDiagnostics(diagnostics).length === 0).toEqual(true);
438438
});
439-
439+
440440
it('should return server title and summary from allServers()', async function () {
441441
const { document, diagnostics } = await parser.parse(`
442442
asyncapi: 3.0.0

0 commit comments

Comments
 (0)