UNPKG

pp-parachute

Version:
81 lines (70 loc) 2.65 kB
var Environment = require('../../application/environment'); var Application = require('../../application/application'); var ParachuteBase = require('../../application/parachute_base'); var Promise = require('bluebird'); describe('application basics', function () { it('should export application', function () { expect(typeof Application).toBe('function'); }); beforeEach(function () { this.application = new Application('test app'); }); it('should be an instance of ParachuteBase', function() { expect(this.application instanceof ParachuteBase).toBe(true); }); it('should add an environment', function () { var env = new Environment('test'); this.application.useEnvironment(env); expect(this.application.environments['test']).toBe(env); }); it('should handle many environments', function () { var envs = []; for (var i = 0; i < 10; i++) { var env = new Environment('test' + i); envs.push(env); this.application.useEnvironment(env); } for (i = 0; i < 10; i++) { expect(this.application.environments['test' + i]).toBe(envs[i]); } }); it('should build an environment', function (done) { var env = new Environment('test'); var called = false; env.build = function () { called = true; return Promise.resolve(); }; this.application.useEnvironment(env); this.application.build(env.name).then(function () { expect(called).toBe(true); done(); }); }); it('should watch an environment', function (done) { var env = new Environment('test'); env.watch = function() { return Promise.resolve(); }; spyOn(env, 'watch').and.callThrough(); this.application.useEnvironment(env); this.application.watch(env).then(function () { expect(env.watch.calls.count()).toBe(1); done(); }) }); it('should be all environments base parent', function () { var env = new Environment('test'); this.application.useEnvironment(env); expect(env.parent).toBe(this.application); }); it('should have its root path set correctly', function () { expect(this.application.rootPath).toBe(__dirname); }); it('should not build unregistered environments', function(done) { this.application.build('not_here').catch(function(e) { expect(e).toBe('Environment not_here is not registered'); done(); }); }); });