-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
63 lines (51 loc) · 1.32 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict';
require('mocha');
var assert = require('assert');
var Prompt = require('./');
describe('enquirer-prompt-input', function() {
it('should export a function', function() {
assert.equal(typeof Prompt, 'function');
});
it('should throw an error when no args are passed', function() {
assert.throws(function() {
Prompt();
});
});
it('should throw an error when invalid args are passed', function() {
assert.throws(function() {
Prompt(null);
});
});
it('should return an answers object on run', function(cb) {
var prompt = new Prompt({
name: 'color',
message: 'What is your favorite color?',
});
var unmute = prompt.mute();
prompt.on('ask', function() {
prompt.rl.emit('line', 'blue');
});
prompt.run()
.then(function(answer) {
assert.deepEqual(answer, 'blue');
unmute();
cb();
})
.catch(cb);
});
it('should return an answers object on ask', function(cb) {
var prompt = new Prompt({
name: 'color',
message: 'What is your favorite color?',
});
var unmute = prompt.mute();
prompt.on('ask', function() {
prompt.rl.emit('line', 'blue');
});
prompt.ask(function(answer) {
assert.deepEqual(answer, 'blue');
unmute();
cb();
});
});
});