forked from ionic-team/ionic-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprompt.spec.js
More file actions
36 lines (32 loc) · 1.15 KB
/
prompt.spec.js
File metadata and controls
36 lines (32 loc) · 1.15 KB
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
'use strict';
var prompt = require('prompt');
var promptUtil = require('../../lib/utils/prompt');
describe('prompt function', function() {
it('should pass the prompt callback value to the resolved promise', function(done) {
spyOn(prompt, 'get').andCallFake(function(schema, callback) {
callback(null, 1000);
});
promptUtil.prompt({}, {}).then(function(value) {
expect(value).toEqual(1000);
done();
});
});
it('should reject the promise with the error if an error occurs with a msg not equal to "cancelled"', function(done) {
spyOn(prompt, 'get').andCallFake(function(schema, callback) {
callback({ message: 'error happened' }, 1000);
});
promptUtil.prompt({}, {}).catch(function(value) {
expect(value).toEqual({ message: 'error happened' });
done();
});
});
it('should reject the promise with false if an error occurs with msg canceled', function(done) {
spyOn(prompt, 'get').andCallFake(function(schema, callback) {
callback({ message: 'canceled' }, 1000);
});
promptUtil.prompt({}, {}).catch(function(value) {
expect(value).toEqual(false);
done();
});
});
});