Add document build test
This commit is contained in:
parent
475904a266
commit
c2bd392c84
@ -37,6 +37,7 @@ func NewDocument(
|
||||
thread threadmodels.Thread,
|
||||
stateProvider InitialStateProvider,
|
||||
accountData *AccountData) *Document {
|
||||
|
||||
decoder := threadmodels.NewEd25519Decoder()
|
||||
return &Document{
|
||||
thread: thread,
|
||||
|
||||
28
data/document_test.go
Normal file
28
data/document_test.go
Normal file
@ -0,0 +1,28 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/data/threadbuilder"
|
||||
)
|
||||
|
||||
func TestDocument_Build(t *testing.T) {
|
||||
thread, err := threadbuilder.NewThreadBuilderFromFile("threadbuilder/userjoinexample.yml")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
keychain := thread.GetKeychain()
|
||||
accountData := &AccountData{
|
||||
Identity: keychain.GetIdentity("A"),
|
||||
EncKey: keychain.EncryptionKeys["A"],
|
||||
}
|
||||
doc := NewDocument(thread, NewPlainTextDocumentStateProvider(), accountData)
|
||||
res, err := doc.Build()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
st := res.(*PlainTextDocumentState)
|
||||
assert.Equal(t, st.Text, "some text|first")
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user