How to use dates2String method in devicefarmer-stf

Best JavaScript code snippet using devicefarmer-stf

sgfTests.js

Source:sgfTests.js Github

copy

Full Screen

1const assert = require('assert')2const fs = require('fs')3const util = require('util')4const tmp = require('tmp')5const helper = require('../src/modules/helper')6const {sgf} = require('../src/modules/fileformats')7const gametree = require('../src/modules/gametree')8describe('sgf', () => {9 describe('tokenize', () => {10 it('should work on multiple nodes', () => {11 assert.deepEqual(sgf.tokenize('(;B[aa]SZ[19];AB[cc][dd:ee])'), [12 ['parenthesis', '('],13 ['semicolon', ';'],14 ['prop_ident', 'B'], ['c_value_type', '[aa]'],15 ['prop_ident', 'SZ'], ['c_value_type', '[19]'],16 ['semicolon', ';'],17 ['prop_ident', 'AB'], ['c_value_type', '[cc]'], ['c_value_type', '[dd:ee]'],18 ['parenthesis', ')']19 ])20 })21 it('should take escaping values into account', () => {22 assert.deepEqual(sgf.tokenize('(;C[hello\\]world];C[hello\\\\];C[hello])'), [23 ['parenthesis', '('],24 ['semicolon', ';'],25 ['prop_ident', 'C'], ['c_value_type', '[hello\\]world]'],26 ['semicolon', ';'],27 ['prop_ident', 'C'], ['c_value_type', '[hello\\\\]'],28 ['semicolon', ';'],29 ['prop_ident', 'C'], ['c_value_type', '[hello]'],30 ['parenthesis', ')']31 ])32 assert.deepEqual(sgf.tokenize('(;C[\\];B[aa];W[bb])'), [33 ['parenthesis', '('],34 ['semicolon', ';'],35 ['prop_ident', 'C'], ['c_value_type', '[\\];B[aa]'],36 ['semicolon', ';'],37 ['prop_ident', 'W'], ['c_value_type', '[bb]'],38 ['parenthesis', ')']39 ])40 })41 it('should allow lower case properties', () => {42 assert.deepEqual(sgf.tokenize('(;CoPyright[blah])'), [43 ['parenthesis', '('],44 ['semicolon', ';'],45 ['prop_ident', 'CoPyright'], ['c_value_type', '[blah]'],46 ['parenthesis', ')']47 ])48 })49 })50 describe('parse', () => {51 it('should parse multiple nodes', () => {52 assert.equal(gametree.getJson(sgf.parseTokens([53 ['parenthesis', '('],54 ['semicolon', ';'],55 ['prop_ident', 'B'], ['c_value_type', '[aa]'],56 ['prop_ident', 'SZ'], ['c_value_type', '[19]'],57 ['semicolon', ';'],58 ['prop_ident', 'AB'], ['c_value_type', '[cc]'], ['c_value_type', '[dd:ee]'],59 ['parenthesis', ')']60 ])[0]), gametree.getJson({61 nodes: [62 {B: ['aa'], SZ: ['19']},63 {AB: ['cc', 'dd:ee']}64 ],65 subtrees: []66 }))67 })68 it('should parse variations', () => {69 assert.equal(70 gametree.getJson(sgf.parse('(;B[hh](;W[ii])(;W[hi]C[h]))')[0]),71 gametree.getJson({72 nodes: [{B: ['hh']}],73 subtrees: [74 {75 nodes: [{W: ['ii']}],76 subtrees: []77 },78 {79 nodes: [{W: ['hi'], C: ['h']}],80 subtrees: []81 }82 ]83 })84 )85 })86 it('should convert lower case properties', () => {87 assert.equal(88 gametree.getJson(sgf.parse('(;CoPyright[hello](;White[ii])(;White[hi]Comment[h]))')[0]),89 gametree.getJson({90 nodes: [{CP: ['hello']}],91 subtrees: [92 {93 nodes: [{W: ['ii']}],94 subtrees: []95 },96 {97 nodes: [{W: ['hi'], C: ['h']}],98 subtrees: []99 }100 ]101 })102 )103 })104 it('should parse a relatively complex file', () => {105 let contents = fs.readFileSync(__dirname + '/sgf/complex.sgf', 'utf8')106 let trees = sgf.parse(contents)107 assert.equal(trees.length, 1)108 })109 it('should ignore empty subtrees', () => {110 assert.equal(111 gametree.getJson(sgf.parse('(;B[hh]()(;W[ii])()(;W[hi]C[h]))')[0]),112 gametree.getJson({113 nodes: [{B: ['hh']}],114 subtrees: [115 {116 nodes: [{W: ['ii']}],117 subtrees: []118 },119 {120 nodes: [{W: ['hi'], C: ['h']}],121 subtrees: []122 }123 ]124 })125 )126 })127 })128 describe('encoding', () => {129 let languageMap = {130 'chinese': '围棋',131 'japanese': '囲碁',132 'korean': '바둑'133 }134 it('should be able to read out the CA property', () => {135 assert.equal(136 sgf.parse('(;CA[UTF-8])')[0].nodes[0].CA[0],137 'UTF-8'138 )139 })140 for (language in languageMap) {141 it('should be able to decode non-UTF-8 text nodes', () => {142 assert.equal(143 sgf.parseFile(util.format('%s/sgf/%s.sgf', __dirname, language))[0].nodes[2].C[0],144 util.format('%s is fun', languageMap[language])145 )146 })147 }148 it('should be able to go back and re-parse attributes set before CA', () => {149 assert.equal(150 sgf.parseFile(__dirname + '/sgf/chinese.sgf')[0].nodes[0].PW[0],151 '柯洁'152 )153 assert.equal(154 sgf.parseFile(__dirname + '/sgf/chinese.sgf')[0].nodes[0].PB[0],155 '古力'156 )157 })158 it('should ignore unknown encodings', () => {159 assert.notEqual(160 sgf.parseFile(__dirname + '/sgf/japanese_bad.sgf')[0].nodes[2].C[0],161 util.format('%s is fun', languageMap['japanese'])162 )163 })164 })165 describe('string2dates', () => {166 it('should parse comma-separated dates', () => {167 assert.deepEqual(sgf.string2dates('1996-12-27,1997-01-03'), [168 [1996, 12, 27], [1997, 1, 3]169 ])170 })171 it('should be able to handle empty strings', () => {172 assert.deepEqual(sgf.string2dates(''), [])173 })174 it('should handle short-hand notation', () => {175 assert.deepEqual(sgf.string2dates('1996-05,06'), [176 [1996, 5], [1996, 6]177 ])178 assert.deepEqual(sgf.string2dates('1996-05,06-01'), [179 [1996, 5], [1996, 6, 1]180 ])181 assert.deepEqual(sgf.string2dates('1996-05,1997'), [182 [1996, 5], [1997]183 ])184 assert.deepEqual(sgf.string2dates('1996-05-06,07,08'), [185 [1996, 5, 6], [1996, 5, 7], [1996, 5, 8]186 ])187 assert.deepEqual(sgf.string2dates('1996,1997'), [188 [1996], [1997]189 ])190 assert.deepEqual(sgf.string2dates('1996-12-27,28,1997-01-03,04'), [191 [1996, 12, 27], [1996, 12, 28], [1997, 1, 3], [1997, 1, 4]192 ])193 })194 })195 describe('dates2string', () => {196 it('should work', () => {197 assert.equal(sgf.dates2string([198 [1996, 5], [1996, 6]199 ]), '1996-05,06')200 assert.equal(sgf.dates2string([201 [1996, 5], [1996, 6, 1]202 ]), '1996-05,06-01')203 assert.equal(sgf.dates2string([204 [1996, 5], [1997]205 ]), '1996-05,1997')206 assert.equal(sgf.dates2string([207 [1996, 5, 6], [1996, 5, 7], [1996, 5, 8]208 ]), '1996-05-06,07,08')209 assert.equal(sgf.dates2string([210 [1996], [1997]211 ]), '1996,1997')212 assert.equal(sgf.dates2string([213 [1996, 12, 27], [1996, 12, 28], [1997, 1, 3], [1997, 1, 4]214 ]), '1996-12-27,28,1997-01-03,04')215 })216 it('should be able to handle empty strings', () => {217 assert.equal(sgf.dates2string([]), '')218 })219 it('should be inverse to string2dates', () => {220 assert.deepEqual(sgf.string2dates(sgf.dates2string([221 [1996, 5], [1996, 6]222 ])), [223 [1996, 5], [1996, 6]224 ])225 assert.deepEqual(sgf.string2dates(sgf.dates2string([226 [1996, 5, 6], [1996, 5, 7], [1996, 5, 8]227 ])), [228 [1996, 5, 6], [1996, 5, 7], [1996, 5, 8]229 ])230 assert.deepEqual(sgf.string2dates(sgf.dates2string([231 [1996], [1997]232 ])), [233 [1996], [1997]234 ])235 assert.deepEqual(sgf.string2dates(sgf.dates2string([236 [1996, 12, 27], [1996, 12, 28], [1997, 1, 3], [1997, 1, 4]237 ])), [238 [1996, 12, 27], [1996, 12, 28], [1997, 1, 3], [1997, 1, 4]239 ])240 assert.equal(sgf.dates2string(sgf.string2dates('1996-05,06')), '1996-05,06')241 assert.equal(sgf.dates2string(sgf.string2dates('1996-05-06,07,08')), '1996-05-06,07,08')242 assert.equal(sgf.dates2string(sgf.string2dates('1996,1997')), '1996,1997')243 assert.equal(sgf.dates2string(sgf.string2dates('1996-12-27,28,1997-01-03,04')), '1996-12-27,28,1997-01-03,04')244 })245 })246 describe('point2vertex', () => {247 it('should return [-1, -1] when passing string with length > 2', () => {248 assert.deepEqual(sgf.point2vertex(''), [-1, -1])249 assert.deepEqual(sgf.point2vertex('d'), [-1, -1])250 assert.deepEqual(sgf.point2vertex('blah'), [-1, -1])251 })252 it('should work', () => {253 assert.deepEqual(sgf.point2vertex('bb'), [1, 1])254 assert.deepEqual(sgf.point2vertex('jj'), [9, 9])255 assert.deepEqual(sgf.point2vertex('jf'), [9, 5])256 assert.deepEqual(sgf.point2vertex('fa'), [5, 0])257 assert.deepEqual(sgf.point2vertex('fA'), [5, 26])258 assert.deepEqual(sgf.point2vertex('AB'), [26, 27])259 })260 it('should be left inverse to vertex2point', () => {261 let tests = [[-1, -1], [10, 5], [9, 28], [30, 27], [0, 0]]262 tests.forEach(test => assert.deepEqual(sgf.point2vertex(sgf.vertex2point(test)), test))263 })264 })265 describe('vertex2point', () => {266 it('should return empty string when passing negative values', () => {267 assert.equal(sgf.vertex2point([-4, -5]), '')268 assert.equal(sgf.vertex2point([-4, 5]), '')269 assert.equal(sgf.vertex2point([4, -5]), '')270 })271 it('should return empty string when passing too big values', () => {272 assert.equal(sgf.vertex2point([100, 100]), '')273 assert.equal(sgf.vertex2point([100, 1]), '')274 assert.equal(sgf.vertex2point([1, 100]), '')275 })276 it('should work', () => {277 assert.equal(sgf.vertex2point([1, 1]), 'bb')278 assert.equal(sgf.vertex2point([9, 9]), 'jj')279 assert.equal(sgf.vertex2point([9, 5]), 'jf')280 assert.equal(sgf.vertex2point([5, 0]), 'fa')281 assert.equal(sgf.vertex2point([5, 26]), 'fA')282 assert.equal(sgf.vertex2point([26, 27]), 'AB')283 })284 it('should be left inverse to point2vertex', () => {285 let tests = ['', 'df', 'AB', 'fA', 'fa']286 tests.forEach(test => assert.equal(sgf.vertex2point(sgf.point2vertex(test)), test))287 })288 })289 describe('compressed2list', () => {290 it('should handle points normally', () => {291 assert.deepEqual(sgf.compressed2list('ce'), [sgf.point2vertex('ce')])292 assert.deepEqual(sgf.compressed2list('aa'), [sgf.point2vertex('aa')])293 assert.deepEqual(sgf.compressed2list('Az'), [sgf.point2vertex('Az')])294 })295 it('should handle one point compressions', () => {296 assert.deepEqual(sgf.compressed2list('ce:ce'), [sgf.point2vertex('ce')])297 assert.deepEqual(sgf.compressed2list('aa:aa'), [sgf.point2vertex('aa')])298 assert.deepEqual(sgf.compressed2list('Az:Az'), [sgf.point2vertex('Az')])299 })300 it('should handle compressions', () => {301 assert.deepEqual(sgf.compressed2list('aa:bb'), [[0, 0], [0, 1], [1, 0], [1, 1]])302 assert.deepEqual(sgf.compressed2list('bb:aa'), [[0, 0], [0, 1], [1, 0], [1, 1]])303 })304 })305 describe('stringify', () => {306 it('should produce some sgf', () => {307 let gametree = {308 nodes: [],309 subtrees: [310 {311 nodes: [312 {B: ['ee'], SZ: [19]},313 {W: ['dd']}314 ],315 subtrees: []316 }317 ]318 }319 let content = [320 '(;B[ee]SZ[19]',321 ';W[dd]',322 ')'323 ].join(helper.linebreak)324 assert.equal(sgf.stringify(gametree), content)325 })326 it('should handle empty properties', () => {327 let gametree = {328 nodes: [],329 subtrees: [330 {331 nodes: [{HS: []}],332 subtrees: []333 }334 ]335 }336 assert.equal(sgf.stringify(gametree), `(;HS[]${helper.linebreak})`)337 })338 it('should handle variations', () => {339 let gametree = {340 nodes: [],341 subtrees: [342 {343 nodes: [{B: ['hh']}],344 subtrees: [345 {346 nodes: [{W: ['ii']}],347 subtrees: []348 },349 {350 nodes: [{W: ['hi'], C: ['h']}],351 subtrees: []352 }353 ]354 }355 ]356 }357 let content = [358 '(;B[hh]',359 '(;W[ii]',360 ')(;W[hi]C[h]',361 '))'362 ].join(helper.linebreak)363 assert.equal(sgf.stringify(gametree), content)364 })365 })366 describe('escapeString', () => {367 it('should escape backslashes', () => {368 assert.equal(sgf.escapeString('hello\\world'), 'hello\\\\world')369 })370 it('should escape right brackets', () => {371 assert.equal(sgf.escapeString('hello]world'), 'hello\\]world')372 })373 it('should not escape left brackets', () => {374 assert.equal(sgf.escapeString('hello[world'), 'hello[world')375 })376 })377 describe('unescapeString', () => {378 it('should ignore escaped linebreaks', () => {379 assert.equal(sgf.unescapeString('hello\\\nworld'), 'helloworld')380 assert.equal(sgf.unescapeString('hello\\\rworld'), 'helloworld')381 assert.equal(sgf.unescapeString('hello\\\n\rworld'), 'helloworld')382 assert.equal(sgf.unescapeString('hello\\\r\nworld'), 'helloworld')383 })384 it('should unescape backslashes and right brackets', () => {385 assert.equal(sgf.unescapeString('hello wor\\]ld'), 'hello wor]ld')386 assert.equal(sgf.unescapeString('hello wor\\\\ld'), 'hello wor\\ld')387 assert.equal(sgf.unescapeString('he\\]llo wor\\\\ld'), 'he]llo wor\\ld')388 })389 it('should ignore other backslashes', () => {390 assert.equal(sgf.unescapeString('h\\e\\llo world'), 'hello world')391 assert.equal(sgf.unescapeString('hello\\ world'), 'hello world')392 })393 it('should normalize line endings', () => {394 assert.equal(sgf.unescapeString('hello\nworld'), 'hello\nworld')395 assert.equal(sgf.unescapeString('hello\r\nworld'), 'hello\nworld')396 assert.equal(sgf.unescapeString('hello\n\rworld'), 'hello\nworld')397 assert.equal(sgf.unescapeString('hello\rworld'), 'hello\nworld')398 })399 it('should be left inverse to escapeString', () => {400 let texts = [401 'He()llo Wor\\\\[Foo;Bar]ld\\',402 'Hello\\! []World!'403 ]404 texts.forEach(text => {405 assert.equal(sgf.unescapeString(sgf.escapeString(text)), text)406 })407 })408 })...

Full Screen

Full Screen

groups.js

Source:groups.js Github

copy

Full Screen

...38 , users39 , isAddedDevice40 , devices41 , action) {42 function dates2String(dates) {43 return dates.map(function(date) {44 return {45 start: date.start.toJSON()46 , stop: date.stop.toJSON()47 }48 })49 }50 pushdev.send([51 wireutil.global52 , wireutil.envelope(53 new wire.GroupChangeMessage(54 new wire.GroupField(55 group.id56 , group.name57 , group.class58 , group.privilege59 , group.owner60 , dates2String(group.dates)61 , group.duration62 , group.repetitions63 , group.devices64 , group.users65 , group.state66 , group.isActive67 )68 , action69 , subscribers70 , isChangedDates71 , isChangedClass72 , isAddedUser73 , users74 , isAddedDevice...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2var date = new Date();3var date2 = new Date();4var date3 = new Date();5var date4 = new Date();6var date5 = new Date();7var date6 = new Date();8var date7 = new Date();9var date8 = new Date();10var date9 = new Date();11var date10 = new Date();12var date11 = new Date();13var date12 = new Date();14var date13 = new Date();15var date14 = new Date();16var date15 = new Date();17var date16 = new Date();18var date17 = new Date();19var date18 = new Date();20var date19 = new Date();21var date20 = new Date();22var date21 = new Date();23var date22 = new Date();24var date23 = new Date();25var date24 = new Date();26var date25 = new Date();27var date26 = new Date();28var date27 = new Date();29var date28 = new Date();30var date29 = new Date();31var date30 = new Date();32var date31 = new Date();33var date32 = new Date();34var date33 = new Date();35var date34 = new Date();36var date35 = new Date();37var date36 = new Date();38var date37 = new Date();39var date38 = new Date();40var date39 = new Date();41var date40 = new Date();42var date41 = new Date();43var date42 = new Date();44var date43 = new Date();45var date44 = new Date();46var date45 = new Date();47var date46 = new Date();48var date47 = new Date();49var date48 = new Date();50var date49 = new Date();51var date50 = new Date();52var date51 = new Date();53var date52 = new Date();54var date53 = new Date();55var date54 = new Date();56var date55 = new Date();57var date56 = new Date();58var date57 = new Date();59var date58 = new Date();60var date59 = new Date();61var date60 = new Date();62var date61 = new Date();63var date62 = new Date();64var date63 = new Date();65var date64 = new Date();66var date65 = new Date();67var date66 = new Date();68var date67 = new Date();69var date68 = new Date();70var date69 = new Date();

Full Screen

Using AI Code Generation

copy

Full Screen

1var date = new Date();2var date2 = new Date();3date2.setDate(date2.getDate() + 1);4var date3 = new Date();5date3.setDate(date3.getDate() + 2);6var date4 = new Date();7date4.setDate(date4.getDate() + 3);8var date5 = new Date();9date5.setDate(date5.getDate() + 4);10var date6 = new Date();11date6.setDate(date6.getDate() + 5);12var date7 = new Date();13date7.setDate(date7.getDate() + 6);14var date8 = new Date();15date8.setDate(date8.getDate() + 7);16var date9 = new Date();17date9.setDate(date9.getDate() + 8);18var date10 = new Date();19date10.setDate(date10.getDate() + 9);20var date11 = new Date();21date11.setDate(date11.getDate() + 10);22var date12 = new Date();23date12.setDate(date12.getDate() + 11);24var date13 = new Date();25date13.setDate(date13.getDate() + 12);26var date14 = new Date();27date14.setDate(date14.getDate() + 13);28var date15 = new Date();29date15.setDate(date15.getDate() + 14);30var date16 = new Date();31date16.setDate(date16.getDate() + 15);32var date17 = new Date();33date17.setDate(date17.getDate() + 16);34var date18 = new Date();35date18.setDate(date18.getDate() + 17);36var date19 = new Date();37date19.setDate(date19.getDate() + 18);38var date20 = new Date();39date20.setDate(date20.getDate() + 19);40var date21 = new Date();41date21.setDate(date21.getDate() + 20);42var date22 = new Date();43date22.setDate(date22.getDate() + 21);44var date23 = new Date();45date23.setDate(date23.getDate() + 22);46var date24 = new Date();47date24.setDate(date24.getDate() + 23);48var date25 = new Date();49date25.setDate(date25.getDate() + 24);50var date26 = new Date();51date26.setDate(date26.getDate() + 25);52var date27 = new Date();53date27.setDate(date27.getDate() + 26);54var date28 = new Date();55date28.setDate(date28.getDate() + 27);

Full Screen

Using AI Code Generation

copy

Full Screen

1var utils = require('devicefarmer-stf-utils');2var date = new Date();3console.log(utils.dates2String(date));4var utils = require('devicefarmer-stf-utils');5var date = new Date();6console.log(utils.dates2String(date));7var utils = require('devicefarmer-stf-utils');8var date = new Date();9console.log(utils.dates2String(date));10var utils = require('devicefarmer-stf-utils');11var date = new Date();12console.log(utils.dates2String(date));13var utils = require('devicefarmer-stf-utils');14var date = new Date();15console.log(utils.dates2String(date));16var utils = require('devicefarmer-stf-utils');17var date = new Date();18console.log(utils.dates2String(date));19var utils = require('devicefarmer-stf-utils');20var date = new Date();21console.log(utils.dates2String(date));22var utils = require('devicefarmer-stf-utils');23var date = new Date();24console.log(utils.dates2String(date));25var utils = require('devicefarmer-stf-utils');26var date = new Date();27console.log(utils.dates2String(date));28var utils = require('devicefarmer-stf-utils');29var date = new Date();30console.log(utils.dates2String(date));

Full Screen

Using AI Code Generation

copy

Full Screen

1var devicefarmer = require('devicefarmer-stf');2var dates2String = devicefarmer.dates2String;3var date = new Date();4var dateString = dates2String(date);5console.log(dateString);6var devicefarmer = require('devicefarmer-stf');7var dates2String = devicefarmer.dates2String;8var date = new Date();9var dateString = dates2String(date);10console.log(dateString);11var devicefarmer = require('devicefarmer-stf');12var dates2String = devicefarmer.dates2String;13var date = new Date();14var dateString = dates2String(date);15console.log(dateString);16var devicefarmer = require('devicefarmer-stf');17var dates2String = devicefarmer.dates2String;18var date = new Date();19var dateString = dates2String(date);20console.log(dateString);21var devicefarmer = require('devicefarmer-stf');22var dates2String = devicefarmer.dates2String;23var date = new Date();24var dateString = dates2String(date);25console.log(dateString);26var devicefarmer = require('devicefarmer-stf');27var dates2String = devicefarmer.dates2String;28var date = new Date();29var dateString = dates2String(date);30console.log(dateString);31var devicefarmer = require('devicefarmer-stf');32var dates2String = devicefarmer.dates2String;33var date = new Date();34var dateString = dates2String(date);35console.log(dateString);36var devicefarmer = require('devicefarmer-stf');

Full Screen

Using AI Code Generation

copy

Full Screen

1var utils = require('devicefarmer-stf-utils');2var dates = utils.dates2String(new Date());3console.log(dates);4{ date: '2016-07-21',5 datetime: '2016-07-21 16:09:21' }6dates2String(date)7getDeviceType(device)8getDeviceName(device)9getAndroidVersion(device)10getDeviceModel(device)11getDeviceManufacturer(device)12getDeviceScreenResolution(device)13getDeviceScreenSize(device)14getDeviceScreenSizeInInches(device)15getDeviceScreenSizeInCentimeters(device)16getDeviceScreenSizeInMillimeters(device)17getDeviceScreenSizeInPixels(device)

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