2017-09-27 02:42:18 +08:00
|
|
|
import { Folder, Actions } from 'mailspring-exports';
|
2017-09-27 02:33:08 +08:00
|
|
|
import SidebarItem from '../lib/sidebar-item';
|
2016-06-16 07:46:34 +08:00
|
|
|
|
2017-09-27 02:33:08 +08:00
|
|
|
describe('sidebar-item', function sidebarItemSpec() {
|
|
|
|
it('preserves nested labels on rename', () => {
|
|
|
|
spyOn(Actions, 'queueTask');
|
|
|
|
const categories = [new Folder({ path: 'a.b/c', accountId: window.TEST_ACCOUNT_ID })];
|
2017-09-27 02:36:58 +08:00
|
|
|
AppEnv.savedState.sidebarKeysCollapsed = {};
|
2017-09-27 02:33:08 +08:00
|
|
|
const item = SidebarItem.forCategories(categories);
|
|
|
|
item.onEdited(item, 'd');
|
2017-08-26 12:25:49 +08:00
|
|
|
|
2017-09-27 02:33:08 +08:00
|
|
|
const task = Actions.queueTask.calls[0].args[0];
|
|
|
|
const { existingPath, path } = task;
|
|
|
|
expect(existingPath).toBe('a.b/c');
|
|
|
|
expect(path).toBe('a.b/d');
|
|
|
|
});
|
|
|
|
it('preserves labels on rename', () => {
|
|
|
|
spyOn(Actions, 'queueTask');
|
|
|
|
const categories = [new Folder({ path: 'a', accountId: window.TEST_ACCOUNT_ID })];
|
2017-09-27 02:36:58 +08:00
|
|
|
AppEnv.savedState.sidebarKeysCollapsed = {};
|
2017-09-27 02:33:08 +08:00
|
|
|
const item = SidebarItem.forCategories(categories);
|
|
|
|
item.onEdited(item, 'b');
|
2017-08-26 12:25:49 +08:00
|
|
|
|
2017-09-27 02:33:08 +08:00
|
|
|
const task = Actions.queueTask.calls[0].args[0];
|
|
|
|
const { existingPath, path } = task;
|
|
|
|
expect(existingPath).toBe('a');
|
|
|
|
expect(path).toBe('b');
|
|
|
|
});
|
|
|
|
});
|