Add expect().nothing() to reducer tests without expectations, who only exist to check if an error is thrown

This commit is contained in:
Alexandre Vryghem
2023-07-01 17:42:22 +02:00
parent b4a3882dcf
commit c1875cade3
7 changed files with 80 additions and 0 deletions

View File

@@ -126,6 +126,10 @@ describe('objectCacheReducer', () => {
deepFreeze(state);
objectCacheReducer(state, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should remove the specified object from the cache in response to the REMOVE action', () => {
@@ -149,6 +153,10 @@ describe('objectCacheReducer', () => {
const action = new RemoveFromObjectCacheAction(selfLink1);
// testState has already been frozen above
objectCacheReducer(testState, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should set the timestamp of all objects in the cache in response to a RESET_TIMESTAMPS action', () => {
@@ -164,6 +172,10 @@ describe('objectCacheReducer', () => {
const action = new ResetObjectCacheTimestampsAction(new Date().getTime());
// testState has already been frozen above
objectCacheReducer(testState, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should perform the ADD_PATCH action without affecting the previous state', () => {
@@ -174,6 +186,10 @@ describe('objectCacheReducer', () => {
}]);
// testState has already been frozen above
objectCacheReducer(testState, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should when the ADD_PATCH action dispatched', () => {

View File

@@ -52,12 +52,20 @@ describe('serverSyncBufferReducer', () => {
const action = new AddToSSBAction(selfLink1, RestRequestMethod.POST);
// testState has already been frozen above
serverSyncBufferReducer(testState, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should perform the EMPTY action without affecting the previous state', () => {
const action = new EmptySSBAction();
// testState has already been frozen above
serverSyncBufferReducer(testState, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should empty the buffer if the EmptySSBAction is dispatched without a payload', () => {

View File

@@ -44,6 +44,10 @@ describe('hostWindowReducer', () => {
const action = new HostWindowResizeAction(1024, 768);
hostWindowReducer(state, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
});

View File

@@ -180,6 +180,7 @@ describe('menusReducer', () => {
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should set collapsed to false for the correct menu in response to the EXPAND_MENU action', () => {
@@ -201,6 +202,7 @@ describe('menusReducer', () => {
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should set collapsed to false for the correct menu in response to the TOGGLE_MENU action when collapsed is true', () => {
@@ -231,6 +233,7 @@ describe('menusReducer', () => {
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should set previewCollapsed to true for the correct menu in response to the COLLAPSE_MENU_PREVIEW action', () => {
@@ -252,6 +255,7 @@ describe('menusReducer', () => {
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should set previewCollapsed to false for the correct menu in response to the EXPAND_MENU_PREVIEW action', () => {
@@ -273,6 +277,7 @@ describe('menusReducer', () => {
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should set visible to true for the correct menu in response to the SHOW_MENU action', () => {
@@ -294,6 +299,7 @@ describe('menusReducer', () => {
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should set previewCollapsed to false for the correct menu in response to the HIDE_MENU action', () => {
@@ -315,6 +321,7 @@ describe('menusReducer', () => {
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should set add a new section for the correct menu in response to the ADD_SECTION action', () => {
@@ -347,6 +354,7 @@ describe('menusReducer', () => {
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should remove a section for the correct menu in response to the REMOVE_SECTION action', () => {
@@ -383,6 +391,10 @@ describe('menusReducer', () => {
const action = new ActivateMenuSectionAction(menuID, topSectionID);
menusReducer(state, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should set active to false for the correct menu section in response to the DEACTIVATE_SECTION action', () => {
@@ -401,6 +413,10 @@ describe('menusReducer', () => {
const action = new DeactivateMenuSectionAction(menuID, topSectionID);
menusReducer(state, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should set active to false for the correct menu in response to the TOGGLE_ACTIVE_SECTION action when active is true', () => {
@@ -430,6 +446,7 @@ describe('menusReducer', () => {
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should set visible to true for the correct menu section in response to the SHOW_SECTION action', () => {
@@ -448,6 +465,10 @@ describe('menusReducer', () => {
const action = new ShowMenuSectionAction(menuID, topSectionID);
menusReducer(state, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should set visible to false for the correct menu section in response to the HIDE_SECTION action', () => {
@@ -466,5 +487,9 @@ describe('menusReducer', () => {
const action = new HideMenuSectionAction(menuID, topSectionID);
menusReducer(state, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
});

View File

@@ -60,6 +60,7 @@ describe('filterReducer', () => {
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should set filterCollapsed to false in response to the EXPAND action', () => {
@@ -78,6 +79,10 @@ describe('filterReducer', () => {
const action = new SearchFilterExpandAction(filterName1);
filterReducer(state, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should flip the value of filterCollapsed in response to the TOGGLE action', () => {
@@ -99,6 +104,10 @@ describe('filterReducer', () => {
const action = new SearchFilterToggleAction(filterName1);
filterReducer(state, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should set filterCollapsed to true in response to the INITIALIZE action with isOpenByDefault to false when no state has been set for this filter', () => {

View File

@@ -47,6 +47,7 @@ describe('sidebarReducer', () => {
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should set sidebarCollapsed to false in response to the EXPAND action', () => {
@@ -63,6 +64,10 @@ describe('sidebarReducer', () => {
const action = new SidebarExpandAction();
sidebarReducer(state, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should flip the value of sidebarCollapsed in response to the TOGGLE action', () => {
@@ -82,6 +87,10 @@ describe('sidebarReducer', () => {
const action = new SidebarToggleAction();
sidebarReducer(state, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
});

View File

@@ -53,6 +53,7 @@ describe('truncatableReducer', () => {
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should set filterCollapsed to false in response to the EXPAND action', () => {
@@ -71,6 +72,10 @@ describe('truncatableReducer', () => {
const action = new TruncatableExpandAction(id1);
truncatableReducer(state, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
it('should flip the value of filterCollapsed in response to the TOGGLE action', () => {
@@ -92,5 +97,9 @@ describe('truncatableReducer', () => {
const action = new TruncatableToggleAction(id2);
truncatableReducer(state, action);
// no expect required, deepFreeze will ensure an exception is thrown if the state
// is mutated, and any uncaught exception will cause the test to fail
expect().nothing();
});
});