Comparing version 0.0.3 to 0.0.4
@@ -5,2 +5,3 @@ 'use strict'; | ||
var config = require('../conf'); | ||
var format = require('../utils/format'); | ||
var fs = require('fs-extra'); | ||
@@ -104,6 +105,16 @@ var Handlebars = require('./renderers/handlebars'); | ||
if(err){ | ||
return callback(strings.errors.client.serverSideRenderingFail, !!options.disableFailoverRendering ? '' : self.renderer.getUnrenderedComponent(href)); | ||
if(err){ | ||
var errorDescription = strings.errors.client.serverSideRenderingFail; | ||
if(!!options.disableFailoverRendering){ | ||
return callback(errorDescription, ''); | ||
} | ||
fs.readFile(path.resolve(__dirname, '../registry/public/oc-client.min.js'), 'utf-8', function(err, clientJs){ | ||
var clientSideHtml = format('<script class="ocClientScript">{0}</script>{1}', clientJs, self.renderer.getUnrenderedComponent(href)); | ||
return callback(errorDescription, clientSideHtml); | ||
}); | ||
} else { | ||
apiResponse = JSON.parse(apiResponse); | ||
@@ -134,2 +145,3 @@ | ||
}); | ||
} | ||
}); | ||
@@ -136,0 +148,0 @@ }; |
@@ -32,2 +32,5 @@ 'use strict'; | ||
// Setup the precommit hook | ||
grunt.registerTask('hooks', ['githooks:all']); | ||
// test | ||
@@ -34,0 +37,0 @@ grunt.registerTask('test', ['jshint:all', 'mochaTest:unit', 'mochaTest:acceptance']); |
{ | ||
"name": "oc", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "An experimental framework to develop and distribute html components", | ||
@@ -27,2 +27,3 @@ "main": "index.js", | ||
"grunt-contrib-jshint": "0.10.0", | ||
"grunt-githooks": "0.3.1", | ||
"grunt-mocha-test": "0.6.2", | ||
@@ -29,0 +30,0 @@ "load-grunt-tasks": "0.6.0", |
@@ -79,2 +79,3 @@ 'use strict'; | ||
var $component, | ||
$clientScript, | ||
error; | ||
@@ -88,2 +89,3 @@ | ||
$component = $('oc-component'); | ||
$clientScript = $('script.ocClientScript'); | ||
done(); | ||
@@ -93,2 +95,6 @@ }); | ||
it('should include the client-side rendering script', function(){ | ||
expect($clientScript).to.have.length.above(0); | ||
}); | ||
it('should return non rendered contents', function(){ | ||
@@ -95,0 +101,0 @@ expect($component).to.exist(); |
@@ -23,3 +23,3 @@ 'use strict'; | ||
publishFacade({ componentPath: path.resolve('test/fixtures/components/hello-world/') }); | ||
logs = consoleMock.get(); | ||
logs = consoleMock.get(); | ||
}; | ||
@@ -51,3 +51,2 @@ | ||
sinon.stub(registry, 'get').yields(null, ['http://www.api.com']); | ||
execute(); | ||
}); | ||
@@ -60,2 +59,6 @@ | ||
it('should show a message', function(){ | ||
sinon.stub(local, 'package').yields('the component is not valid'); | ||
execute(); | ||
local.package.restore(); | ||
expect(logs[0]).to.include('Packaging -> '); | ||
@@ -85,14 +88,20 @@ expect(logs[0]).to.include('components/hello-world/_package'); | ||
beforeEach(function(){ | ||
sinon.stub(local, 'package').yields(null, { | ||
name: 'hello-world', | ||
version: '1.0.0' | ||
}); | ||
}); | ||
afterEach(function(){ | ||
local.package.restore(); | ||
}); | ||
describe('when creating tar.gz archive', function(){ | ||
beforeEach(function(){ | ||
sinon.stub(local, 'package').yields(null, { | ||
name: 'hello-world', | ||
version: '1.0.0' | ||
}); | ||
sinon.stub(local, 'compress').yields(null); | ||
sinon.stub(local, 'compress').yields(null); | ||
}); | ||
afterEach(function(){ | ||
local.package.restore(); | ||
local.compress.restore(); | ||
@@ -102,2 +111,6 @@ }); | ||
it('should show a message', function(){ | ||
sinon.stub(registry, 'putComponent').yields('blabla'); | ||
execute(); | ||
registry.putComponent.restore(); | ||
expect(logs[1]).to.include('Compressing -> '); | ||
@@ -112,4 +125,5 @@ expect(logs[1]).to.include('components/hello-world/package.tar.gz'); | ||
execute(); | ||
registry.putComponent.restore(); | ||
expect(logs[2]).to.include('Publishing -> '); | ||
registry.putComponent.restore(); | ||
}); | ||
@@ -116,0 +130,0 @@ |
170166
75
4064
8