forked from ionic-team/ionic-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserve.spec.js
More file actions
84 lines (71 loc) · 1.99 KB
/
serve.spec.js
File metadata and controls
84 lines (71 loc) · 1.99 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
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
var IonicAppLib = require('ionic-app-lib'),
IonicProject = IonicAppLib.project,
Serve = IonicAppLib.serve,
Q = require('q'),
rewire = require('rewire');
var argv = {
_: ['--livereload'],
nogulp: false
}
describe('Serve', function() {
var serveTask;
beforeEach(function() {
serveTask = rewire('../lib/ionic/serve');
});
it('should have serve defined', function() {
expect(serveTask).toBeDefined();
});
it('should use connect live reload port from env var', function(done) {
spyOn(IonicProject, 'load').andReturn({});
spyOn(Serve, 'loadSettings').andReturn({});
spyOn(Serve, 'getAddress').andReturn(Q());
spyOn(Serve, 'checkPorts');
spyOn(Serve, 'start');
spyOn(Serve, 'showFinishedServeMessage');
spyOn(process, 'cwd').andReturn('/ionic/app/path');
process.env = { CONNECT_LIVE_RELOAD_PORT: 5000 };
var serve = new serveTask.IonicTask();
var options = {
appDirectory: '/ionic/app/path',
liveReloadPort: 5000,
nogulp: false
};
Q()
.then(function(){
return serve.run({}, argv);
})
.then(function() {
expect(Serve.start).toHaveBeenCalledWith(options);
})
.catch(function(ex){
expect('this').toBe(ex.stack);
})
.fin(done);
});
it('should use connect live reload port from env var', function(done) {
spyOn(IonicProject, 'load').andReturn({
get: function() {
return false;
}
});
process.env = {};
spyOn(Serve, 'getAddress').andReturn(Q());
spyOn(Serve, 'checkPorts');
spyOn(Serve, 'start');
spyOn(Serve, 'showFinishedServeMessage');
spyOn(process, 'cwd').andReturn('/ionic/app/path');
var serve = new serveTask.IonicTask();
Q()
.then(function(){
return serve.run({}, argv);
})
.then(function() {
var calls = Serve.start.calls[0].args[0];
expect(calls.liveReloadPort).toBe(35729);
})
.catch(function(ex){
expect('this').toBe(ex.stack);
})
.fin(done);
});
});