it('send field value for radio', function(done){ var radioConfig = { id: 'testRadio', name: 'Radio', label: 'Test Radio', type: 'radio', value: "two", options: [{'label':'one','value':'one'},{'label':'two','value':'two'}] }; var radioField = TestUtils.renderIntoDocument(<Field {...radioConfig}/>); Dispatcher.register( 'TEST-FIELD-SEND-VALUE-RADIO' , function(action,data){ if( action === constants.actions.FIELD_VALUE && data.id === radioConfig.id) { Dispatcher.unregister('TEST-FIELD-SEND-VALUE-RADIO'); expect(data.value).toEqual(radioConfig.value); expect(data.id).toEqual(radioConfig.id); expect(data.name).toEqual(radioConfig.name); done(); } }); Flux.doAction(constants.actions.GET_FIELD_VALUE, {'id':radioConfig.id}); });
it('send field value for checkbox field as fieldGroup', function(done){ var checkboxFieldConfig = { id: 'testCheckbox', name: 'testCheckbox', label: 'Test Checkbox', type: 'checkbox', value: ['one','two'], options: [{'label':'one','value':'one'},{'label':'two','value':'two'}] }; var checkboxField = TestUtils.renderIntoDocument(<Field {...checkboxFieldConfig}/>); Dispatcher.register( 'TEST-FIELD-SEND-VALUE-CHECKBOX' , function(action,data){ if( action === constants.actions.FIELD_VALUE && data.id === checkboxFieldConfig.id) { Dispatcher.unregister('TEST-FIELD-SEND-VALUE-CHECKBOX'); expect(data.value).toEqual(checkboxFieldConfig.value); expect(data.id).toEqual(checkboxFieldConfig.id); expect(data.name).toEqual(checkboxFieldConfig.name); done(); } }); Flux.doAction(constants.actions.GET_FIELD_VALUE, {'id':checkboxFieldConfig.id}); });
it('send field value for checkbox field as checkable that is NOT checked', function(done){ var checkboxCheckableFieldNotCheckedConfig = { id: 'testCheckboxCheckableNot', name: 'testCheckboxCheckableNot', label: 'Test Checkbox Not', type: 'checkbox', value: "two", checked : false }; var checkboxCheckableNotCheckedField = TestUtils.renderIntoDocument(<Field {...checkboxCheckableFieldNotCheckedConfig}/>); Dispatcher.register( 'TEST-FIELD-SEND-VALUE-CHECKBOX-CHECKABLE-NOT-CHECKED' , function(action,data){ if( action === constants.actions.FIELD_VALUE && data.id === checkboxCheckableFieldNotCheckedConfig.id) { Dispatcher.unregister('TEST-FIELD-SEND-VALUE-CHECKBOX-CHECKABLE-NOT-CHECKED'); expect(data.value).toEqual(null); expect(data.id).toEqual(checkboxCheckableFieldNotCheckedConfig.id); expect(data.name).toEqual(checkboxCheckableFieldNotCheckedConfig.name); done(); } }); Flux.doAction(constants.actions.GET_FIELD_VALUE, {'id':checkboxCheckableFieldNotCheckedConfig.id}); });
Flux.doAction(constants.actions.WORKFLOW_NEXT_PAGE).then(function(){ expect(workflow.state.lastSectionCompleted).toEqual('page3'); Flux.doAction(constants.actions.WORKFLOW_NEXT_PAGE).then(function(){ expect(workflow.state.lastSectionCompleted).toEqual('page4'); done(); }); });
it('can autoclose itself after a set duration', function(done){ Flux.doAction('test', 'info', 'This is a delayed test.', true).then(function(){ setTimeout(function(){ expect(alertDOM.className).toEqual(hiddenClassName); done(); }, 1000); }); });
editedChange: function (updater, value) { // Меняется режим редактирования документа updater.set({edited: value}); if (value) { backupDoc(); } else { flux.doAction('backupChange', {docData: null, gridData: null}); } },
it('can revert to the previous section', function(done){ this.workflow.setState({currentPage: 'page2', previousPage: 'page1', nextPage: 'page3'}); expect(this.workflow.state.currentPage).toEqual('page2'); Flux.doAction( constants.actions.WORKFLOW_PREVIOUS_PAGE ).then(function(){ expect(this.workflow.state.currentPage).toEqual('page1'); expect(this.workflow.state.previousPage).toBeUndefined(); expect(this.workflow.state.nextPage).toEqual('page2'); done(); }.bind(this)); });
it('can progress to the next section', function(done){ let workflow = this.workflow; expect(workflow.state.currentPage).toEqual('page2'); Flux.doAction(constants.actions.WORKFLOW_NEXT_PAGE).then(function(){ expect(workflow.state.currentPage).toEqual('page3'); expect(workflow.state.previousPage).toEqual('page2'); expect(workflow.state.nextPage).not.toBeDefined(); done(); }); });
requery('save', JSON.stringify(saveData), function (err, data) { if (err) return err; try { let newId = data[0].id; // обновим ид saveData.data.id = newId; flux.doAction('dataChange', saveData.data); //новые данные flux.doAction('docIdChange', newId); // новое ид flux.doAction('savedChange', true); // устанавливаем режим сохранен flux.doAction('editedChange', false); // устанавливаем режим сохранен // reload document reloadDocument(newId); //@todo выполнить перегрузку данных перез перегрузки страницы } catch (e) { console.error('tekkis viga', e); } });
it('can progress to the next section and update lastSectionCompleted', function(done){ let config = longerWorkflow; let component = Factory.build(elements, config, config)[0]; let workflow = TestUtils.renderIntoDocument(component); Flux.doAction(constants.actions.WORKFLOW_NEXT_PAGE).then(function(){ expect(workflow.state.lastSectionCompleted).toEqual('page3'); Flux.doAction(constants.actions.WORKFLOW_NEXT_PAGE).then(function(){ expect(workflow.state.lastSectionCompleted).toEqual('page4'); done(); }); }); });
it('can load files for preview fetched from an API', (done) => { let compTwo = TestUtils.renderIntoDocument(<File {...configTwo}/>); expect(compTwo.value).not.toBeDefined(); Dispatcher.register('load-file-preview-list', (action, data) => { if (action === FILE_PREVIEW_LIST_LOAD && data.fieldId === configTwo.id) { Dispatcher.unregister('load-file-preview-list'); expect(compTwo.value).toEqual(fixture.value); done(); } }); // Action called in PE on successful response from FILE_PREVIEW_LIST_GET Flux.doAction(FILE_PREVIEW_LIST_LOAD, {fieldId: 'file-test2', value: fixture}); });
setLibsFilter: function (updater, libName, filter) { // ищем справочник let libs = this.libs; for (let i = 0; i < libs.length; i++) { if (libs[i].id == libName) { if (filter) { libs[i].filter = filter; flux.doAction('loadLibs', libName); //новые данные } break; } } },
}), function (err, data) { if (err) throw err; let newLibs = docStore.libs.map(function (item) { // ищем данные справолчника, которые обновили let returnData = item; if (item.id == libraryName) { returnData.data = data; } return returnData; }); if (newLibs.length > 0) { flux.doAction('libsChange', newLibs); // пишем изменения в хранилище } });
it('can skip the next section', function(done){ let config = childrenFixture; let component = Factory.build(elements, config, config)[0]; let workflow = TestUtils.renderIntoDocument(component); let dom = React.findDOMNode(workflow); let ul = dom.childNodes[1]; let page2Link = ul.childNodes[1].childNodes[0]; expect(workflow.state.currentPage).toEqual('page1'); Flux.doAction(constants.actions.WORKFLOW_NEXT_PAGE).then(function() { // page2 is skipped because page2 props.skip is true expect(workflow.state.currentPage).toEqual('page3'); // navigate away to page5 to test again workflow.setState({currentPage: 'page5'}); expect(workflow.state.currentPage).toEqual('page5'); // click on page2 link in nav-tree TestUtils.Simulate.click(page2Link); setTimeout(function() { // page2 is skipped again expect(workflow.state.currentPage).toEqual('page3'); done(); }, 300); }); });
it('send field value for text field', function(done){ var textFieldConfig = { id: 'testText', name: 'testText', label: 'Test Text', type: 'text', value: 'ten' }; var textField = TestUtils.renderIntoDocument(<Field {...textFieldConfig}/>); Dispatcher.register('TEST-FIELD-SEND-VALUE-TEXT', function(action, data){ if( action === constants.actions.FIELD_VALUE && data.id === textFieldConfig.id) { Dispatcher.unregister('TEST-FIELD-SEND-VALUE-TEXT'); expect(data.value).toEqual(textFieldConfig.value); expect(data.id).toEqual(textFieldConfig.id); expect(data.name).toEqual(textFieldConfig.name); done(); } }); Flux.doAction(constants.actions.GET_FIELD_VALUE, {'id':textFieldConfig.id}); });
it('can display a custom message type', function(done){ Flux.doAction('test', 'danger', 'This is a test.').then(function(){ expect(alertDOM.className).toEqual('alert alert-dismissible alert-danger'); done(); }); });
it('can display a message to the user', function(done){ Flux.doAction('test', 'info', 'This is a test.').then(function(){ expect(alertDOM.childNodes[1].textContent).toEqual('This is a test.'); done(); }); });
/** * сохраняет копию данных */ function backupDoc() { let docData = JSON.stringify(docStore.data), gridData = JSON.stringify(docStore.details); flux.doAction('backupChange', {docData: docData, gridData: gridData}); }
onClick : function() { flux.doAction('viewEmail', this.props.email) }
}).done(function(data) { flux.doAction('changePlaylistUrl', data.spotify_uri); this.setState({ loading: false }); }.bind(this));
$.ajax({ method: 'GET', url: '/api/locations/' + SessionStore.location + '/events', }).done(function(data) { this.setState({ loading: false, events: data.events, city: data.city }); NProgress.done(); }.bind(this)); }, componentWillUnmount() { NProgress.done(); }, handleResetLocation() { flux.doAction('changeLocation', null); }, render() { if (this.state.loading) { return ( <Page header='Loading...' /> ); } return ( <Page header={`Bands coming to ${this.state.city}`}> <p> Pick about 10 bands you like. This will help us create a playlist for you. </p> <p>