Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add reply() to the Operation model #834

Merged
Merged
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
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