How to use hasHistory method in devicefarmer-stf

Best JavaScript code snippet using devicefarmer-stf

undo.js

Source:undo.js Github

copy

Full Screen

1//developed with the guidlines from here:2//https://github.com/reactjs/redux/blob/master/docs/recipes/ImplementingUndoHistory.md3import { UNDOING, UNDONE, REDONE, UNDOFAILED, CLEARPAST } from '../actions/undo'4const undoEnhancer = (reducer) => {5 const initState = {6 undoState: {7 past: [],8 present: reducer(undefined, {}),9 future: []10 },11 fetching: false,12 hasHistory: false,13 hasFuture: false,14 err: ''15 }16 return function (state = initState, action) {17 const { past, present, future } = state.undoState;18 var hasHistory = past.filter(past => past.fetching === false && past.err === '').length > 1;19 var hasFuture = future.filter(future => future.fetching === false && future.err === '').length > 0;20 switch (action.type) {21 case UNDOING:22 return { ...state, fetching: true, err: '' };23 case REDONE:24 //undone modified to allow desired time travel25 const next = action.desiredFuture;26 const newFuture = future.slice(action.desiredFutureIndex + 1, future.length);27 const newPastRedone = [...past, present]; //shift present to the past28 hasHistory = newPastRedone.filter(past => past.fetching === false && past.err === '').length > 1;29 hasFuture = newFuture.filter(future => future.fetching === false && future.err === '').length > 0;30 return {31 undoState: {32 past: newPastRedone,33 present: next,34 future: newFuture35 },36 fetching: false,37 hasHistory: hasHistory,38 hasFuture: hasFuture,39 err: ''40 }41 case UNDONE:42 //undone modified to allow desired time travel43 const previous = action.desiredPast;44 //old code, was maintaiining unsuccessful past45 //const newPast = past.slice(0,action.desiredPastIndex-1);46 //ditch uncsuccesful pasts47 const successfulPast = past.filter((past, index) => {48 return past.fetching === false && past.err === '';49 })50 const newPast = successfulPast.slice(0, successfulPast.length - 1);51 const newFutureUndone = [present, ...future];52 //the first past is invalid?53 hasHistory = newPast.filter(past => past.fetching === false && past.err === '').length > 1;54 hasFuture = newFutureUndone.filter(future => future.fetching === false && future.err === '').length > 0;55 return {56 undoState: {57 past: newPast,58 present: previous,59 future: newFutureUndone60 },61 fetching: false,62 hasHistory: hasHistory,63 hasFuture: hasFuture,64 err: ''65 }66 case UNDOFAILED:67 //console.log(action.err);68 return { ...state, fetching: false, hasHistory: hasHistory, err: action.err };69 case CLEARPAST:70 return initState;71 default:72 // Delegate handling the action to the passed reducer73 const newPresent = reducer(present, action)74 if (present === newPresent) {75 return state76 }77 return {78 undoState: {79 past: [...past, present],80 present: newPresent,81 future: []82 },83 fetching: false,84 hasHistory: hasHistory,85 hasFuture: hasFuture,86 err: ''87 }88 }89 }90}...

Full Screen

Full Screen

QuestionsBar.js

Source:QuestionsBar.js Github

copy

Full Screen

1import React, { PureComponent } from 'react';2import autoBindReact from 'auto-bind/react';3import _ from 'lodash';4import PropTypes from 'prop-types';5import { FlatList, Platform } from 'react-native';6import { I18n } from 'shoutem.i18n';7import { connectStyle } from '@shoutem/theme';8import { ext } from '../const';9import Question from './Question';10function getItemName(item) {11 return _.get(item, 'name') || _.get(item, 'buttonLabel');12}13export class QuestionsBar extends PureComponent {14 static propTypes = {15 onBackPress: PropTypes.func,16 onItemPress: PropTypes.func,17 items: PropTypes.array,18 hasHistory: PropTypes.bool,19 style: PropTypes.any,20 };21 constructor(props) {22 super(props);23 autoBindReact(this);24 this.BACK_ITEM_NAME = I18n.t(ext('backButtonTitle'));25 const { hasHistory, items } = props;26 this.state = {27 items: hasHistory ? [{ name: this.BACK_ITEM_NAME }, ...items] : items,28 ready: true,29 };30 }31 componentDidUpdate(prevProps) {32 const { items, hasHistory } = this.props;33 const { items: prevItems } = prevProps;34 // ScrollView has some issues with rerendering on items change. Specifically,35 // scrollview doesn't know how to modify scroll offset in this case, even through one36 // of many scrollTo native methods37 if (prevItems !== items) {38 if (Platform.OS === 'ios') {39 this.setState({40 items: hasHistory ? [{ name: this.BACK_ITEM_NAME }, ...items] : items,41 });42 }43 if (Platform.OS === 'android') {44 this.setState(45 {46 items: hasHistory47 ? [{ name: this.BACK_ITEM_NAME }, ...items]48 : items,49 ready: false,50 },51 () => this.setState({ ready: true }),52 );53 }54 }55 }56 renderQuestion({ item }) {57 const { onBackPress, onItemPress } = this.props;58 const isBackItem = _.get(item, 'name') === this.BACK_ITEM_NAME;59 const onPress = isBackItem ? onBackPress : onItemPress;60 return <Question isBack={isBackItem} item={item} onPress={onPress} />;61 }62 render() {63 const { style } = this.props;64 const { items, ready } = this.state;65 if (!ready) {66 return null;67 }68 return (69 <FlatList70 ref={ref => (this.list = ref)}71 contentContainerStyle={style.contentContainer}72 data={items}73 horizontal74 keyExtractor={getItemName}75 renderItem={this.renderQuestion}76 showsHorizontalScrollIndicator={false}77 style={style.container}78 />79 );80 }81}...

Full Screen

Full Screen

docs-controller.js

Source:docs-controller.js Github

copy

Full Screen

1module.exports =2 function DocsCtrl($rootScope, $scope, $window, $location) {3 function hasHistory() {4 return $window.history.length > 15 }6 $scope.hasHistory = hasHistory()7 $scope.goBack = function() {8 $window.history.back()9 }10 $scope.goHome = function() {11 $location.path('/docs/Help')12 }13 /* eslint no-console:0 */14 $rootScope.$on('$routeChangeError',15 function(event, current, previous, rejection) {16 console.error('ROUTE CHANGE ERROR: ' + rejection)17 console.log('event', event)18 console.log('current', current)19 console.log('previous', previous)20 })...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf-client');2client.hasHistory('12345').then(function(hasHistory) {3 console.log('hasHistory: ' + hasHistory);4});5var stf = require('devicefarmer-stf-client');6client.getHistory('12345').then(function(history) {7 console.log('history: ' + history);8});9var stf = require('devicefarmer-stf-client');10client.getDevice('12345').then(function(device) {11 console.log('device: ' + device);12});13var stf = require('devicefarmer-stf-client');14client.getDevices().then(function(devices) {15 console.log('devices: ' + devices);16});17var stf = require('devicefarmer-stf-client');18client.getDevicesByOwner('12345').then(function(devices) {19 console.log('devices: ' + devices);20});21var stf = require('devicefarmer-stf-client');22client.getDevicesByGroup('12345').then(function(devices) {23 console.log('devices: ' + devices);24});25var stf = require('devicefarmer-stf-client');26client.getDevicesByProvider('12345').then(function(devices) {27 console.log('devices: ' + devices);28});

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf-client');2var device = client.getDevice('HT4A1SK00708');3device.hasHistory().then(function(hasHistory) {4 console.log('Has history: ' + hasHistory);5});6var stf = require('devicefarmer-stf-client');7var device = client.getDevice('HT4A1SK00708');8device.hasHistory().then(function(hasHistory) {9 console.log('Has history: ' + hasHistory);10 if (hasHistory) {11 device.getHistory().then(function(history) {12 console.log('History: ' + JSON.stringify(history));13 });14 }15});16History: {"start":1464196300000,"end":1464196300000,"success":true,"error":null}17History: {"start":1464196300000,"end":1464196300000,"success":true,"error":null}18History: {"start":1464196300000,"end":1464196300000,"success":true,"error":null}19History: {"

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2var Promise = require('bluebird');3var device = client.getDevice('7b0c78f6');4device.hasHistory().then(function(hasHistory) {5 console.log(hasHistory);6});7hasHistory()8var stf = require('devicefarmer-stf');9var Promise = require('bluebird');10var device = client.getDevice('7b0c78f6');11device.hasHistory().then(function(hasHistory) {12 console.log(hasHistory);13});14hasHistory()15var stf = require('devicefarmer-stf');16var Promise = require('bluebird');17var device = client.getDevice('7b0c78f6');18device.hasHistory().then(function(hasHistory) {19 console.log(hasHistory);20});21hasHistory()22var stf = require('devicefarmer-stf');23var Promise = require('bluebird');24var device = client.getDevice('7b0c78f6');25device.hasHistory().then(function(hasHistory) {26 console.log(hasHistory);27});28hasHistory()29var stf = require('devicefarmer-stf');30var Promise = require('bluebird');

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run devicefarmer-stf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful