From 57c529758e8208648ac2bb62e2d2eb9a34dc1fd0 Mon Sep 17 00:00:00 2001 From: Daisuke Baba Date: Thu, 19 Jan 2017 17:19:41 +0900 Subject: [PATCH] Add an edge case test --- test/red/runtime/nodes/registry/loader_spec.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/red/runtime/nodes/registry/loader_spec.js b/test/red/runtime/nodes/registry/loader_spec.js index c3df70bd5..b7f32a2de 100644 --- a/test/red/runtime/nodes/registry/loader_spec.js +++ b/test/red/runtime/nodes/registry/loader_spec.js @@ -585,6 +585,24 @@ describe("red/nodes/registry/loader",function() { loader.getNodeHelp(node,"fr").should.eql("bar"); fs.readFileSync.calledTwice.should.be.true(); }); + it("fails to load en-US help content", function() { + stubs.push(sinon.stub(fs,"readFileSync", function(path) { + throw new Error("not found"); + })); + var node = { + template: "/tmp/node/directory/file.html", + help:{} + }; + delete node.help['en-US']; + + should.not.exist(loader.getNodeHelp(node,"en-US")); + should.not.exist(node.help['en-US']); + fs.readFileSync.calledTwice.should.be.true(); + fs.readFileSync.firstCall.args[0].should.eql(path.normalize("/tmp/node/directory/locales/en-US/file.html")); + fs.readFileSync.lastCall.args[0].should.eql(path.normalize("/tmp/node/directory/locales/en/file.html")); + should.not.exist(loader.getNodeHelp(node,"en-US")); + fs.readFileSync.callCount.should.eql(4); + }); }); });