Created
December 29, 2015 03:21
-
-
Save y2468101216/0f301d4533c4f8ba0325 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var readline = require('readline'); | |
var rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
var readlineClass = function () { | |
this.monkKeyboard = function (robot,importString) { | |
rl.on('pause', function () { | |
Console.log('Readline pause'); | |
robot.typeString(importString); | |
robot.keyTap("enter"); | |
}); | |
} | |
this.enterPackagePackageNumber = function (callback) { | |
rl.question("請輸入補充包或者預組編號:", function (answer) { | |
// TODO: Log the answer in a database | |
callback(answer); | |
rl.close(); | |
}); | |
} | |
} | |
module.exports = readlineClass; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert'); | |
var robot = require('robotjs'); | |
var readline = require(__dirname + '/../../../bin/parse/readlineClass.js'); | |
var readlineTest = new readline(); | |
describe('readlineSyncTest', function () { | |
it('enterPackagePackageNumber', function (done) { | |
readlineTest.monkKeyboard(robot, 'S05'); | |
readlineTest.enterPackagePackageNumber(function(actual){ | |
assert.equal(actual, 'S05'); | |
done() | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment