mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add clean to context plugin
and don't delete local context unless the context is deleted by a user
This commit is contained in:
@@ -22,6 +22,13 @@ describe('memory',function() {
|
||||
|
||||
beforeEach(function() {
|
||||
context = Memory({});
|
||||
return context.open();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
return context.clean([]).then(function(){
|
||||
return context.close();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#get/set',function() {
|
||||
@@ -120,9 +127,39 @@ describe('memory',function() {
|
||||
context.get("nodeX","foo").should.eql("abc");
|
||||
context.get("nodeY","foo").should.eql("abc");
|
||||
|
||||
context.delete("nodeX");
|
||||
return context.delete("nodeX").then(function(){
|
||||
should.not.exist(context.get("nodeX","foo"));
|
||||
should.exist(context.get("nodeY","foo"));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#clean',function() {
|
||||
it('should clean unnecessary context',function() {
|
||||
should.not.exist(context.get("nodeX","foo"));
|
||||
should.exist(context.get("nodeY","foo"));
|
||||
should.not.exist(context.get("nodeY","foo"));
|
||||
context.set("nodeX","foo","abc");
|
||||
context.set("nodeY","foo","abc");
|
||||
context.get("nodeX","foo").should.eql("abc");
|
||||
context.get("nodeY","foo").should.eql("abc");
|
||||
|
||||
return context.clean([]).then(function(){
|
||||
should.not.exist(context.get("nodeX","foo"));
|
||||
should.not.exist(context.get("nodeY","foo"));
|
||||
});
|
||||
});
|
||||
it('should not clean active context',function() {
|
||||
should.not.exist(context.get("nodeX","foo"));
|
||||
should.not.exist(context.get("nodeY","foo"));
|
||||
context.set("nodeX","foo","abc");
|
||||
context.set("nodeY","foo","abc");
|
||||
context.get("nodeX","foo").should.eql("abc");
|
||||
context.get("nodeY","foo").should.eql("abc");
|
||||
|
||||
return context.clean(["nodeX"]).then(function(){
|
||||
should.exist(context.get("nodeX","foo"));
|
||||
should.not.exist(context.get("nodeY","foo"));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user