summaryrefslogtreecommitdiffstats
path: root/app/export_test.go
blob: 05b81387aa338208552bb72316df13d495330583 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package app

import (
	"github.com/stretchr/testify/assert"
	"testing"

	"github.com/mattermost/mattermost-server/model"
)

func TestReactionsOfPost(t *testing.T) {
	th := Setup().InitBasic()
	defer th.TearDown()

	post := th.BasicPost
	post.HasReactions = true

	reactionObject := model.Reaction{
		UserId:    model.NewId(),
		PostId:    post.Id,
		EmojiName: "emoji",
		CreateAt:  model.GetMillis(),
	}

	th.App.SaveReactionForPost(&reactionObject)
	reactionsOfPost, err := th.App.BuildPostReactions(post.Id)

	if err != nil {
		t.Fatal("should have reactions")
	}

	assert.Equal(t, reactionObject.EmojiName, *(*reactionsOfPost)[0].EmojiName)
}