From f6c7cb58048a8a2ea445c4dbe346961054f1d74e Mon Sep 17 00:00:00 2001 From: nakanishi Date: Thu, 19 Jul 2018 13:49:36 +0900 Subject: [PATCH] Add test cases for global context of memory context --- test/red/runtime/nodes/context/memory_spec.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/red/runtime/nodes/context/memory_spec.js b/test/red/runtime/nodes/context/memory_spec.js index 00582d986..95bb0674f 100644 --- a/test/red/runtime/nodes/context/memory_spec.js +++ b/test/red/runtime/nodes/context/memory_spec.js @@ -144,6 +144,32 @@ describe('memory',function() { keysY.should.have.length(1); keysY[0].should.equal("hoge"); }); + + it('should enumerate global context keys', function () { + var keys = context.keys("global"); + keys.should.be.an.Array(); + keys.should.be.empty(); + + context.set("global", "foo", "bar"); + keys = context.keys("global"); + keys.should.have.length(1); + keys[0].should.equal("foo"); + + context.set("global", "abc.def", "bar"); + keys = context.keys("global"); + keys.should.have.length(2); + keys[1].should.equal("abc"); + }); + + it('should not return specific keys as global context keys', function () { + var keys = context.keys("global"); + + context.set("global", "set", "bar"); + context.set("global", "get", "bar"); + context.set("global", "keys", "bar"); + keys = context.keys("global"); + keys.should.have.length(0); + }); }); describe('async',function() { @@ -212,6 +238,14 @@ describe('memory',function() { should.not.exist(context.get("nodeY","foo")); }); }); + it('should not clean global context', function () { + context.set("global", "foo", "abc"); + context.get("global", "foo").should.equal("abc"); + + return context.clean(["global"]).then(function () { + should.exist(context.get("global", "foo")); + }); + }); }); });