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

Tests for CoversationViewModel #5225

Merged
merged 2 commits into from Mar 9, 2023
Merged

Tests for CoversationViewModel #5225

merged 2 commits into from Mar 9, 2023

Conversation

wrdhub
Copy link
Contributor

@wrdhub wrdhub commented Mar 6, 2023

No description provided.

const viewModelObject = object<MailViewerViewModel>()
// @ts-ignore
viewModelObject.mail = mail
//when(viewModelObject.isCollapsed()).thenReturn(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dangling comment

}

function makeMailModel(mailBoxDetail: MailboxDetail): MailModel {
return downcast({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest replacing downcast with as Partial<MailModel> as MailModel

}

async function makeViewModel(pMail: Mail): Promise<void> {
let factory = await viewModelFactory()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let -> const

redraw = async () => {
// defer to the end of the event loop so that viewModel has correct loading state
await delay(1)
console.log("redraw", "finished", viewModel.isFinished(), "offline", viewModel.isConnectionLost())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would avoid logging, it's spammy

)
})

o("only one mail is shown when conversation view option is turned off", async function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rewrite most cases like "when the option is off it only shows selected mail", so like "when … then". At least I think we are trying to do it this way these days?


when(
mailModel.getMailboxDetailsForMail(
matchers.argThat(function (mail) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this matcher do anything? did you want to use anything() instead?

)

const numMailsDisplayed = viewModel.conversationItems().filter((i) => i.type === "mail").length
o(numMailsDisplayed).equals(conversation.length)(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if just the number is enough, it might be that a wrong email is removed

@charlag charlag added this pull request to the merge queue Mar 9, 2023
Merged via the queue into master with commit 8e7031f Mar 9, 2023
@charlag charlag deleted the conversation-view-tests branch March 9, 2023 10:56
@charlag charlag added this to the v3.110.1 milestone Mar 9, 2023
@charlag charlag added the state:not-testable "tested" for blind fixes or old code removal with no expected regressions label Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:not-testable "tested" for blind fixes or old code removal with no expected regressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants