mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-21 22:54:11 +08:00
Summary: Adds a resizable column next to the calendar that lets you pick which calendars you want to turn on and off. The picker sidebar styling mimics that of the main account sidebar. Calendars are grouped by account. We store the disabled calendars in in your config. I added a `notIn` SQL method so it'll perform `WHERE calendarId NOT IN ['a', 'b', ...]` instead of `NOT (WHERE calendarId IN ['a', 'b', 'c'])` I wanted it to be an exclusion (instead of inclusion) list so the default was "all on" and we didn't need to always fetch the full list of calendarIds from the database to compare against. This also fixed a test that was failing constantly: The Query Subscription Pool Spec was not being properly reset on each test. As a result, the test would fail with an instance of a query subscription that Jasmine would attempt to pretty print. Jasmine would fail to pretty print it because of a jasmine bug that fails to properly display Objects with null prototypes. The DatabaseStore's EventEmitter has a property with a null prototyp causing the error Test Plan: manual Reviewers: bengotow, juan Reviewed By: juan Differential Revision: https://phab.nylas.com/D3336
51 lines
2.1 KiB
CoffeeScript
51 lines
2.1 KiB
CoffeeScript
QuerySubscriptionPool = require('../../src/flux/models/query-subscription-pool').default
|
|
DatabaseStore = require('../../src/flux/stores/database-store').default
|
|
Label = require '../../src/flux/models/label'
|
|
|
|
describe "QuerySubscriptionPool", ->
|
|
beforeEach ->
|
|
@query = DatabaseStore.findAll(Label)
|
|
@queryKey = @query.sql()
|
|
QuerySubscriptionPool._subscriptions = {}
|
|
QuerySubscriptionPool._cleanupChecks = []
|
|
|
|
describe "add", ->
|
|
it "should add a new subscription with the callback", ->
|
|
callback = jasmine.createSpy('callback')
|
|
QuerySubscriptionPool.add(@query, callback)
|
|
expect(QuerySubscriptionPool._subscriptions[@queryKey]).toBeDefined()
|
|
|
|
subscription = QuerySubscriptionPool._subscriptions[@queryKey]
|
|
expect(subscription.hasCallback(callback)).toBe(true)
|
|
|
|
it "should yield database changes to the subscription", ->
|
|
callback = jasmine.createSpy('callback')
|
|
QuerySubscriptionPool.add(@query, callback)
|
|
subscription = QuerySubscriptionPool._subscriptions[@queryKey]
|
|
spyOn(subscription, 'applyChangeRecord')
|
|
|
|
record = {objectType: 'whateves'}
|
|
QuerySubscriptionPool._onChange(record)
|
|
expect(subscription.applyChangeRecord).toHaveBeenCalledWith(record)
|
|
|
|
describe "unsubscribe", ->
|
|
it "should return an unsubscribe method", ->
|
|
expect(QuerySubscriptionPool.add(@query, -> ) instanceof Function).toBe(true)
|
|
|
|
it "should remove the callback from the subscription", ->
|
|
cb = ->
|
|
|
|
unsub = QuerySubscriptionPool.add(@query, cb)
|
|
subscription = QuerySubscriptionPool._subscriptions[@queryKey]
|
|
|
|
expect(subscription.hasCallback(cb)).toBe(true)
|
|
unsub()
|
|
expect(subscription.hasCallback(cb)).toBe(false)
|
|
|
|
it "should wait before removing th subscription to make sure it's not reused", ->
|
|
unsub = QuerySubscriptionPool.add(@query, -> )
|
|
expect(QuerySubscriptionPool._subscriptions[@queryKey]).toBeDefined()
|
|
unsub()
|
|
expect(QuerySubscriptionPool._subscriptions[@queryKey]).toBeDefined()
|
|
advanceClock()
|
|
expect(QuerySubscriptionPool._subscriptions[@queryKey]).toBeUndefined()
|