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

a composed message has a content ID #26

Merged
merged 5 commits into from
Jul 17, 2019
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
50 changes: 50 additions & 0 deletions packages/main/src/compose/edit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,52 @@ it("edits a message", () => {
})
})

it("has a Content-ID header", async () => {
const content = {
type: "text",
subtype: "plain",
content: "What I meant to say was, hello!"
}
const testMessage = testThread[1].attributes
const testPart = testMessage.struct![0] as imap.ImapMessagePart
const editedMessage = {
envelope_messageId: testMessage.envelope.messageId
}
const editedPart = {
content_id: testPart.id
}
const { attributes } = composeEdit({
account,
content,
conversation: conversationFrom(testThread),
editedMessage,
editedPart
})

expect(attributes).toMatchObject({
struct: [
hallettj marked this conversation as resolved.
Show resolved Hide resolved
{
type: "multipart",
subtype: "mixed"
},
[
{
type: "text",
subtype: "plain",
id: expect.any(String)
}
],
[
{
type: content.type,
subtype: content.subtype,
id: expect.any(String)
}
]
]
})
})

function conversationFrom(
messages: Array<{ attributes: MessageAttributes }>
): C.Conversation {
Expand All @@ -89,3 +135,7 @@ function conversationFrom(
}
return cache.getThreads(accountId)[0]
}

afterEach(async () => {
db.prepare("delete from accounts").run()
hallettj marked this conversation as resolved.
Show resolved Hide resolved
})
30 changes: 30 additions & 0 deletions packages/main/src/compose/newConversation.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { MessageInput } from "../generated/graphql"
import { composeNewConversation } from "./newConversation"

describe("a message for a new Conversation", () => {
it("has a content-ID", async () => {
hallettj marked this conversation as resolved.
Show resolved Hide resolved
const account = { email: "[email protected]", id: 1 }

const message: MessageInput = {
subject: "testing",
to: [{ host: "test.com", mailbox: "ben", name: "Ben Reitman" }],
content: {
type: "text",
subtype: "plain",
content: "hey just testing"
}
}

const { attributes } = composeNewConversation({ account, message })

expect(attributes).toMatchObject({
struct: [
{
id: expect.any(String),
type: message.content.type,
subtype: message.content.subtype
}
]
})
})
})
28 changes: 28 additions & 0 deletions packages/main/src/compose/reply.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,34 @@ describe("reply recipients", () => {
})
})

describe("reply", () => {
it("has a Content-ID header", async () => {
hallettj marked this conversation as resolved.
Show resolved Hide resolved
const content = {
type: "text",
subtype: "plain",
content: "What I meant to say was, hello!"
}

const { attributes } = composeReply({
account,
content,
conversation: conversationFrom(testThread)
})

expect(attributes).toMatchObject({
struct: [
{
id: expect.any(String),
partID: "1",
type: content.type,
subtype: content.subtype,
params: { charset: "UTF-8" }
}
]
})
})
})

afterEach(() => {
db.prepare("delete from accounts").run()
})
Expand Down