Connecting features #1

Merged
innocuous-symmetry merged 5 commits from connecting-features into master 2022-01-27 17:04:47 +00:00
5 changed files with 94 additions and 3 deletions
Showing only changes of commit bdc0856608 - Show all commits

View File

@@ -4,12 +4,16 @@ import { Provider } from 'react-redux';
import { store } from './app/store';
import App from './App';
test('renders learn react link', () => {
test('renders text', () => {
const { getByText } = render(
<Provider store={store}>
<App />
</Provider>
);
expect(getByText(/learn/i)).toBeInTheDocument();
expect(getByText(/Stuff/)).toBeInTheDocument();
});
test('store is not empty or falsy', () => {
expect(store).not.toBeNull();
})

View File

@@ -1,7 +1,10 @@
import { configureStore } from '@reduxjs/toolkit';
import postsSlice from '../features/posts/postsSlice';
import redditSlice from '../features/reddit/redditSlice';
export const store = configureStore({
reducer: {
// reducers for app here
redditSlice: redditSlice,
postsSlice: postsSlice,
},
});

View File

@@ -0,0 +1,10 @@
import { createSlice } from "@reduxjs/toolkit";
export const postsSlice = createSlice({
name: 'posts',
initialState: {},
reducers: {},
extraReducers: {},
});
export default postsSlice.reducer;

View File

@@ -0,0 +1,74 @@
import { createSlice } from "@reduxjs/toolkit";
const urlBase = 'https://www.reddit.com/';
export const redditSlice = createSlice({
name: 'redditSlice',
initialState: {
subreddits: {
'r/cats': {
name: 'r/cats',
access: `${urlBase}r/cats.json`,
isSelected: true
},
'r/IllegallySmolCats': {
name: 'r/IllegallySmolCats',
access: `${urlBase}r/IllegallySmolCats.json`,
isSelected: true
},
'r/Catswhoyell': {
name: 'r/Catswhoyell',
access: `${urlBase}r/Catswhoyell.json`,
isSelected: true
},
'r/ActivationSound': {
name: 'r/ActivationSound',
access: `${urlBase}r/ActivationSound.json`,
isSelected: true,
},
'r/CatSlaps': {
name: 'r/CatSlaps',
access: `${urlBase}r/CatSlaps.json`,
isSelected: true
},
'r/CatTaps': {
name: 'r/CatTaps',
access: `${urlBase}r/CatTaps.json`,
isSelected: true
},
'r/catsinboxes': {
name: 'r/catsinboxes',
access: `${urlBase}r/catsinboxes.json`,
isSelected: true,
},
'r/Thisismylifemeow': {
name: 'r/Thisismylifemeow',
access: `${urlBase}r/Thisismylifemeow.json`,
isSelected: true
},
'r/scrungycats': {
name: 'r/scrungycats',
access: `${urlBase}r/scrungycats.json`,
isSelected: true,
},
'r/notmycat': {
name: 'r/notmycat',
access: `${urlBase}r/notmycat.json`,
isSelected: true,
},
'r/StartledCats': {
name: 'r/StartledCats',
access: `${urlBase}r/StartledCats.json`,
isSelected: true
}
},
},
reducers: {
updateSubVisibility(state,action) {
// reads state of buttons in Sidebar component to determine whether each is active
// connects with post rendering, filtering out posts belonging to inactive subreddits
}
}
});
export default redditSlice.reducer;

View File