semantic update
This commit is contained in:
@@ -21,13 +21,14 @@ describe('SidebarStore', () => {
|
||||
describe('initial state', () => {
|
||||
it('should have default values when no localStorage', () => {
|
||||
const state = get(sidebarStore);
|
||||
|
||||
|
||||
expect(state.isExpanded).toBe(true);
|
||||
expect(state.activeCategory).toBe('dashboards');
|
||||
expect(state.activeItem).toBe('/dashboards');
|
||||
expect(state.isMobileOpen).toBe(false);
|
||||
});
|
||||
});
|
||||
// [/DEF:test_sidebar_initial_state:Function]
|
||||
|
||||
// [DEF:test_toggleSidebar:Function]
|
||||
// @TEST: toggleSidebar toggles isExpanded state
|
||||
@@ -37,9 +38,9 @@ describe('SidebarStore', () => {
|
||||
it('should toggle isExpanded from true to false', () => {
|
||||
const initialState = get(sidebarStore);
|
||||
expect(initialState.isExpanded).toBe(true);
|
||||
|
||||
|
||||
toggleSidebar();
|
||||
|
||||
|
||||
const newState = get(sidebarStore);
|
||||
expect(newState.isExpanded).toBe(false);
|
||||
});
|
||||
@@ -47,11 +48,12 @@ describe('SidebarStore', () => {
|
||||
it('should toggle isExpanded from false to true', () => {
|
||||
toggleSidebar(); // Now false
|
||||
toggleSidebar(); // Should be true again
|
||||
|
||||
|
||||
const state = get(sidebarStore);
|
||||
expect(state.isExpanded).toBe(true);
|
||||
});
|
||||
});
|
||||
// [/DEF:test_toggleSidebar:Function]
|
||||
|
||||
// [DEF:test_setActiveItem:Function]
|
||||
// @TEST: setActiveItem updates activeCategory and activeItem
|
||||
@@ -60,7 +62,7 @@ describe('SidebarStore', () => {
|
||||
describe('setActiveItem', () => {
|
||||
it('should update activeCategory and activeItem', () => {
|
||||
setActiveItem('datasets', '/datasets');
|
||||
|
||||
|
||||
const state = get(sidebarStore);
|
||||
expect(state.activeCategory).toBe('datasets');
|
||||
expect(state.activeItem).toBe('/datasets');
|
||||
@@ -68,12 +70,13 @@ describe('SidebarStore', () => {
|
||||
|
||||
it('should update to admin category', () => {
|
||||
setActiveItem('admin', '/settings');
|
||||
|
||||
|
||||
const state = get(sidebarStore);
|
||||
expect(state.activeCategory).toBe('admin');
|
||||
expect(state.activeItem).toBe('/settings');
|
||||
});
|
||||
});
|
||||
// [/DEF:test_setActiveItem:Function]
|
||||
|
||||
// [DEF:test_mobile_functions:Function]
|
||||
// @TEST: Mobile functions correctly update isMobileOpen
|
||||
@@ -82,7 +85,7 @@ describe('SidebarStore', () => {
|
||||
describe('mobile functions', () => {
|
||||
it('should set isMobileOpen to true with setMobileOpen', () => {
|
||||
setMobileOpen(true);
|
||||
|
||||
|
||||
const state = get(sidebarStore);
|
||||
expect(state.isMobileOpen).toBe(true);
|
||||
});
|
||||
@@ -90,7 +93,7 @@ describe('SidebarStore', () => {
|
||||
it('should set isMobileOpen to false with closeMobile', () => {
|
||||
setMobileOpen(true);
|
||||
closeMobile();
|
||||
|
||||
|
||||
const state = get(sidebarStore);
|
||||
expect(state.isMobileOpen).toBe(false);
|
||||
});
|
||||
@@ -98,18 +101,19 @@ describe('SidebarStore', () => {
|
||||
it('should toggle isMobileOpen with toggleMobileSidebar', () => {
|
||||
const initialState = get(sidebarStore);
|
||||
const initialMobileOpen = initialState.isMobileOpen;
|
||||
|
||||
|
||||
toggleMobileSidebar();
|
||||
|
||||
|
||||
const state1 = get(sidebarStore);
|
||||
expect(state1.isMobileOpen).toBe(!initialMobileOpen);
|
||||
|
||||
|
||||
toggleMobileSidebar();
|
||||
|
||||
|
||||
const state2 = get(sidebarStore);
|
||||
expect(state2.isMobileOpen).toBe(initialMobileOpen);
|
||||
});
|
||||
});
|
||||
// [/DEF:test_mobile_functions:Function]
|
||||
});
|
||||
|
||||
// [/DEF:frontend.src.lib.stores.__tests__.sidebar:Module]
|
||||
|
||||
Reference in New Issue
Block a user