Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #386 from Financial-Times/deprecate-expanded
Browse files Browse the repository at this point in the history
Deprecate the expanded property for demos
  • Loading branch information
onishiweb authored Aug 31, 2016
2 parents 7b52d18 + 37e5893 commit 4ab0da3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 18 deletions.
11 changes: 11 additions & 0 deletions lib/tasks/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ module.exports.origamiJson = function() {
if (fs.existsSync(origamiJsonPath)) {
log.secondary('Verifying your origami.json');
const origamiJson = JSON.parse(fs.readFileSync(origamiJsonPath, 'utf8'));
const componentDemos = origamiJson.demos;
if (!origamiJson.description) {
result.push('A non-empty description property is required');
}
Expand All @@ -229,6 +230,16 @@ module.exports.origamiJson = function() {
result.push('The supportStatus property must be set to either "active", "maintained", "deprecated", "dead" or "experimental"');
}

if (componentDemos) {
const hasExpanded = componentDemos.some(function(demo) {
return demo.hasOwnProperty('expanded');
});

if (hasExpanded) {
result.push('The expanded property has been deprecated. Use the "hidden" property when a demo should not appear in the Registry.');
}
}

if (result.length > 0) {
for (let i = 0; i < result.length; i++) {
log.secondaryError(result[i]);
Expand Down
2 changes: 0 additions & 2 deletions test/fixtures/o-test/origami.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
"name": "test1",
"template": "demos/src/test1.mustache",
"path": "/demos/test1.html",
"expanded": true,
"description": "First test"
},
{
"name": "test2",
"template": "demos/src/test2.mustache",
"path": "/demos/test2.html",
"expanded": false,
"description": "Second test"
}
],
Expand Down
50 changes: 34 additions & 16 deletions test/tasks/verify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,39 @@ describe('Verify task', function() {
});
});

it('should run origamiJson check', function(done) {
verify.origamiJson()
.then(function(verifiedOrigamiJson) {
expect(verifiedOrigamiJson.length).to.be(0);
fs.writeFileSync('origami.json', JSON.stringify({}), 'utf8');
return verify.origamiJson();
})
.then(function() {}, function(verifiedOrigamiJson) {
expect(verifiedOrigamiJson).to.contain('A non-empty description property is required');
expect(verifiedOrigamiJson).to.contain('The origamiType property needs to be set to either "module" or "service"');
expect(verifiedOrigamiJson).to.contain('A non-empty description property is required');
expect(verifiedOrigamiJson).to.contain('The origamiVersion property needs to be set to 1');
expect(verifiedOrigamiJson).to.contain('The support property must be an email or url to an issue tracker for this module');
expect(verifiedOrigamiJson).to.contain('The supportStatus property must be set to either "active", "maintained", "deprecated", "dead" or "experimental"');
done();
});
describe('verify origami.json', function() {
it('should run origami.json check successfully', function(done) {
verify.origamiJson()
.then(function(verifiedOrigamiJson) {
expect(verifiedOrigamiJson.length).to.be(0);
done();
});
});

it('should fail with an empty origami.json', function(done) {
fs.writeFileSync('origami.json', JSON.stringify({}), 'utf8');

verify.origamiJson()
.then(function() {}, function(verifiedOrigamiJson) {
expect(verifiedOrigamiJson).to.contain('A non-empty description property is required');
expect(verifiedOrigamiJson).to.contain('The origamiType property needs to be set to either "module" or "service"');
expect(verifiedOrigamiJson).to.contain('A non-empty description property is required');
expect(verifiedOrigamiJson).to.contain('The origamiVersion property needs to be set to 1');
expect(verifiedOrigamiJson).to.contain('The support property must be an email or url to an issue tracker for this module');
expect(verifiedOrigamiJson).to.contain('The supportStatus property must be set to either "active", "maintained", "deprecated", "dead" or "experimental"');
done();
});
});

it('should fail when an expanded property is found for a demo', function(done) {
fs.writeFileSync('origami.json', JSON.stringify({ demos: [ { expanded: false }, { expanded: true } ] }), 'utf8');

verify.origamiJson()
.then(function() {}, function(verifiedOrigamiJson) {
expect(verifiedOrigamiJson).to.contain('The expanded property has been deprecated. Use the "hidden" property when a demo should not appear in the Registry.');
done();
});
});
});

});

0 comments on commit 4ab0da3

Please sign in to comment.