From 4e41f96d89d08bd6319d0a3c6439252f002b04d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Fri, 8 Apr 2016 14:42:37 +0200 Subject: [PATCH] Add "languages" property to all json files for multilingual book --- lib/output/base.js | 2 +- test/output-json.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/output/base.js b/lib/output/base.js index d513d71c2..b60edb16b 100644 --- a/lib/output/base.js +++ b/lib/output/base.js @@ -240,7 +240,7 @@ Output.prototype.getContext = function() { output: this.getSelfContext() }, this.book.getContext(), - this.book.langs.getContext(), + (this.book.isLanguageBook()? this.book.parent: this.book).langs.getContext(), this.book.summary.getContext(), this.book.glossary.getContext(), this.book.config.getContext(), diff --git a/test/output-json.js b/test/output-json.js index 1006dab26..cb2911935 100644 --- a/test/output-json.js +++ b/test/output-json.js @@ -41,8 +41,23 @@ describe('JSON Output', function() { output.should.have.file('fr/README.json'); }); + it('should correctly add languages list to all json', function() { + var jsonFR = require(output.resolve('fr/README.json')); + var jsonEN = require(output.resolve('en/README.json')); + + jsonFR.should.have.property('languages') + .with.property('list').with.lengthOf(2); + jsonEN.should.have.property('languages') + .with.property('list').with.lengthOf(2); + }); + it('should correctly generate a README.json for the whole book', function() { output.should.have.file('README.json'); + + var json = require(output.resolve('README.json')); + + json.should.have.property('languages') + .with.property('list').with.lengthOf(2); }); }); });