Skip to content

Commit 8e82645

Browse files
authored
test(asyncapi-2-0): add test for Operation.message dereferencing (#530)
Refs #427
1 parent 8798c4b commit 8e82645

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[
2+
{
3+
"asyncapi": "2.0.0",
4+
"channels": {
5+
"user/signedup": {
6+
"subscribe": {
7+
"summary": "A user signed up.",
8+
"operationId": "emitUserSignUpEvent",
9+
"message": [
10+
{
11+
"name": "userSignedUp",
12+
"title": "User signed up event",
13+
"summary": "Inform about a new user",
14+
"contentType": "application/json",
15+
"payload": {}
16+
}
17+
]
18+
}
19+
}
20+
},
21+
"components": {
22+
"messages": {
23+
"UserSignedUp": {
24+
"name": "userSignedUp",
25+
"title": "User signed up event",
26+
"summary": "Inform about a new user",
27+
"contentType": "application/json",
28+
"payload": {}
29+
}
30+
}
31+
}
32+
}
33+
]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"asyncapi": "2.0.0",
3+
"channels": {
4+
"user/signedup": {
5+
"subscribe": {
6+
"summary": "A user signed up.",
7+
"operationId": "emitUserSignUpEvent",
8+
"message": [
9+
{
10+
"$ref": "#/components/messages/UserSignedUp"
11+
}
12+
]
13+
}
14+
}
15+
},
16+
"components": {
17+
"messages": {
18+
"UserSignedUp": {
19+
"name": "userSignedUp",
20+
"title": "User signed up event",
21+
"summary": "Inform about a new user",
22+
"contentType": "application/json",
23+
"payload": {}
24+
}
25+
}
26+
}
27+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import path from 'path';
2+
import { assert } from 'chai';
3+
import { toValue } from 'apidom';
4+
5+
import { loadJsonFile } from '../../../../helpers';
6+
import { dereference } from '../../../../../src';
7+
8+
const rootFixturePath = path.join(__dirname, 'fixtures');
9+
10+
describe('dereference', function () {
11+
context('strategies', function () {
12+
context('asyncapi-2-0', function () {
13+
context('Message Object', function () {
14+
context('given in Operation Object', function () {
15+
const fixturePath = path.join(rootFixturePath, 'operation-object');
16+
17+
specify('should dereference', async function () {
18+
const rootFilePath = path.join(fixturePath, 'root.json');
19+
const actual = await dereference(rootFilePath, {
20+
parse: { mediaType: 'application/vnd.aai.asyncapi+json;version=2.0.0' },
21+
});
22+
const expected = loadJsonFile(path.join(fixturePath, 'dereferenced.json'));
23+
24+
assert.deepEqual(toValue(actual), expected);
25+
});
26+
});
27+
});
28+
});
29+
});
30+
});

0 commit comments

Comments
 (0)