* @param {string} opt.action 'start' or 'stop'. * @param {string} opt.outputType Optional. 'clipboard' or 'console'. * @param {Object} opt.printObjectOpt Optional. The opt of `testHelper.printObject`.
(opt)
| 548 | * @param {Object} opt.printObjectOpt Optional. The opt of `testHelper.printObject`. |
| 549 | */ |
| 550 | function recordInputs(opt) { |
| 551 | var action = opt.action; |
| 552 | assert( |
| 553 | NAMES_RECORD_INPUTS_ACTION_START.indexOf(action) >= 0 |
| 554 | || NAMES_RECORD_INPUTS_ACTION_STOP.indexOf(action) >= 0, |
| 555 | 'Invalide recordInputs action: ' + action + '. Should be ' |
| 556 | + NAMES_RECORD_INPUTS_ACTION_START + ' ' + NAMES_RECORD_INPUTS_ACTION_STOP |
| 557 | ); |
| 558 | if (NAMES_RECORD_INPUTS_ACTION_START.indexOf(action) >= 0) { |
| 559 | _inputsRecord = { |
| 560 | version: _INPUTS_RECORD_VERSION, |
| 561 | startTime: +(new Date()), |
| 562 | operations: [], |
| 563 | }; |
| 564 | } |
| 565 | else if (NAMES_RECORD_INPUTS_ACTION_STOP.indexOf(action) >= 0) { |
| 566 | if (_inputsRecord == null) { |
| 567 | console.error( |
| 568 | 'Inputs record is not started. Please call' |
| 569 | + ' `chart.__testHelper.recordInputs({action: "start"})` first.' |
| 570 | ); |
| 571 | return; |
| 572 | } |
| 573 | _inputsRecord.endTime = +(new Date()); |
| 574 | var inputsRecord = _inputsRecord; |
| 575 | _inputsRecord = null; |
| 576 | outputInputsRecord(inputsRecord); |
| 577 | return inputsRecord; |
| 578 | } |
| 579 | |
| 580 | function outputInputsRecord(record) { |
| 581 | if (opt.outputType === 'console') { |
| 582 | console.log(testHelper.printObject(record, opt.printObjectOpt)); |
| 583 | } |
| 584 | else { |
| 585 | testHelper.clipboard(record, opt.printObjectOpt); |
| 586 | } |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | function replayInputs(inputsRecord) { |
| 591 | assert( |
nothing calls this directly
no test coverage detected
searching dependent graphs…