-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f80a23b
commit d8d9c1a
Showing
1 changed file
with
30 additions
and
0 deletions.
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,30 @@ | ||
import { applyUniqueIds } from '../../src/custom-operations'; | ||
|
||
describe('applying unique ids', function() { | ||
it('should not do anything for v2 inputs', async function() { | ||
const input = {asyncapi: '2.0.0'}; | ||
const output = {...input}; | ||
applyUniqueIds(output); | ||
expect(input).toEqual(output); | ||
}); | ||
describe('for v3', function() { | ||
it('should work with no channels input', async function() { | ||
const input = {asyncapi: '3.0.0'}; | ||
const output = {...input}; | ||
applyUniqueIds(output); | ||
expect(input).toEqual(output); | ||
}); | ||
it('should set unique id when input has channels', async function() { | ||
const input = {asyncapi: '3.0.0', channels: {testChannel: {}}}; | ||
const output = {...input, channels: {testChannel: {'x-parser-unique-object-id': 'testChannel'}}}; | ||
applyUniqueIds(input); | ||
expect(input).toEqual(output); | ||
}); | ||
it('should set unique id when input has messages in channels', async function() { | ||
const input = {asyncapi: '3.0.0', channels: {testChannel: {messages: {testMessage: {}}}}}; | ||
const output = {...input, channels: {testChannel: {'x-parser-unique-object-id': 'testChannel', messages: {testMessage: {'x-parser-unique-object-id': 'testMessage'}}}}}; | ||
applyUniqueIds(input); | ||
expect(input).toEqual(output); | ||
}); | ||
}); | ||
}); |