Skip to content

Commit

Permalink
Merge pull request #67 from zcei/fix/preview-url-for-surface-types
Browse files Browse the repository at this point in the history
🐛 Fix preview url for home and modal surfaces
  • Loading branch information
raycharius authored Aug 30, 2021
2 parents 77db4ea + c6ce85f commit 2b4ad0d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/methods/other-methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export abstract class GetPreviewUrl extends Builder {
const result = this.build();

const baseUri = 'https://app.slack.com/block-kit-builder/#';
const stringifiedBlocks = this.props.type
const stringifiedBlocks = result.type
? JSON.stringify(result)
: JSON.stringify({ blocks: result.blocks, attachments: result.attachments });

Expand Down
6 changes: 3 additions & 3 deletions tests/surfaces/surface.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ describe('Surfaces', () => {

const result = modal.getPreviewUrl();

expect(result).toEqual('https://app.slack.com/block-kit-builder/#%7B%22blocks%22:%5B%7B%22type%22:%22divider%22%7D%5D%7D');
expect(result).toEqual('https://app.slack.com/block-kit-builder/#%7B%22blocks%22:%5B%7B%22type%22:%22divider%22%7D%5D,%22type%22:%22home%22%7D');
});

test('Calling \'getPreviewUrl()\' for Modal returns the URL as a string.', () => {
const message = Modal()
const message = Modal({ submit: 'Start' })
.blocks(Blocks.Divider());

const result = message.getPreviewUrl();

expect(result).toEqual('https://app.slack.com/block-kit-builder/#%7B%22blocks%22:%5B%7B%22type%22:%22divider%22%7D%5D%7D');
expect(result).toEqual('https://app.slack.com/block-kit-builder/#%7B%22submit%22:%7B%22type%22:%22plain_text%22,%22text%22:%22Start%22%7D,%22blocks%22:%5B%7B%22type%22:%22divider%22%7D%5D,%22type%22:%22modal%22%7D');
});

test('Calling \'printPreviewUrl()\' for HomeTab logs the URL to the console.', () => {
Expand Down

0 comments on commit 2b4ad0d

Please sign in to comment.