Added tests to reducers/soapbox
This commit is contained in:
parent
5ea13bdd64
commit
f205ff5334
|
@ -0,0 +1,55 @@
|
||||||
|
{
|
||||||
|
"configs": [
|
||||||
|
{
|
||||||
|
"group": ":pleroma",
|
||||||
|
"key": ":frontend_configurations",
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"tuple": [
|
||||||
|
":soapbox_fe",
|
||||||
|
{
|
||||||
|
"logo": "blob:http://localhost:3036/0cdfa863-6889-4199-b870-4942cedd364f",
|
||||||
|
"banner": "blob:http://localhost:3036/a835afed-6078-45bd-92b4-7ffd858c3eca",
|
||||||
|
"brandColor": "#254f92",
|
||||||
|
"customCss": [
|
||||||
|
"/instance/static/custom.css"
|
||||||
|
],
|
||||||
|
"promoPanel": {
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"icon": "globe",
|
||||||
|
"text": "blog",
|
||||||
|
"url": "https://teci.world/blog"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"icon": "globe",
|
||||||
|
"text": "book",
|
||||||
|
"url": "https://teci.world/book"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"extensions": {
|
||||||
|
"patron": false
|
||||||
|
},
|
||||||
|
"defaultSettings": {
|
||||||
|
"autoPlayGif": false
|
||||||
|
},
|
||||||
|
"navlinks": {
|
||||||
|
"homeFooter": [
|
||||||
|
{
|
||||||
|
"title": "about",
|
||||||
|
"url": "/instance/about/index.html"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "tos",
|
||||||
|
"url": "/instance/about/tos.html"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
"logo": "blob:http://localhost:3036/0cdfa863-6889-4199-b870-4942cedd364f",
|
||||||
|
"banner": "blob:http://localhost:3036/a835afed-6078-45bd-92b4-7ffd858c3eca",
|
||||||
|
"brandColor": "#254f92",
|
||||||
|
"customCss": [
|
||||||
|
"/instance/static/custom.css"
|
||||||
|
],
|
||||||
|
"promoPanel": {
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"icon": "globe",
|
||||||
|
"text": "blog",
|
||||||
|
"url": "https://teci.world/blog"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"icon": "globe",
|
||||||
|
"text": "book",
|
||||||
|
"url": "https://teci.world/book"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"extensions": {
|
||||||
|
"patron": false
|
||||||
|
},
|
||||||
|
"defaultSettings": {
|
||||||
|
"autoPlayGif": false
|
||||||
|
},
|
||||||
|
"navlinks": {
|
||||||
|
"homeFooter": [
|
||||||
|
{
|
||||||
|
"title": "about",
|
||||||
|
"url": "/instance/about/index.html"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "tos",
|
||||||
|
"url": "/instance/about/tos.html"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,32 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import { acctFull } from 'soapbox/utils/accounts';
|
|
||||||
import StillImage from 'soapbox/components/still_image';
|
|
||||||
|
|
||||||
const BrandingPreview = ({ account }) => (
|
|
||||||
<div className='card h-card'>
|
|
||||||
<a target='_blank' rel='noopener' href={account.get('url')}>
|
|
||||||
<div className='card__img'>
|
|
||||||
<StillImage alt='' src={account.get('header')} />
|
|
||||||
</div>
|
|
||||||
<div className='card__bar'>
|
|
||||||
<div className='avatar'>
|
|
||||||
<StillImage alt='' className='u-photo' src={account.get('avatar')} width='48' height='48' />
|
|
||||||
</div>
|
|
||||||
<div className='display-name'>
|
|
||||||
<span style={{ display: 'none' }}>{account.get('username')}</span>
|
|
||||||
<bdi>
|
|
||||||
<strong className='emojify p-name'>{account.get('display_name')}</strong>
|
|
||||||
</bdi>
|
|
||||||
<span>{acctFull(account)}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
BrandingPreview.propTypes = {
|
|
||||||
account: ImmutablePropTypes.map,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default BrandingPreview;
|
|
|
@ -160,6 +160,8 @@ class ConfigSoapbox extends ImmutablePureComponent {
|
||||||
this.state.customCssItems.forEach((f) =>
|
this.state.customCssItems.forEach((f) =>
|
||||||
obj.configs[0].value[0].tuple[1].customCss.push(f)
|
obj.configs[0].value[0].tuple[1].customCss.push(f)
|
||||||
);
|
);
|
||||||
|
console.log(JSON.stringify(obj, null, 2));
|
||||||
|
console.log(JSON.stringify(obj.configs[0].value[0].tuple[1], null, 2));
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,44 @@
|
||||||
import reducer from '../soapbox';
|
import reducer from '../soapbox';
|
||||||
import { Map as ImmutableMap } from 'immutable';
|
import { Map as ImmutableMap } from 'immutable';
|
||||||
|
import * as actions from 'soapbox/actions/soapbox';
|
||||||
|
import soapbox from 'soapbox/__fixtures__/soapbox.json';
|
||||||
|
import frontend_config from 'soapbox/__fixtures__/admin_api_frontend_config.json';
|
||||||
|
|
||||||
describe('soapbox reducer', () => {
|
describe('soapbox reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual(ImmutableMap());
|
expect(reducer(undefined, {})).toEqual(ImmutableMap());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle SOAPBOX_CONFIG_REQUEST_SUCCESS', () => {
|
||||||
|
const state = ImmutableMap({ brandColor: '#354e91' });
|
||||||
|
const action = {
|
||||||
|
type: actions.SOAPBOX_CONFIG_REQUEST_SUCCESS,
|
||||||
|
soapboxConfig: frontend_config,
|
||||||
|
};
|
||||||
|
expect(reducer(state, action).toJS()).toMatchObject({
|
||||||
|
brandColor: '#254f92',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle SOAPBOX_CONFIG_REQUEST_FAIL', () => {
|
||||||
|
const state = ImmutableMap({ skipAlert: false });
|
||||||
|
const action = {
|
||||||
|
type: actions.SOAPBOX_CONFIG_REQUEST_FAIL,
|
||||||
|
};
|
||||||
|
expect(reducer(state, action).toJS()).toMatchObject({
|
||||||
|
skipAlert: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle SOAPBOX_POST_SUCCESS', () => {
|
||||||
|
const state = ImmutableMap({ brandColor: '#354e91' });
|
||||||
|
const action = {
|
||||||
|
type: actions.SOAPBOX_POST_SUCCESS,
|
||||||
|
brandColor: soapbox.get('brandColor'),
|
||||||
|
};
|
||||||
|
expect(reducer(state, action).toJS()).toMatchObject({
|
||||||
|
brandColor: '#254f92',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue