mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Fix linting issues
This commit is contained in:
parent
5a5d62fa27
commit
72fd3b949e
2
admin/client/dist/js/bundle.js
vendored
2
admin/client/dist/js/bundle.js
vendored
@ -2137,7 +2137,7 @@ function t(e){r(this,t)
|
||||
var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))
|
||||
return n.handleChange=n.handleChange.bind(n),n}return a(t,e),s(t,[{key:"handleChange",value:function n(e){"function"==typeof this.props.onChange?this.props.onChange(e,{id:this.props.id,value:e.target.checked?1:0
|
||||
}):"function"==typeof this.props.onClick&&this.props.onClick(e,{id:this.props.id,value:e.target.checked?1:0})}},{key:"getInputProps",value:function i(){return{id:this.props.id,name:this.props.name,disabled:this.props.disabled,
|
||||
readOnly:this.props.readOnly,className:this.props.className+" "+this.props.extraClass,onChange:this.handleChange,checked:!!this.props.value,value:1}}},{key:"render",value:function l(){var e=null!==this.props.leftTitle?this.props.leftTitle:this.props.title,t=void 0
|
||||
readOnly:this.props.readOnly,className:this.props.className+" "+this.props.extraClass,onChange:this.handleChange,checked:!!this.props.value,value:1}}},{key:"render",value:function l(){var e=null!==this.props.leftTitle?this.props.leftTitle:this.props.title,t=null
|
||||
|
||||
|
||||
switch(this.props.type){case"checkbox":t=h.Checkbox
|
||||
|
@ -5,7 +5,7 @@ jest.unmock('react-addons-test-utils');
|
||||
jest.unmock('../CheckboxSetField');
|
||||
|
||||
import React from 'react';
|
||||
import ReactTestUtils from'react-addons-test-utils';
|
||||
import ReactTestUtils from 'react-addons-test-utils';
|
||||
// get non-default because it uses FieldHolder by default
|
||||
import { CheckboxSetField } from '../CheckboxSetField';
|
||||
|
||||
@ -68,7 +68,7 @@ describe('CheckboxSetField', () => {
|
||||
});
|
||||
|
||||
it('should generate a key for field', () => {
|
||||
const key = checkboxSetField.getItemKey({value: 'two'});
|
||||
const key = checkboxSetField.getItemKey({ value: 'two' });
|
||||
|
||||
expect(key).toEqual('checkbox-two');
|
||||
});
|
||||
@ -87,7 +87,7 @@ describe('CheckboxSetField', () => {
|
||||
it('should add the selected value', () => {
|
||||
const event = new Event('click');
|
||||
|
||||
checkboxSetField.handleChange(event, {id: 'checkbox-two', value: 1});
|
||||
checkboxSetField.handleChange(event, { id: 'checkbox-two', value: 1 });
|
||||
|
||||
expect(checkboxSetField.props.onChange).toBeCalledWith(
|
||||
event,
|
||||
@ -98,7 +98,7 @@ describe('CheckboxSetField', () => {
|
||||
it('should remove the unselected value', () => {
|
||||
const event = new Event('click');
|
||||
|
||||
checkboxSetField.handleChange(event, {id: 'checkbox-one', value: 0});
|
||||
checkboxSetField.handleChange(event, { id: 'checkbox-one', value: 0 });
|
||||
|
||||
expect(checkboxSetField.props.onChange).toBeCalledWith(
|
||||
event,
|
||||
|
@ -14,9 +14,8 @@ class CompositeField extends SilverStripeComponent {
|
||||
'legend',
|
||||
this.props.data.legend
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -17,11 +17,11 @@ class LookupField extends SilverStripeComponent {
|
||||
* @returns {string} csv
|
||||
*/
|
||||
getValueCSV() {
|
||||
let values = this.props.value;
|
||||
const values = this.props.value;
|
||||
|
||||
if (!Array.isArray(values) &&
|
||||
(values || typeof values === 'string' || typeof values === 'number')) {
|
||||
const item = this.props.source.find((item) => item.value === values);
|
||||
const item = this.props.source.find((next) => next.value === values);
|
||||
if (item) {
|
||||
return item.title;
|
||||
}
|
||||
@ -33,7 +33,7 @@ class LookupField extends SilverStripeComponent {
|
||||
}
|
||||
return values
|
||||
.map((value) => {
|
||||
const item = this.props.source.find((item) => item.value === value);
|
||||
const item = this.props.source.find((next) => next.value === value);
|
||||
return item && item.title;
|
||||
})
|
||||
.filter((value) => `${value}`.length)
|
||||
@ -46,7 +46,6 @@ class LookupField extends SilverStripeComponent {
|
||||
* @returns {object} properties
|
||||
*/
|
||||
getFieldProps() {
|
||||
|
||||
return {
|
||||
id: this.props.id,
|
||||
name: this.props.name,
|
||||
|
@ -55,7 +55,7 @@ class OptionField extends SilverStripeComponent {
|
||||
: this.props.title;
|
||||
|
||||
// default and fallback to a Radio button
|
||||
let Option;
|
||||
let Option = null;
|
||||
|
||||
switch (this.props.type) {
|
||||
case 'checkbox':
|
||||
|
@ -34,7 +34,7 @@ describe('OptionsetField', () => {
|
||||
|
||||
describe('getItemKey()', () => {
|
||||
it('should generate a key for field', () => {
|
||||
const key = setField.getItemKey({value: 'two'});
|
||||
const key = setField.getItemKey({ value: 'two' });
|
||||
|
||||
expect(key).toEqual('set-two');
|
||||
});
|
||||
@ -44,7 +44,7 @@ describe('OptionsetField', () => {
|
||||
it('should set the selected value', () => {
|
||||
const event = new Event('click');
|
||||
|
||||
setField.handleChange(event, {id: 'set-one', value: 1});
|
||||
setField.handleChange(event, { id: 'set-one', value: 1 });
|
||||
|
||||
expect(setField.props.onChange).toBeCalledWith(
|
||||
event,
|
||||
|
@ -151,7 +151,9 @@ class CampaignAdminList extends SilverStripeComponent {
|
||||
|
||||
return (
|
||||
<div className="fill-width campaigns">
|
||||
<div className="fill-height campaign-items cms-content__left cms-campaigns" aria-expanded="true">
|
||||
<div className="fill-height campaign-items cms-content__left cms-campaigns"
|
||||
aria-expanded="true"
|
||||
>
|
||||
<Toolbar showBackButton handleBackButtonClick={this.props.handleBackButtonClick}>
|
||||
<BreadcrumbComponent multiline crumbs={this.props.breadcrumbs} />
|
||||
</Toolbar>
|
||||
|
@ -8,6 +8,15 @@ jest.unmock('merge');
|
||||
|
||||
import backend from '../Backend';
|
||||
|
||||
/**
|
||||
* Return a mock function that returns a promise
|
||||
*/
|
||||
function getMockPromise(data) {
|
||||
const mock = jest.genMockFunction();
|
||||
mock.mockImplementation(() => Promise.resolve(data));
|
||||
return mock;
|
||||
}
|
||||
|
||||
// Mock out the get/post/put/delete methods in the backend
|
||||
// So that we can isolate our test to the behaviour of createEndpointFetcher()
|
||||
// The mocked getters will pass returnValue to the resulting promise's then() call
|
||||
@ -20,15 +29,6 @@ function getBackendMock(returnValue) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a mock function that returns a promise
|
||||
*/
|
||||
function getMockPromise(data) {
|
||||
const mock = jest.genMockFunction();
|
||||
mock.mockImplementation(() => Promise.resolve(data));
|
||||
return mock;
|
||||
}
|
||||
|
||||
describe('Backend', () => {
|
||||
beforeEach(() => {
|
||||
backend.fetch = getMockPromise({
|
||||
@ -151,13 +151,10 @@ describe('Backend', () => {
|
||||
const promise = endpoint({ id: 1, values: { a: 'aye', b: 'bee' } });
|
||||
|
||||
expect(mock.get)
|
||||
.toBeCalledWith(
|
||||
'http://example.org?id=1&values%5Ba%5D=aye&values%5Bb%5D=bee',
|
||||
{
|
||||
.toBeCalledWith('http://example.org?id=1&values%5Ba%5D=aye&values%5Bb%5D=bee', {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
return promise
|
||||
.catch((e) => expect(e).toBeFalsy())
|
||||
@ -177,8 +174,7 @@ describe('Backend', () => {
|
||||
expect(mock.post)
|
||||
.toBeCalledWith(
|
||||
'http://example.org',
|
||||
'{"id":1,"values":{"a":"aye","b":"bee"}}',
|
||||
{
|
||||
'{"id":1,"values":{"a":"aye","b":"bee"}}', {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
@ -207,8 +203,7 @@ describe('Backend', () => {
|
||||
expect(mock.post)
|
||||
.toBeCalledWith(
|
||||
'http://example.com/1/2/?foo=bar',
|
||||
'two=2&three=3',
|
||||
{
|
||||
'two=2&three=3', {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
}
|
||||
@ -239,8 +234,7 @@ describe('Backend', () => {
|
||||
expect(mock.post)
|
||||
.toBeCalledWith(
|
||||
'http://example.com/1/2/?foo=bar&three=3',
|
||||
'{"two":2}',
|
||||
{
|
||||
'{"two":2}', {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
@ -268,13 +262,10 @@ describe('Backend', () => {
|
||||
});
|
||||
|
||||
expect(mock.get)
|
||||
.toBeCalledWith(
|
||||
'http://example.com/1/2/?foo=bar&two=2&three=3',
|
||||
{
|
||||
.toBeCalledWith('http://example.com/1/2/?foo=bar&two=2&three=3', {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
return promise
|
||||
.catch((e) => expect(e).toBeFalsy())
|
||||
@ -302,8 +293,7 @@ describe('Backend', () => {
|
||||
two: 'updated',
|
||||
four: { fourOne: true, fourTwo: true },
|
||||
three: 3,
|
||||
}),
|
||||
{
|
||||
}), {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
|
@ -4,46 +4,25 @@ jest.unmock('react');
|
||||
jest.unmock('react-addons-test-utils');
|
||||
jest.unmock('../castStringToElement');
|
||||
|
||||
import React from 'react';
|
||||
import castStringToElement from '../castStringToElement';
|
||||
import CompositeField from 'components/CompositeField/CompositeField';
|
||||
|
||||
describe('castStringToElement', () => {
|
||||
let props = null;
|
||||
|
||||
beforeEach(() => {
|
||||
props = {
|
||||
id: '',
|
||||
title: '',
|
||||
name: '',
|
||||
};
|
||||
});
|
||||
|
||||
it('should render a simple div with string', () => {
|
||||
const Element = castStringToElement(
|
||||
'div',
|
||||
'My div',
|
||||
);
|
||||
|
||||
const Element = castStringToElement('div', 'My div');
|
||||
expect(Element.type).toEqual('div');
|
||||
expect(Element.props.children).toEqual('My div');
|
||||
});
|
||||
|
||||
it('should render a simple div with string given an object', () => {
|
||||
const Element = castStringToElement(
|
||||
'div',
|
||||
{ text: 'My div in an object' },
|
||||
);
|
||||
const Element = castStringToElement('div', { text: 'My div in an object' });
|
||||
|
||||
expect(Element.type).toEqual('div');
|
||||
expect(Element.props.children).toEqual('My div in an object');
|
||||
});
|
||||
|
||||
it('should render a CompositeField with string', () => {
|
||||
const Element = castStringToElement(
|
||||
CompositeField,
|
||||
'My string content',
|
||||
);
|
||||
const Element = castStringToElement(CompositeField, 'My string content');
|
||||
|
||||
expect(Element.type.name).toEqual('CompositeField');
|
||||
expect(Element.props.children).toEqual('My string content');
|
||||
@ -52,7 +31,7 @@ describe('castStringToElement', () => {
|
||||
it('should render a CompositeField with setInnerHtml given an object', () => {
|
||||
const Element = castStringToElement(
|
||||
CompositeField,
|
||||
{ html: '<div>My div content in something</div>' },
|
||||
{ html: '<div>My div content in something</div>' }
|
||||
);
|
||||
|
||||
expect(Element.type.name).toEqual('CompositeField');
|
||||
|
@ -140,13 +140,16 @@
|
||||
// Reference https://css-tricks.com/boxes-fill-height-dont-squish/
|
||||
// Reference http://codepen.io/clarkepaul/pen/qaNWAY
|
||||
|
||||
*, *:before, *:after {
|
||||
*,
|
||||
*:before,
|
||||
*:after {
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html, body {
|
||||
html,
|
||||
body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user