Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions packages/api/src/activities/activity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ describe('Activity', () => {
});

describe('addCitation', () => {
it('should add', () => {
it('should set encodingFormat when text is provided', () => {
const activity = new Activity({ type: 'test' }).addCitation(0, {
abstract: 'test',
name: 'test',
text: 'adaptive card content',
});

expect(activity.type).toEqual('test');
Expand All @@ -194,23 +195,32 @@ describe('Activity', () => {
expect.objectContaining({
'@type': 'Claim',
position: 0,
appearance: {
appearance: expect.objectContaining({
'@type': 'DigitalDocument',
abstract: 'test',
name: 'test',
encodingFormat: 'application/vnd.microsoft.card.adaptive',
},
}),
}),
],
},
]);
});

it('should add with icon', () => {
it('should omit encodingFormat when text is not provided', () => {
const activity = new Activity({ type: 'test' }).addCitation(0, {
abstract: 'test',
name: 'test',
});
expect(activity.entities?.at(0)?.citation?.at(0)?.appearance.encodingFormat).toBeUndefined();
});

it('should include image when icon is provided', () => {
const activity = new Activity({ type: 'test' }).addCitation(0, {
abstract: 'test',
name: 'test',
icon: 'GIF',
text: 'adaptive card content',
});

expect(activity.type).toEqual('test');
Expand All @@ -224,7 +234,7 @@ describe('Activity', () => {
expect.objectContaining({
'@type': 'Claim',
position: 0,
appearance: {
appearance: expect.objectContaining({
'@type': 'DigitalDocument',
abstract: 'test',
name: 'test',
Expand All @@ -233,7 +243,7 @@ describe('Activity', () => {
'@type': 'ImageObject',
name: 'GIF',
},
},
}),
}),
],
},
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/activities/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ export class Activity<T extends string = string> implements IActivity<T> {
'@type': 'DigitalDocument',
abstract: appearance.abstract,
name: appearance.name,
encodingFormat: 'application/vnd.microsoft.card.adaptive',
encodingFormat: appearance.text ? 'application/vnd.microsoft.card.adaptive' : undefined,
image: appearance.icon
? {
'@type': 'ImageObject',
Expand Down
Loading