Best JavaScript code snippet using cucumber-gherkin
EditMatch.jsx
Source:EditMatch.jsx
1import React, { Component } from 'react';2import MatchService from '../../services/MatchService';3class EditMatch extends Component {4 constructor(props){5 super(props)6 this.state={7 op:this.props.match.params.id,8 match_Id:'',9 match_name:'',10 match_genre:'',11 match_language:'',12 match_hours:'',13 match_rating:'',14 match_description:'',15 match_date:''16 }17 }18 componentDidMount(){19 MatchService.getByMatchId(this.state.op).then((response)=>{20 let matchob=response.data;21 this.setState({match_Id:matchob.matchId,22 match_name:matchob.matchName,23 match_genre:matchob.matchGenre,24 match_lanuage:matchob.matchLanguage,25 match_hours:matchob.matchHours,26 match_rating:matchob.matchRating,27 match_description:matchob.matchDescription,28 match_date:matchob.matchDate });29 })30 31 }32 editMatch=(e)=>{33 e.preventDefault();34 console.log(this.state);35 let match={ matchId:this.state.match_Id,36 matchName:this.state.match_name,37 matchGenre:this.state.match_genre,38 matchLanguage:this.state.match_language,39 matchHours:this.state.match_hours,40 matchRating:this.state.match_rating,41 matchDescription:this.state.match_description,42 matchDate:this.state.match_date}43 console.log((JSON.stringify(match)));44 MatchService.editMatch(match);45 console.log("match details updated succesfully");46 this.props.history.push('/Admin');47 }48 49 50 changeMatchNameHandler=(event)=>{this.setState({match_name:event.target.value});}51 changeMatchGenreHandler=(event)=>{this.setState({match_genre:event.target.value});}52 changeMatchLanguageHandler=(event)=>{this.setState({match_language:event.target.value});}53 changeMatchHoursHandler=(event)=>{this.setState({match_hours:event.target.value});}54 changeMatchRatingHandler=(event)=>{this.setState({match_rating:event.target.value});}55 changeMatchDescriptionHandler=(event)=>{this.setState({match_description:event.target.value});}56 changeMatchDateHandler=(event)=>{this.setState({match_date:event.target.value});}57 changeMatchIdHandler=(event)=>{this.setState({match_Id:event.target.value});}58 render() {59 return (60 <section>61 <div class="custom-container">62 63 <form onSubmit={this.editMatch} style={{background:'white'}}>64 <div class="col-lg-6 text-center text-lg-left" >65 <div class="section-title">66 <h1>Edit Match Details</h1>67 </div>68 </div>69 <hr />70 <div class="form-row">71 <div class="form-group">72 <div class="input-data">73 <input74 type="text"75 class="form-control"76 formControlName="matchId"77 name='match_Id'78 id='match_Id'79 required80 value={this.state.match_Id} 81 onChange={this.changeMatchIdHandler}82 83 />84 <div class="underline"></div>85 <label for="">Match Id</label>86 </div>87 </div>88 </div>89 <div class="form-row">90 <div class="form-group">91 <div class="input-data">92 <input93 type="text"94 class="form-control"95 formControlName="matchName"96 name='match_name'97 id='match_name'98 required99 value={this.state.match_name} 100 onChange={this.changeMatchNameHandler}101 102 />103 <div class="underline"></div>104 <label for="">Match Name</label>105 </div>106 </div>107 </div>108 <div class="form-row">109 <div class="form-group">110 <div class="row">111 <div class="col input-data">112 <input113 type="text"114 class="form-control"115 formControlName="matchGenre"116 name='match_genre'117 id='match_genre'118 value={this.state.match_genre} 119 onChange={this.changeMatchGenreHandler}120 121 required122 />123 <div class="underline"></div>124 <label for="">Match Genre</label>125 </div>126 <div class="col input-data">127 <input128 type="text"129 class="form-control"130 formControlName="matchLanguage"131 name='match_language'132 id='match_language'133 value={this.state.match_language} 134 onChange={this.changeMatchLanguageHandler}135 required136 />137 <div class="underline"></div>138 <label for="">Match Language</label>139 </div>140 </div>141 </div>142 </div>143 <div class="form-row">144 <div class="form-group">145 <div class="row">146 <div class="col input-data">147 <input148 type="text"149 class="form-control"150 formControlName="matchHours"151 name='match_hours'152 id='match-hours'153 value={this.state.match_hours} 154 onChange={this.changeMatchHoursHandler}155 required156 />157 <div class="underline"></div>158 <label for="">Match Hours</label>159 </div>160 <div class="col input-data">161 <input162 type="number"163 class="form-control"164 formControlName="matchRating"165 name='match_rating'166 id='match_rating'167 value={this.state.match_rating} 168 onChange={this.changeMatchRatingHandler}169 required170 />171 <div class="underline"></div>172 <label for="">Match Rating</label>173 </div>174 </div>175 </div>176 </div>177 <div class="form-group">178 <div class="form-row">179 <div class="input-data textarea">180 <textarea181 rows="8"182 cols="80"183 formControlName="matchDescription"184 name='match_description'185 id='match_description'186 value={this.state.match_description} 187 onChange={this.changeMatchDescriptionHandler}188 required189 ></textarea>190 <div class="underline"></div>191 <label for="">Match Description</label>192 </div>193 </div>194 <div class="form-row">195 <div class="date">196 <input197 type="date"198 class="form-control"199 placeholder="Enter Match Date"200 formControlName="matchDate"201 name='match_date'202 id='match_date'203 value={this.state.match_date} 204 onChange={this.changeMatchDateHandler}205 />206 </div>207 </div>208 </div>209 <div>210 <button211 type="submit"212 class="btn btn-primary"213 214 >215 update changes216 </button>217 </div>218 </form>219 </div>220 </section>221 );222 }223}...
Addmatch.jsx
Source:Addmatch.jsx
1import React, { Component } from 'react';2import './AddMatch.css';3import MatchService from '../../services/MatchService';4class Addmatch extends Component {5 constructor(){6 super();7 this.state={8 match_name:'',9 match_genre:'',10 match_language:'',11 match_hours:'',12 match_rating:'',13 match_description:'',14 match_date:'' 15 }16 this.changeMatchNameHandler=this.changeMatchNameHandler.bind(this);17 this.changeMatchGenreHandler=this.changeMatchGenreHandler.bind(this);18 this.changeMatchLanguageHandler=this.changeMatchLanguageHandler.bind(this);19 this.changeMatchHoursHandler=this.changeMatchHoursHandler.bind(this);20 this.changeMatchRatingHandler=this.changeMatchRatingHandler.bind(this);21 this.changeMatchDescriptionHandler=this.changeMatchDescriptionHandler.bind(this);22 this.changeMatchDateHandler=this.changeMatchDateHandler.bind(this);23 this.addMatch=this.addMatch.bind(this);24 }25 addMatch=(u)=>{26 u.preventDefault();27 let match={matchName:this.state.match_name,28 matchGenre:this.state.match_genre,29 matchLanguage:this.state.match_language,30 matchHours:this.state.match_hours,31 matchRating:this.state.match_rating,32 matchDescription:this.state.match_description,33 matchDate:this.state.match_date}34 console.log((JSON.stringify(match)));35 MatchService.matchAdd(match)36 .then(response => {37 console.log('Match Added successfully', response.data);38 this.props.history.push('/Admin');39 });40 }41 changeMatchNameHandler=(event)=>{this.setState({match_name:event.target.value});}42 changeMatchGenreHandler=(event)=>{this.setState({match_genre:event.target.value});}43 changeMatchLanguageHandler=(event)=>{this.setState({match_language:event.target.value});}44 changeMatchHoursHandler=(event)=>{this.setState({match_hours:event.target.value});}45 changeMatchRatingHandler=(event)=>{this.setState({match_rating:event.target.value});}46 changeMatchDescriptionHandler=(event)=>{this.setState({match_description:event.target.value});}47 changeMatchDateHandler=(event)=>{this.setState({match_date:event.target.value});}48 render() {49 return (50 51 <section>52 <div class="custom-container">53 54 <form onSubmit={this.addMatch} style={{background:'white'}}>55 <div class="col-lg-6 text-center text-lg-left" style={{background:'blue'}}>56 <div class="section-title">57 <h1>Add Match</h1>58 </div>59 </div>60 <hr />61 <div class="form-row">62 <div class="form-group">63 <div class="input-data">64 <input65 type="text"66 class="form-control"67 formControlName="matchName"68 name='match_name'69 id='match_name'70 required71 value={this.state.match_name} 72 onChange={this.changeMatchNameHandler}73 />74 <div class="underline"></div>75 <label for="">Match Name</label>76 </div>77 </div>78 </div>79 <div class="form-row">80 <div class="form-group">81 <div class="row">82 <div class="col input-data">83 <input84 type="text"85 class="form-control"86 formControlName="matchGenre"87 name='match_genre'88 id='match_genre'89 value={this.state.match_genre} 90 onChange={this.changeMatchGenreHandler}91 required92 />93 <div class="underline"></div>94 <label for="">Match Genre</label>95 </div>96 <div class="col input-data">97 <input98 type="text"99 class="form-control"100 formControlName="matchLanguage"101 name='match_language'102 id='match_language'103 value={this.state.match_language} 104 onChange={this.changeMatchLanguageHandler}105 required106 />107 <div class="underline"></div>108 <label for="">Match Language</label>109 </div>110 </div>111 </div>112 </div>113 <div class="form-row">114 <div class="form-group">115 <div class="row">116 <div class="col input-data">117 <input118 type="text"119 class="form-control"120 formControlName="matchHours"121 name='match_hours'122 id='match-hours'123 value={this.state.match_hours} 124 onChange={this.changeMatchHoursHandler}125 required126 />127 <div class="underline"></div>128 <label for="">Match Hours</label>129 </div>130 <div class="col input-data">131 <input132 type="number"133 class="form-control"134 formControlName="matchRating"135 name='match_rating'136 id='match_rating'137 value={this.state.match_rating} 138 onChange={this.changeMatchRatingHandler}139 required140 />141 <div class="underline"></div>142 <label for="">Match Rating</label>143 </div>144 </div>145 </div>146 </div>147 <div class="form-group">148 <div class="form-row">149 <div class="input-data textarea">150 <textarea151 rows="8"152 cols="80"153 formControlName="matchDescription"154 name='match_description'155 id='match_description'156 value={this.state.match_description} 157 onChange={this.changeMatchDescriptionHandler}158 required159 ></textarea>160 <div class="underline"></div>161 <label for="">Match Description</label>162 </div>163 </div>164 <div class="form-row">165 <div class="date">166 <input167 type="date"168 class="form-control"169 placeholder="Enter Match Date"170 formControlName="matchDate"171 name='match_date'172 id='match_date'173 value={this.state.match_date} 174 onChange={this.changeMatchDateHandler}175 />176 </div>177 </div>178 </div>179 <div>180 <button181 type="submit"182 class="btn btn-primary"183 184 >185 Add Match186 </button>187 </div>188 </form>189 </div>190</section>191 );192 }193}...
MatchList.jsx
Source:MatchList.jsx
1// import React, { Component } from "react";2// import MatchService from '../../services/MatchService';3// import { Link } from "react-router-dom";4// class TutorialsList extends Component {5// constructor(props) {6// super(props);7// this.onChangeSearchTitle = this.onChangeSearchTitle.bind(this);8// this.retrieveMatchs = this.retrieveMatchs.bind(this);9// this.refreshList = this.refreshList.bind(this);10// // this.searchTitle = this.searchTitle.bind(this);11// this.state = {12// matchs: [],13// match_id: -1,14// match_date: new Date().toLocaleString(),15// match_description: "",16// match_genre: "",17// match_hours: "",18// match_language: "",19// match_name: "",20// match_rating: "",21// show_show_id: -122// };23// }24// componentDidMount() {25// this.retrieveMatchs();26// }27// onChangeSearchTitle(e) {28// const searchTitle = e.target.value;29// this.setState({30// searchTitle: searchTitle31// });32// } 33// retrieveMatchs() {34// MatchService.getMatchs()35// .then(response => {36// this.setState({37// matchs: response.data38// });39// console.log(response.data);40// })41// .catch(e => {42// console.log(e);43// });44// }45// refreshList() {46// this.retrieveMatchs();47// this.setState({48// match_id: -1,49// match_date: new Date().toLocaleString(),50// match_description: "",51// match_genre: "",52// match_hours: "",53// match_language: "",54// match_name: "",55// match_rating: "",56// show_show_id: -157// });58// }59// // searchTitle() {60// // MatchService.findByTitle(this.state.searchTitle)61// // .then(response => {62// // this.setState({63// // tutorials: response.data64// // });65// // console.log(response.data);66// // })67// // .catch(e => {68// // console.log(e);69// // });70// // }71// render() {72// const { searchTitle, tutorials, currentTutorial, currentIndex } = this.state;73// return (74// <div className="list row">75// <div className="col-md-8">76// <div className="input-group mb-3">77// <input78// type="text"79// className="form-control"80// placeholder="Search by title"81// value={searchTitle}82// onChange={this.onChangeSearchTitle}83// />84// <div className="input-group-append">85// <button86// className="btn btn-outline-secondary"87// type="button"88// onClick={this.searchTitle}89// >90// Search91// </button>92// </div>93// </div>94// </div>95// <div className="col-md-6">96// <h4>Matchs List</h4>97// <ul className="list-group">98// {tutorials &&99// tutorials.map((tutorial, index) => (100// <li101// className={102// "list-group-item " +103// (index === currentIndex ? "active" : "")104// }105// onClick={() => this.setActiveTutorial(tutorial, index)}106// key={index}107// >108// {tutorial.title}109// </li>110// ))}111// </ul>112// <button113// className="m-3 btn btn-sm btn-danger"114// onClick={this.removeAllTutorials}115// >116// Remove All117// </button>118// </div>119// <div className="col-md-6">120// {currentTutorial ? (121// <div>122// <h4>Tutorial</h4>123// <div>124// <label>125// <strong>Title:</strong>126// </label>{" "}127// {currentTutorial.title}128// </div>129// <div>130// <label>131// <strong>Description:</strong>132// </label>{" "}133// {currentTutorial.description}134// </div>135// <div>136// <label>137// <strong>Status:</strong>138// </label>{" "}139// {currentTutorial.published ? "Published" : "Pending"}140// </div>141// <Link142// to={"/tutorials/" + currentTutorial.id}143// className="badge badge-warning"144// >145// Edit146// </Link>147// </div>148// ) : (149// <div>150// <br />151// <p>Please click on a Tutorial...</p>152// </div>153// )}154// </div>155// </div>156// );157// }158// }...
BookMatch.jsx
Source:BookMatch.jsx
1import React, { Component } from 'react';2import { Navbar, Nav, Container } from 'react-bootstrap';3import MatchService from '../../services/MatchService';4class BookMatch extends Component {5 constructor(props) {6 super(props)7 this.state = {8 op: this.props.match.params.id,9 matcharr: []10 // match_Id: '',11 // match_name: '',12 // match_genre: '',13 // match_language: '',14 // match_hours: '',15 // match_rating: '',16 // match_description: '',17 // match_date: ''18 }19 }20 componentDidMount() {21 MatchService.getByMatchId(this.state.op).then((response) => {22 console.log("in did mount");23 this.setState({ matcharr: response.data })24 console.log(this.state.matcharr)25 // let matchob = response.data;26 // this.setState({27 // match_Id: matchob.matchId,28 // match_name: matchob.matchName,29 // match_genre: matchob.matchGenre,30 // match_lanuage: matchob.matchLanguage,31 // match_hours: matchob.matchHours,32 // match_rating: matchob.matchRating,33 // match_description: matchob.matchDescription,34 // match_date: matchob.matchDate35 // });36 })37 }38 // editMatch = (e) => {39 // e.preventDefault();40 // console.log(this.state);41 // let match = {42 // matchId: this.state.match_Id,43 // matchName: this.state.match_name,44 // matchGenre: this.state.match_genre,45 // matchLanguage: this.state.match_language,46 // matchHours: this.state.match_hours,47 // matchRating: this.state.match_rating,48 // matchDescription: this.state.match_description,49 // matchDate: this.state.match_date50 // }51 // console.log((JSON.stringify(match)));52 // MatchService.editMatch(match);53 // console.log("match details updated succesfully");54 // this.props.history.push('/Admin');55 // }56 // changeMatchNameHandler = (event) => { this.setState({ match_name: event.target.value }); }57 // changeMatchGenreHandler = (event) => { this.setState({ match_genre: event.target.value }); }58 // changeMatchLanguageHandler = (event) => { this.setState({ match_language: event.target.value }); }59 // changeMatchHoursHandler = (event) => { this.setState({ match_hours: event.target.value }); }60 // changeMatchRatingHandler = (event) => { this.setState({ match_rating: event.target.value }); }61 // changeMatchDescriptionHandler = (event) => { this.setState({ match_description: event.target.value }); }62 // changeMatchDateHandler = (event) => { this.setState({ match_date: event.target.value }); }63 // changeMatchIdHandler = (event) => { this.setState({ match_Id: event.target.value }); }64 render() {65 return (66 <div>67 <h2 className="text-center">Match Details</h2>68 <div className='row'>69 <table striped bordered hover variant="dark">70 <thead>71 <tr>72 <th>Match Id</th>73 <th> Match Name</th>74 <th>Match Genre</th>75 <th> Match Hours</th>76 <th> Match Language</th>77 <th> Match Description</th>78 <th> Match Rating</th>79 <th> Show Id</th>80 </tr>81 </thead>82 <tbody>83 {84 85 <tr key={this.state.matcharr.showId}>86 <td>{this.state.matcharr.matchId}</td>87 <td>{this.state.matcharr.matchName}</td>88 <td>{this.state.matcharr.matchGenre}</td>89 <td>{this.state.matcharr.matchHours}</td>90 <td>{this.state.matcharr.matchLanguage}</td>91 <td>{this.state.matcharr.matchDescription}</td>92 <td>{this.state.matcharr.matchRating}</td>93 <td>{this.state.matcharr.showId}</td>94 {/* <td>95 <button className="btn btn-success" onClick={()=>this.editStadium(stadium.stadiumId)}>edit</button> </td>96 <td> <button className="btn btn-danger" onClick={()=>this.deleteStadium(stadium.stadiumId)}>delete</button></td>97 <td> <button className="btn btn-success" onClick={()=>this.addScreen(stadium.stadiumId)}>Add Screen</button>98 </td> */}99 </tr>100 }101 </tbody>102 </table>103 </div>104 </div>105 );106 }107}...
codeExamples.js
Source:codeExamples.js
1/**2 * For multi-language code samples, show only one language add a time and add3 * a language switching UI.4 */5(function($) {6 'use strict';7 var MATCH_LANGUAGE = /(?:lang|language)-([a-zA-Z]+)/;8 var LANGUAGE_NAMES = {9 sh: 'Bash',10 js: 'JavaScript',11 json: 'JSON',12 toml: 'TOML'13 };14 var DEFAULT_LANGUAGE = 'js';15 var STORAGE_KEY = 'code-examples';16 var codeExamples = {17 getLanguage: function() {18 if (!this._language && window.localStorage) {19 try {20 var data = JSON.parse(window.localStorage.getItem(STORAGE_KEY));21 this._language = data.language;22 }23 catch (error) {}24 }25 if (!this._language) {26 this._language = DEFAULT_LANGUAGE;27 }28 return this._language;29 },30 setLanguage: function(language) {31 this._language = language;32 if (window.localStorage) {33 window.localStorage.setItem(STORAGE_KEY, JSON.stringify({34 language: language35 }));36 }37 $(document).trigger('change-code-example-language', language);38 }39 };40 function clickedLanguageButton(event) {41 var language = $(event.target).attr('data-language');42 if (language) {43 codeExamples.setLanguage(language);44 }45 }46 function languageForElement(element) {47 var className = $(element).children('code').attr('class');48 var match = className && className.match(MATCH_LANGUAGE);49 return match && match[1];50 }51 function Switcher (element) {52 this.element = element;53 this.examples = this.findExamples();54 this.addUi();55 $(document).on('change-code-example-language', function(event, language) {56 this.setLanguage(language);57 }.bind(this));58 this.setLanguage(codeExamples.getLanguage());59 }60 Switcher.prototype.findExamples = function() {61 var examples = {};62 var self = this;63 $('pre', this.element).each(function(index, pre) {64 var language = languageForElement(pre);65 if (language) {66 examples[language] = pre;67 self._baseLanguage = self._baseLanguage || language;68 }69 });70 return examples;71 };72 Switcher.prototype.addUi = function() {73 this.createUi().prependTo(this.element);74 };75 Switcher.prototype.createUi = function() {76 var title = $(this.element).attr('name');77 var container = $('<div class="language-switcher"></div>');78 container.append($('<span class="code-example-title"></span>').text(title));79 for (var language in this.examples) {80 var languageName = LANGUAGE_NAMES[language] || capitalize(language);81 var button = $('<button class="language-switcher--setter"></button>')82 .text(languageName)83 .attr('data-language', language)84 .on('click', clickedLanguageButton);85 container.append(button);86 }87 return container;88 };89 Switcher.prototype.setLanguage = function(value) {90 if (!(value in this.examples)) {91 // find the first available language and show it92 value = this._baseLanguage;93 }94 var scrollTop = document.body.scrollTop;95 var bounds = this.element.getBoundingClientRect();96 for (var language in this.examples) {97 var visible = language === value;98 $(this.examples[language]).css('display', visible ? '' : 'none');99 $('.language-switcher--setter[data-language="' + language + '"]',100 this.element)101 .toggleClass('selected', visible);102 }103 if (bounds.top < 0) {104 var newBounds = this.element.getBoundingClientRect();105 window.scrollTo(106 document.body.scrollLeft,107 scrollTop + (newBounds.height - bounds.height));108 }109 };110 function capitalize(text) {111 return text.split(' ').map(function(word) {112 return word.charAt(0).toUpperCase() + word.slice(1);113 }).join(' ');114 }115 // ...and go!116 $('code-example').each(function(index, element) {117 new Switcher(element);118 });...
constants.js
Source:constants.js
1/**2 * Internal dependencies3 */4import { translate as __ } from 'i18n-calypso';5import {6 ACTION_URL,7 ACTION_PASS,8 ACTION_NOTHING,9 ACTION_RANDOM,10 ACTION_ERROR,11 MATCH_URL,12 MATCH_LOGIN,13 MATCH_REFERRER,14 MATCH_AGENT,15 MATCH_COOKIE,16 MATCH_HEADER,17 MATCH_CUSTOM,18 MATCH_ROLE,19 MATCH_SERVER,20 MATCH_IP,21 MATCH_PAGE,22 MATCH_LANGUAGE,23} from 'state/redirect/selector';24export const getMatches = () => [25 {26 value: MATCH_URL,27 label: __( 'URL only' ),28 },29 {30 value: MATCH_LOGIN,31 label: __( 'URL and login status' ),32 },33 {34 value: MATCH_ROLE,35 label: __( 'URL and role/capability' ),36 },37 {38 value: MATCH_REFERRER,39 label: __( 'URL and referrer' ),40 },41 {42 value: MATCH_AGENT,43 label: __( 'URL and user agent' ),44 },45 {46 value: MATCH_COOKIE,47 label: __( 'URL and cookie' ),48 },49 {50 value: MATCH_IP,51 label: __( 'URL and IP' ),52 },53 {54 value: MATCH_SERVER,55 label: __( 'URL and server' ),56 },57 {58 value: MATCH_HEADER,59 label: __( 'URL and HTTP header' ),60 },61 {62 value: MATCH_CUSTOM,63 label: __( 'URL and custom filter' ),64 },65 {66 value: MATCH_PAGE,67 label: __( 'URL and WordPress page type' ),68 },69 {70 value: MATCH_LANGUAGE,71 label: __( 'URL and language' ),72 },73];74export const getActions = () => [75 {76 value: ACTION_URL,77 label: __( 'Redirect to URL' ),78 },79 {80 value: ACTION_RANDOM,81 label: __( 'Redirect to random post' ),82 },83 {84 value: ACTION_PASS,85 label: __( 'Pass-through' ),86 },87 {88 value: ACTION_ERROR,89 label: __( 'Error (404)' ),90 },91 {92 value: ACTION_NOTHING,93 label: __( 'Do nothing (ignore)' ),94 },95];96export const getHttpCodes = () => [97 {98 value: '301',99 label: __( '301 - Moved Permanently' ),100 },101 {102 value: '302',103 label: __( '302 - Found' ),104 },105 {106 value: '303',107 label: __( '303 - See Other' ),108 },109 {110 value: '304',111 label: __( '304 - Not Modified' ),112 },113 {114 value: '307',115 label: __( '307 - Temporary Redirect' ),116 },117 {118 value: '308',119 label: __( '308 - Permanent Redirect' ),120 },121];122export const getHttpError = () => [123 {124 value: '400',125 label: __( '400 - Bad Request' ),126 },127 {128 value: '401',129 label: __( '401 - Unauthorized' ),130 },131 {132 value: '403',133 label: __( '403 - Forbidden' ),134 },135 {136 value: '404',137 label: __( '404 - Not Found' ),138 },139 {140 value: '410',141 label: __( '410 - Gone' ),142 },143 {144 value: '418',145 label: __( "418 - I'm a teapot" ),146 },147 {148 value: '451',149 label: __( '451 - Unavailable For Legal Reasons' ),150 },151 {152 value: '500',153 label: __( '500 - Internal Server Error' ),154 },155 {156 value: '501',157 label: __( '501 - Not implemented' ),158 },159 {160 value: '502',161 label: __( '502 - Bad Gateway' ),162 },163 {164 value: '503',165 label: __( '503 - Service Unavailable' ),166 },167 {168 value: '504',169 label: __( '504 - Gateway Timeout' ),170 },171];172export const getAllHttpCodes = () => getHttpCodes().concat( getHttpError() );173export const getSourceFlags = () => [174 {175 value: 'flag_regex',176 label: __( 'Regex' ),177 },178 {179 value: 'flag_trailing',180 label: __( 'Ignore Slash' ),181 },182 {183 value: 'flag_case',184 label: __( 'Ignore Case' ),185 },186];187export const FLAG_REGEX = 0;188export const FLAG_TRAILING = 1;189export const FLAG_CASE = 2;190export const getSourceQuery = () => [191 {192 value: 'exactorder',193 label: __( 'Exact match' ),194 },195 {196 value: 'exact',197 label: __( 'Exact match in any order' ),198 },199 {200 value: 'ignore',201 label: __( 'Ignore all parameters' ),202 },203 {204 value: 'pass',205 label: __( 'Ignore & pass parameters to the target' ),206 },...
index.js
Source:index.js
1var retext = require ('retext');2var language = require ('retext-language');3var languageData = require ('./languageData');4const identifyLanguage = (data = '') => {5 return new Promise (function (res, rej) {6 retext ()7 .use (language)8 .use (() => cst => {9 const [result] = cst.children10 .map (e => ({11 languages: ((e.data || {}).languages || [])12 .map (e => ({13 lang: e[0],14 matchScore: e[1],15 data: languageData.map[e[0]],16 }))17 .sort ((a, b) => -a.matchScore + b.matchScore),18 }))19 .filter (e => e.languages.length > 0);20 const [resolution = {}] = result.languages;21 const {lang: resolutionLang = 'undefined'} = resolution;22 const languageObject = languageData.map[resolutionLang] || {};23 const {24 lang: match_language = 'undefined',25 matchScore: match_score,26 } = resolution;27 res ({28 match_score,29 match_language,30 match_language_data: languageObject,31 match_languages: result.languages,32 match_languages_count: (result.languages || []).length,33 });34 })35 .process (data.replace (/\n/g, ' '));36 });37};...
matchLanguage.js
Source:matchLanguage.js
1function chgLanguange(mode) {2 var arr = [ '_gy', '_gd' ];3 var s = arr[mode];4 var s2 = arr[arr.length-1-mode];5 var alltable = $('alltable');6 $('#alltable span[' + s + ']').each(function(index, domEle) {7 domEle.innerHTML = domEle.getAttribute(s);8 });9 document.getElementById('match_language'+s).style.fontWeight = 'bold';10 document.getElementById('match_language'+s2).style.fontWeight = 'normal';
...
Using AI Code Generation
1var gherkin = require('gherkin');2var parser = new gherkin.Parser();3var lexer = new gherkin.Lexer('en');4";5var featureDoc = parser.parse(lexer.lex(feature));6var language = featureDoc.language;7var match = gherkin.match_Language(language);8console.log(match);9var gherkin = require('gherkin');10var parser = new gherkin.Parser();11var lexer = new gherkin.Lexer('en');12";13var featureDoc = parser.parse(lexer.lex(feature));14var language = featureDoc.language;15var match = gherkin.match_Language(language);16console.log(match);17var gherkin = require('gherkin');18var parser = new gherkin.Parser();19var lexer = new gherkin.Lexer('en');20";21var featureDoc = parser.parse(lexer.lex(feature));22var language = featureDoc.language;23var match = gherkin.match_Language(language);24console.log(match);
Using AI Code Generation
1var gherkin = require('cucumber-gherkin');2var fs = require('fs');3var language = gherkin.match_Language('test.feature');4var source = fs.readFileSync('test.feature', 'utf8');5var parser = new gherkin.Parser(language);6var document = parser.parse(source);7console.log(document.feature.name);
Using AI Code Generation
1var gherkin = require('cucumber-gherkin');2var path = require('path');3var featureFile = path.resolve(__dirname, 'test.feature');4var feature = gherkin.parse(featureFile);5var language = feature.match_Language('en');6console.log(language);7match_Language(language)
Using AI Code Generation
1var=Cucumber require('cucumber-gherkin');2var path = require('path');3var featureFile = path.resolve(__dirname, 'test.feature');4var feature = gherkin.parse(featureFile);5var language = feature.match_Language('en');6console.log(language);7match_Language(language)
Using AI Code Generation
1var Cucumber = require('cucumber');2var gherkin = require('gherkin');3var fs = require('fs');4var gherkinSource = fs.readFileSync('features/test.feature', 'utf8');5var language = 'en';6var feature = gherkin.Parser(language).parse(gherkinSource);7var featureName = feature.name;8var featureTags = feature.tags;9var featureDescription = feature.description;10var featureElements = feature.elements;11var featureElementName = featureElements[0].name;12var featureElementTags = featureElements[0].tags;13var featureElementDescription = featureElements[0].description;14var featureElementSteps = featureElements[0].steps;15var featureElementStepKeyword = featureElementSteps[0].keyword;16var featureElementStepName = featureElementSteps[0].name;17var featureElementStepArgument = featureElementSteps[0].argument;18console.log('Feature Name: ' + featureName);19console.log('Feature Tags: ' + featureTags);20console.log('Feature Description: ' + featureDescription);21console.log('Feature Element Name: ' + featureElementName);22console.log('Feature Element Tags: ' + featureElementTags);23console.log('Feature Element Description: ' + featureElementDescription);24console.log('Feature Element Step Keyword: ' + featureElementStepKeyword);25console.log('Feature Element Step Name: ' + featureElementStepName);26console.log('Feature Element Step Argument: ' + featureElementStepArgument);
Using AI Code Generation
1var gherkin = require('cucumber-gherkin');2var language = 'en';3';4gherkin.match_Language(feature, language, function (err, result) {5 if (err) {6 console.log('Error: ' + err);7 } else {8 console.log(result);9 }10});11{ language: 'en',12 [ { keyword: 'Scenario',13 [ { keyword: 'Given ',14 match: { location: 'test.js:11' } },15 { keyword: 'When ',16 match: { location: 'test.js:11' } },17 { keyword: 'Then ',18 match: { location: 'test.js:11' } } ],19 tags: [] } ] }
LambdaTest offers a detailed Cucumber testing tutorial, explaining its features, importance, best practices, and more to help you get started with running your automation testing scripts.
Here are the detailed Cucumber testing chapters to help you get started:
Get 100 minutes of automation test minutes FREE!!