mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-25 09:30:13 +08:00
37af2ba42c
Summary: - Separate gmail's remove-from-view and delete behaviors and write logic for each of those - Remove MailboxPerspective::{canArchiveThreads, canTrashThreads, removeThreads} and some unecessary code in TaskFactory - Instead, add MailboxPerspective::tasksForRemovingFromPerspective (I know its a bit of a mouthful) - I initially tried to put all of the logic for each execution path inside the TaskFactory by checking perspective types, but it made more sense to use the polymorphism already in place for the different perspective types. - There is a default delete/remove-from-view behavior which is configurable via simple ruleset objects. The gmail behavior is configured in this way. - Update swipe css classes based on destination of threads - Fixes #1460: - Update logic to display archive/trash buttons and context menu options correctly when selected threads can be archived/trashed (not based on perspective) - Same for swiping - Add a bunch of specs - Convert some code to ES6 - TODO write some docs for new functions Test Plan: Unit tests Reviewers: drew, evan, bengotow Reviewed By: bengotow Differential Revision: https://phab.nylas.com/D2682
62 lines
2.3 KiB
CoffeeScript
62 lines
2.3 KiB
CoffeeScript
{Category, Label} = require 'nylas-exports'
|
|
|
|
describe 'Category', ->
|
|
|
|
describe '.categoriesSharedName', ->
|
|
|
|
it 'returns the name if all the categories on the perspective have the same name', ->
|
|
expect(Category.categoriesSharedName([
|
|
new Category({name: 'c1', accountId: 'a1'}),
|
|
new Category({name: 'c1', accountId: 'a2'}),
|
|
])).toEqual('c1')
|
|
|
|
it 'returns null if there are no categories', ->
|
|
expect(Category.categoriesSharedName([])).toEqual(null)
|
|
|
|
it 'returns null if the categories have different names', ->
|
|
expect(Category.categoriesSharedName([
|
|
new Category({name: 'c1', accountId: 'a1'}),
|
|
new Category({name: 'c2', accountId: 'a2'}),
|
|
])).toEqual(null)
|
|
|
|
describe 'category types', ->
|
|
|
|
it 'assigns type correctly when it is a user category', ->
|
|
cat = new Label
|
|
cat.name = undefined
|
|
expect(cat.isUserCategory()).toBe true
|
|
expect(cat.isStandardCategory()).toBe false
|
|
expect(cat.isHiddenCategory()).toBe false
|
|
expect(cat.isLockedCategory()).toBe false
|
|
|
|
it 'assigns type correctly when it is a standard category', ->
|
|
cat = new Label
|
|
cat.name = 'inbox'
|
|
expect(cat.isUserCategory()).toBe false
|
|
expect(cat.isStandardCategory()).toBe true
|
|
expect(cat.isHiddenCategory()).toBe false
|
|
expect(cat.isLockedCategory()).toBe false
|
|
|
|
it 'assigns type for `important` category when should not show important', ->
|
|
cat = new Label
|
|
cat.name = 'important'
|
|
expect(cat.isUserCategory()).toBe false
|
|
expect(cat.isStandardCategory(false)).toBe false
|
|
expect(cat.isHiddenCategory()).toBe true
|
|
expect(cat.isLockedCategory()).toBe false
|
|
|
|
it 'assigns type correctly when it is a hidden category', ->
|
|
cat = new Label
|
|
cat.name = 'archive'
|
|
expect(cat.isUserCategory()).toBe false
|
|
expect(cat.isStandardCategory()).toBe true
|
|
expect(cat.isHiddenCategory()).toBe true
|
|
expect(cat.isLockedCategory()).toBe false
|
|
|
|
it 'assigns type correctly when it is a locked category', ->
|
|
cat = new Label
|
|
cat.name = 'sent'
|
|
expect(cat.isUserCategory()).toBe false
|
|
expect(cat.isStandardCategory()).toBe true
|
|
expect(cat.isHiddenCategory()).toBe true
|
|
expect(cat.isLockedCategory()).toBe true
|