Data.forEach((node, index) => { const initialProps = Data.at(index).props(); node.simulate("click"); expect(clickHandler.called).to.equal(true); // the first argument is the standard evt object expect(omit(clickHandler.args[index][1], ["events", "key"])) .to.eql(omit(initialProps, ["events", "key"])); expect(clickHandler.args[index][2]).to.eql(index); });
TransactionFlow.prototype._submitWithPayment = function( payment ) { var onComplete = this.push.bind( this, null ), // End the stream when the transaction has finished transaction = { cart: omit( this._initialData.cart, [ 'messages'] ), // messages contain reference to DOMNode domain_details: this._initialData.domainDetails, payment: payment }; this._pushStep( { name: transactionStepTypes.SUBMITTING_WPCOM_REQUEST } ); wpcom.transactions( 'POST', transaction, function( error, data ) { if ( error ) { return this._pushStep( { name: transactionStepTypes.RECEIVED_WPCOM_RESPONSE, error: error, last: true } ); } this._pushStep( { name: transactionStepTypes.RECEIVED_WPCOM_RESPONSE, data: data, last: true } ); onComplete(); }.bind( this ) ); };
.then((doc) => { expect(doc._rev).to.be.a('string'); expect(omit(doc, '_rev')).to.eql({ _id: 'insert-basic', foo: 'bar' }); return couchdb.getAsync('insert-basic') .then((doc) => expect(omit(doc, '_rev')).to.eql({ _id: 'insert-basic', foo: 'bar' })); })
reducers[SAVE_PACKAGE] = ( state, action ) => { const { settings_key, packageData, } = action; if ( packageData.box_weight ) { packageData.box_weight = Number.parseFloat( packageData.box_weight ); } if ( packageData.max_weight ) { packageData.max_weight = Number.parseFloat( packageData.max_weight ); } if ( packageData.hasOwnProperty( 'index' ) ) { const { index } = packageData; const item = omit( packageData, 'index' ); return reducers[UPDATE_SETTINGS_ARRAY_FIELD_ITEM]( state, { settings_key, index, item, } ); } return reducers[ADD_SETTINGS_ARRAY_FIELD_ITEM]( state, { settings_key, item: packageData, } ); };
submitForm: function( event ) { var site = this.props.site; if ( ! event.isDefaultPrevented() && event.nativeEvent ) { event.preventDefault(); } notices.clearNotices( 'notices' ); this.setState( { submittingForm: true } ); site.saveSettings( omit( this.state, 'dirtyFields' ), function( error ) { if ( error ) { // handle error case here switch ( error.error ) { case 'invalid_ip': notices.error( this.translate( 'One of your IP Addresses was invalid. Please, try again.' ) ); break; default: notices.error( this.translate( 'There was a problem saving your changes. Please, try again.' ) ); } this.setState( { submittingForm: false } ); } else { notices.success( this.translate( 'Settings saved!' ) ); this.markSaved(); //for dirtyFields, see lib/mixins/dirty-linked-state this.setState( { submittingForm: false, dirtyFields: [] } ); site.fetchSettings(); } }.bind( this ) ); this.recordEvent( 'Clicked Save Settings Button' ); }
function adaptSite( attributes ) { if ( ! attributes.state ) { attributes.state = State.COMPLETE; } attributes.has_featured = has( attributes, 'meta.links.featured' ); attributes = omit( attributes, [ 'meta', '_headers' ] ); if ( attributes.URL ) { attributes.domain = attributes.URL.replace( /^https?:\/\//, '' ); attributes.slug = attributes.domain.replace( /\//g, '::' ); } attributes.title = trim( attributes.name ) || attributes.domain; // If a WordPress.com site has a mapped domain create a `wpcom_url` // attribute to allow site selection with either domain. if ( attributes.options && attributes.options.is_mapped_domain && ! attributes.is_jetpack ) { attributes.wpcom_url = attributes.options.unmapped_url.replace( /^https?:\/\//, '' ); } // If a site has an `is_redirect` property use the `unmapped_url` // for the slug and domain to match the wordpress.com original site. if ( attributes.options && attributes.options.is_redirect ) { attributes.slug = attributes.options.unmapped_url.replace( /^https?:\/\//, '' ); attributes.domain = attributes.slug; } return attributes; }
function resolver (campaign) { const {platform, sub_status, status} = campaign const defaultStatus = { name: sub_status || status, is_active: false, platform, description: '???' } const foundStatus = find(statuses, {name: status, platform}) const foundSubStatus = find(statuses, {name: sub_status, platform}) let foundDescriptor if (foundStatus && !foundStatus.is_active) { foundDescriptor = foundStatus } else { foundDescriptor = foundSubStatus || foundStatus || defaultStatus } return assign(omit(campaign, 'status', 'sub_status'), { status: assign({}, foundDescriptor, { status, sub_status, icon: getStatusIcon(foundDescriptor) }) }) }
export default function lanes(state = initialState, action) { switch (action.type) { case CREATE_LANE: case UPDATE_LANE: return { ...state, [action.lane.id]: action.lane }; case EDIT_LANE: { const lane = { ...state[action.id], editing: true }; return { ...state, [action.id]: lane }; } case CREATE_LANES: return { ...action.lanes }; case DELETE_NOTE: { const newLane = { ...state[action.laneId] }; newLane.notes = newLane.notes.filter(noteId => noteId !== action.noteId); return { ...state, [action.laneId]: newLane }; } case CREATE_NOTE: { const newLane = { ...state[action.laneId] }; newLane.notes = newLane.notes.concat(action.note.id); return { ...state, [action.laneId]: newLane }; } case DELETE_LANE: { return omit(state, action.laneId); } default: return state; } }
export default store => next => action => { if (action.meta && action.meta.remote) { const serverName = action.meta.serverName; const isCache = action.meta.cache; let params = assign({server_name: serverName, action_name: camelcase(action.type)}, omit(action, ['meta', 'type'])); requestFromAction(action, params, isCache) .then(data => { let newAction = assign({ type: action.type + '_SUCCESS', response: JSON.parse(data), }, params) return next(newAction); }, e => { let newAction = { type: action.type + '_FAILURE', error: e.message } return next(newAction); }).catch( e => { let newAction = { type: action.type + '_FAILURE', error: e.message } return next(newAction); }) } return next(action); }
const mergeOptions = (collectionMeta) => collectionMeta.reduce((mergedOptions, meta, index) => { if (meta.options.limit && !meta.findOne) throw new Error('queries with limit can\'t be merged'); const options = omit(meta.options, ['limit']); if (!index) return options; if (!isEqual(mergedOptions.sort, meta.options.sort)) throw new Error('cant merge sort'); return mergedOptions; }, {});
export const updateURLParams = createThunkAction('updateURLParams', () => (dispatch, getState) => { const { explorePage, routing } = getState(); const { tab, datasets, coreDatasets, datasetFilters, map } = explorePage; const { location } = coreDatasets; const { filters } = datasetFilters; const { filterQuery, activeDatasets } = datasets; const activeDatasetsResult = activeDatasets && activeDatasets.length ? activeDatasets.map(({ id, opacity, visibility, zIndex }) => `${id}|${opacity}|${visibility}|${zIndex}`) : []; const filtersParams = {}; (Object.keys(filters) || []).forEach((key) => { Object.assign(filtersParams, { [key]: filters[key].join(',') }); }); const query = { ...omit(map, 'bbox'), tab, filterQuery, ...filtersParams, location, activeDatasets: activeDatasetsResult }; dispatch(replace({ pathname: routing.locationBeforeTransitions.pathname, query })); });
function settings( state = {}, action ) { switch ( action.type ) { case DESERIALIZE: { const newState = omit( state, UNPERSISTED_SETTINGS_NODES ); if ( isValidStateWithSchema( newState, settingsSchema ) ) { return newState; } debug( 'INVALID settings state during DESERIALIZE', newState ); return { enabled: false, }; } case SERIALIZE: { const newState = omit( state, UNPERSISTED_SETTINGS_NODES ); if ( isValidStateWithSchema( newState, settingsSchema ) ) { return newState; } debug( 'INVALID settings state during SERIALIZE', newState ); return { enabled: false }; } case PUSH_NOTIFICATIONS_TOGGLE_ENABLED: { return Object.assign( {}, state, { enabled: ! state.enabled } ); } case PUSH_NOTIFICATIONS_DISMISS_NOTICE: { return Object.assign( {}, state, { dismissedNotice: true, dismissedNoticeAt: ( new Date() ).getTime(), } ); } case PUSH_NOTIFICATIONS_TOGGLE_UNBLOCK_INSTRUCTIONS: { return Object.assign( {}, state, { showingUnblockInstructions: ! state.showingUnblockInstructions } ); } } return state; }
render () { return ( <Component {...omit(this.props, 'campaign')} {...this.props.campaign.details} level='campaign'/> ) }
return component((paint) => { paint( h('input', omit(props, 'value')), (el) => { createInputUpdater(el, document)(props.value) } ) })
getOptions () { const options = omit(this.props, 'lat', 'lng') options.center = new google.maps.LatLng(this.props.lat, this.props.lng) options.map = this.context.map return options }
const RadioButton = ( props ) => { return ( <FormLabel className={ classNames( 'suggestion', { 'is-selected': props.checked } ) }> <FormRadio { ...omit( props, 'children' ) } /> { props.children } </FormLabel> ); };
reducer.handleAction(ActionTypes.REPLACE, (state, action) => _omit({ ...state, [action.entity._id]: Object.assign({}, state[action.oldId], action.entity, { __isDirty: false, __isNew: false, __isLoaded: action.entity.__isLoaded }, getMetaReferenceAttributes(action.entity)) }, action.oldId))
render() { const { fields : { email, password, username } } = this.props; // ReduxFrom field props unknown to FormControl (causes warning since React 0.15.2) const unknownProps = [ 'initialValue', 'autofill', 'onUpdate', 'valid', 'invalid', 'dirty', 'pristine', 'active', 'touched', 'visited', 'autofilled' ]; return ( <Grid> <Row> <Col md={6} mdPush={3}> <Panel className="login"> <Form> <FormGroup controlId="email" bsClass="form-group label-floating"> <ControlLabel>email</ControlLabel> <FormControl type="text" {...omit(email, unknownProps)} /> </FormGroup> <FormGroup controlId="password" bsClass="form-group label-floating"> <ControlLabel>password</ControlLabel> <FormControl type="password" {...omit(password, unknownProps)} /> </FormGroup> <FormGroup controlId="username" bsClass="form-group label-floating"> <ControlLabel>username</ControlLabel> <FormControl type="text" {...omit(username, unknownProps)} /> </FormGroup> <Button bsStyle="primary" type="submit" onClick={this.handleSubmit.bind(this)}>login</Button> </Form> </Panel> </Col> </Row> </Grid> ); }
function buildSearchUrl(query) { query = omit(query, 'from', 'size'); // Params that don't go into the URL const queryStr = queryString.stringify(query) .replace(/%20/g, '+'); // Replace spaces with + because it's prettier return `/search${queryStr ? `?${queryStr}` : ''}`; }
return wpcom.site( siteId ).post( postId ).restore().then( ( restoredPost ) => { dispatch( { type: POST_RESTORE_SUCCESS, siteId, postId } ); dispatch( receivePost( omit( restoredPost, '_headers' ) ) ); } ).catch( ( error ) => {
this.removeAttr = function(attr) { if (isString(attr)) { delete this.attributes[attr]; } else { this.attributes = omit(this.attributes, attr); } return this; };
this.removeHtmlProp = function() { if (isString(arguments[0])) { delete this.htmlProps[arguments[0]]; } else { this.htmlProps = omit(this.htmlProps, arguments[0]); } return this; };
function Generator (options) { this.bracketData = bracketData({ year: options.year, sport: options.sport }) return this.reset(_omit(options, 'sport', 'year')) }
render() { const { LoadedComponent } = this.state; if (!LoadedComponent) { return null; } return <LoadedComponent { ...omit(this.props, 'getComponent') } />; }
[ NOTICE_REMOVE ]: ( state, action ) => { const { noticeId } = action; if ( ! state.hasOwnProperty( noticeId ) ) { return state; } return omit( state, noticeId ); },
export default function watchlistReducer(state = { loading: false, ids: [], entities: {}, error: null }, action){ const {type, payload} = action; switch(type){ case LOAD_WATCHING: case WATCH: case UNWATCH: return extend({}, state, { loading: true, error: null }); case _reject(LOAD_WATCHING): case _reject(WATCH): case _reject(UNWATCH): return extend({}, state, { loading: false, error: payload }); case resolve(LOAD_WATCHING): const norm = normalize(payload, Schemas.WATCHLIST_ARRAY); return extend({}, state, { loading: false, error: null, ids: union(state.ids, norm.result), entities: extend({}, state.entities, norm.entities.watchlist) }); case resolve(WATCH): const {data: {name, cover}, id} = action.meta; return extend({}, state, { loading: false, error: null, ids: union(state.ids, [id]), entities: extend({}, state.entities, playlist(null, action)) }); case resolve(UNWATCH): const playlistId = action.meta.id; return extend({}, state, { loading: false, error: null, ids: pull(state.ids, playlistId), entities: omit(state.entities, playlistId) }); default: return state; } }
optionChangedHandler = (ev, selectedItem) => { const result = {}; ev = ev || { preventDefault: noop, stopPropagation: noop }; const { onEmptySelected, optionValue, optionText, tags, onChange } = this.props; const { selectedItems } = this.state; if (!selectedItem) { onEmptySelected(ev); return; } const args = omit(selectedItem, ['cid']); result[optionValue] = selectedItem.value; result[optionText] = selectedItem.text; const data = { ...args, ...result }; if (tags) { if (!selectedItems.some(item => item.cid === selectedItem.cid)) { selectedItems.push(selectedItem); } } else if (selectedItem.value === null) { // customize reset option selectedItem = {}; } this.setState( { keyword: null, selectedItems, selectedItem }, () => { onChange( { target: { ...this.props, type: tags ? 'select-multiple' : 'select-one', value: selectedItem.value }, preventDefault() { ev.preventDefault(); }, stopPropagation() { ev.stopPropagation(); } }, data ); } ); };
export function fetchSitePlansCompleted( siteId, data ) { data = omit( data, '_headers' ); return { type: SITE_PLANS_FETCH_COMPLETED, siteId, plans: map( data, createSitePlanObject ) }; }
export const SubHeaderButton = props => { const {tag: Tag, children} = props return ( <Tag className='mdl-button mdl-color-text--white' {...omit(props, 'tag', 'children')}> {children} </Tag> ) }
patch(id, data) { return this.Model.query() .where({id}) .update( omit(data, 'id', 'created_at') ) .then(() => this.get(id)) .catch(utils.errorHandler) }