Skip to content

Commit

Permalink
feat: add tests for button
Browse files Browse the repository at this point in the history
  • Loading branch information
fletcherist committed Aug 14, 2018
1 parent 791619c commit eda4471
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ exports = module.exports;
export default Alice;

export { Reply } from './reply/reply';
export { Markup } from './reply/markup';

export { InMemorySession } from './session/inMemorySession';
export { InMemorySessionStorage } from './session/inMemorySessionStorage';
export { ISession, ISessionStorage } from './session/session';
export { ISessionContext } from './session/sessionContext';
export { sessionMiddleware } from './session/sessionMiddleware';

export { IStageСompere } from './stage/compere';
export { IStageCompere } from './stage/compere';
export { IScene, Scene } from './stage/scene';
export { IStage, Stage } from './stage/stage';
export { IStageContext } from './stage/stageContext';
Expand Down
10 changes: 10 additions & 0 deletions src/reply/markup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { BodyButtonBuilder, BodyButtonDeclaration } from './bodyButtonBuilder';
import { IApiResponseBodyButton } from '../api/response';

export class Markup {
public static button(
declaration: BodyButtonDeclaration,
): IApiResponseBodyButton {
return BodyButtonBuilder.createBodyButton(declaration);
}
}
28 changes: 27 additions & 1 deletion tests/reply.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Reply } from '../dist';
import { Reply, Markup } from '../dist';
import { getRandomText } from './testUtils';

describe('Alice Reply (static method) suite', () => {
Expand Down Expand Up @@ -28,3 +28,29 @@ describe('Alice Reply (static method) suite', () => {
});
});
});

describe('Markup suite', () => {
test('Markup button with text constructor', () => {
const expected = {
title: 'foo',
payload: {
title: 'foo',
},
};
const button = Markup.button(expected.title);
expect(button).toEqual(expected);
});

test('Markup button with object constructor', () => {
const expected = {
title: 'foo',
hide: true,
url: '',
payload: {
title: 'foo',
},
};
const button = Markup.button(expected);
expect(button).toEqual(expected);
});
});

0 comments on commit eda4471

Please sign in to comment.