Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the container options on package to avoid container to be shown on... #44

Merged
merged 1 commit into from
Mar 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ var Client = function(conf){
href: href,
key: key,
version: apiResponse.version,
templateType: apiResponse.template.type
templateType: apiResponse.template.type,
container: (apiResponse.container === false) ? false : true
};

self.renderTemplate(template, data, options, callback);
Expand All @@ -184,6 +185,11 @@ var Client = function(conf){
};

this.getRenderedComponent = function(data){

if(!data.container){
return data.html;
}

var random = Math.floor(Math.random()*9999999999);

return format('<oc-component href="{0}" data-hash="{1}" id="{2}" data-rendered="true" data-version="{3}">{4}</oc-component>',
Expand Down
3 changes: 2 additions & 1 deletion registry/routes/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ module.exports = function(conf, repository){
href: componentHref,
key: key,
version: component.version,
templateType: component.oc.files.template.type
templateType: component.oc.files.template.type,
container: (component.oc.container === false) ? false : true
};

var returnResult = function(template){
Expand Down
38 changes: 36 additions & 2 deletions test/acceptance/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('registry', function(){
registry.close(done);
});

describe('when initialised with invalid configuration', function(){
describe('when initialised with not valid configuration', function(){

it('should throw an error', function(done){
var f = function throwsWithNoArgs() {
Expand Down Expand Up @@ -57,7 +57,11 @@ describe('registry', function(){
});

it('should list the components', function(){
expect(result.components).to.eql(['http://localhost:3030/hello-world', 'http://localhost:3030/oc-client']);
expect(result.components).to.eql([
'http://localhost:3030/hello-world',
'http://localhost:3030/no-container',
'http://localhost:3030/oc-client'
]);
});
});

Expand All @@ -81,6 +85,7 @@ describe('registry', function(){

it('should respond with the rendered template', function(){
expect(result.html).to.exist;
expect(result.html).to.match(/<oc-component (.*?)>Hello world!<\/oc-component>/g);
});

it('should respond with proper render type', function(){
Expand Down Expand Up @@ -113,4 +118,33 @@ describe('registry', function(){
});
});
});

describe('GET /no-container', function(){

describe('when Accept header not specified', function(){

var url = 'http://localhost:3030/no-container',
result;

before(function(done){
request(url, function(err, res){
result = JSON.parse(res);
done();
});
});

it('should respond with the correct href', function(){
expect(result.href).to.eql('http://localhost:3030/no-container');
});

it('should respond with the rendered template without the outer container', function(){
expect(result.html).to.exist;
expect(result.html).to.eql('Hello world!');
});

it('should respond with proper render type', function(){
expect(result.renderMode).to.equal('rendered');
});
});
});
});
1 change: 1 addition & 0 deletions test/fixtures/components/no-container/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_package
17 changes: 17 additions & 0 deletions test/fixtures/components/no-container/_package/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "no-container",
"description": "",
"version": "1.0.0",
"repository": "",
"oc": {
"container": false,
"parameters": {},
"files": {
"template": {
"type": "handlebars",
"hashKey": "18e2619ff1d06451883f21656affd4c6f02b1ed1",
"src": "template.js"
}
}
}
}
1 change: 1 addition & 0 deletions test/fixtures/components/no-container/_package/template.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions test/fixtures/components/no-container/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "no-container",
"description": "",
"version": "1.0.0",
"repository": "",
"oc": {
"container": false,
"files": {
"template": {
"src": "template.html",
"type": "handlebars"
}
}
}
}
1 change: 1 addition & 0 deletions test/fixtures/components/no-container/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello world!
5 changes: 3 additions & 2 deletions test/unit/registry-domain-repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('registry : domain : repository', function(){
var componentsCacheBaseResponse = {
components: {
'hello-world': ['1.0.0'],
'no-container': ['1.0.0'],
'oc-client': ['1.0.0']
}
};
Expand All @@ -78,7 +79,7 @@ describe('registry : domain : repository', function(){
});

it('should list the components', function(){
expect(response.result).to.eql(['hello-world', 'oc-client']);
expect(response.result).to.eql(['hello-world', 'no-container', 'oc-client']);
});
});

Expand Down Expand Up @@ -249,7 +250,7 @@ describe('registry : domain : repository', function(){
});

it('should list the components', function(){
expect(response.result).to.eql(['hello-world', 'oc-client']);
expect(response.result).to.eql(['hello-world', 'no-container', 'oc-client']);
});
});

Expand Down