Skip to content

Commit

Permalink
fix: add reply() to the Operation model (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
smoya authored Aug 10, 2023
1 parent 0ae86fb commit b82b150
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/models/operation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { BaseModel } from './base';
import type { ChannelsInterface } from './channels';
import type { MessagesInterface } from './messages';
import type { OperationReplyInterface } from './operation-reply';
import type { OperationTraitsInterface } from './operation-traits';
import type { OperationTraitInterface } from './operation-trait';
import type { ServersInterface } from './servers';
Expand All @@ -14,5 +15,6 @@ export interface OperationInterface extends BaseModel, OperationTraitInterface {
servers(): ServersInterface;
channels(): ChannelsInterface;
messages(): MessagesInterface;
reply(): OperationReplyInterface | undefined;
traits(): OperationTraitsInterface;
}
5 changes: 5 additions & 0 deletions src/models/v2/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type { ChannelsInterface } from '../channels';
import type { ChannelInterface } from '../channel';
import type { MessagesInterface } from '../messages';
import type { OperationInterface, OperationAction } from '../operation';
import type { OperationReplyInterface } from '../operation-reply';
import type { OperationTraitsInterface } from '../operation-traits';
import type { ServersInterface } from '../servers';
import type { ServerInterface } from '../server';
Expand Down Expand Up @@ -76,6 +77,10 @@ export class Operation extends OperationTrait<v2.OperationObject> implements Ope
);
}

reply(): OperationReplyInterface | undefined {
return;
}

traits(): OperationTraitsInterface {
return new OperationTraits(
(this._json.traits || []).map((trait: any, index: number) => {
Expand Down
8 changes: 8 additions & 0 deletions test/models/v2/operation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ describe('Operation model', function() {
});
});

describe('.reply()', function() {
it('should return always undefined as it is not a feature part of v2', function() {
const doc = { reply: {} };
const d = new Operation(doc);
expect(d.reply()).toBeUndefined();
});
});

describe('.traits()', function() {
it('should return collection of traits', function() {
const doc = { traits: [{ operationId: '...' }] };
Expand Down

0 comments on commit b82b150

Please sign in to comment.