mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Merge pull request #1822 from node-red-hitachi/context-test-memory
Add test cases for memory context
This commit is contained in:
		@@ -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"));
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user