Connecting features #1
@@ -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();
|
||||
})
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
10
src/features/posts/postsSlice.js
Normal file
10
src/features/posts/postsSlice.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
export const postsSlice = createSlice({
|
||||
name: 'posts',
|
||||
initialState: {},
|
||||
reducers: {},
|
||||
extraReducers: {},
|
||||
});
|
||||
|
||||
export default postsSlice.reducer;
|
||||
@@ -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;
|
||||
0
src/features/reddit/redditSlice.test.js
Normal file
0
src/features/reddit/redditSlice.test.js
Normal file
Reference in New Issue
Block a user