Updates for testsuite

This commit is contained in:
Kamil Burzynski 2016-02-09 18:19:59 +01:00
parent 34f30d9e66
commit c5e644626a
2 changed files with 13 additions and 8 deletions

View File

@ -60,6 +60,7 @@ class ServerlessState {
set(data) {
this.meta = data.meta ? this.meta.set(data.meta) : this.meta;
this.project = data.project ? this._S.getProject().set(data.project, { deep: true }) : this._S.getProject();
return this;
}

View File

@ -5,6 +5,7 @@
*/
let Serverless = require('../../../lib/Serverless.js'),
Project = require('../../../lib/ServerlessProject'),
path = require('path'),
utils = require('../../../lib/utils/index'),
assert = require('chai').assert,
@ -24,9 +25,10 @@ describe('Test Serverless State Class', function() {
process.chdir(projPath);
// Instantiate Serverless
serverless = new Serverless({
interactive: false,
projectPath: projPath
let project = new Project( projPath );
project.load();
serverless = new Serverless( project, {
interactive: false
});
return serverless.init()
@ -73,7 +75,7 @@ describe('Test Serverless State Class', function() {
let clone = instance.get();
clone.project.name = 'newProject';
instance.set(clone);
assert.equal(true, instance.project.name === 'newProject');
assert.equal(true, instance._S.getProject().name === 'newProject');
done();
});
@ -225,9 +227,10 @@ describe('Test Serverless State Class', function() {
it('Set Assets', function(done) {
let project = new instance._S.classes.Project(instance._S);
project.name = 'testProject';
instance.setAsset(project);
//TODO
//let project = new instance._S.classes.Project(".");
//project.name = 'testProject';
//instance.setAsset(project);
let component = new instance._S.classes.Component(instance._S, { sPath: 'testComponent' });
component.name = 'testComponent';
@ -241,7 +244,8 @@ describe('Test Serverless State Class', function() {
endpoint.path = 'test/endpoint';
instance.setAsset(endpoint);
assert.equal(true, instance.project.name === 'testProject');
// TODO
//assert.equal(true, instance._S.getProject().name === 'testProject');
assert.equal(true, typeof instance.project.components[component.name] !== 'undefined');
assert.equal(true, typeof instance.project.components[component.name].functions[func._config.sPath] !== 'undefined');
assert.equal(true, instance.project.components[component.name].functions[func._config.sPath].endpoints.length > 0);