mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Create default store for node tests to use
This commit is contained in:
parent
08b0838f9a
commit
7423583508
@ -36,6 +36,7 @@ function init(_settings) {
|
|||||||
stores = {};
|
stores = {};
|
||||||
var seed = settings.functionGlobalContext || {};
|
var seed = settings.functionGlobalContext || {};
|
||||||
contexts['global'] = createContext("global",seed);
|
contexts['global'] = createContext("global",seed);
|
||||||
|
stores["_"] = new memory();
|
||||||
}
|
}
|
||||||
|
|
||||||
function load() {
|
function load() {
|
||||||
|
@ -23,7 +23,7 @@ describe('context', function() {
|
|||||||
describe('local memory',function() {
|
describe('local memory',function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
Context.init({});
|
Context.init({});
|
||||||
return Context.load();
|
Context.load();
|
||||||
});
|
});
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
Context.clean({allNodes:{}});
|
Context.clean({allNodes:{}});
|
||||||
@ -165,7 +165,7 @@ describe('context', function() {
|
|||||||
|
|
||||||
it('should enumerate only context keys when GlobalContext was given - sync', function() {
|
it('should enumerate only context keys when GlobalContext was given - sync', function() {
|
||||||
Context.init({functionGlobalContext: {foo:"bar"}});
|
Context.init({functionGlobalContext: {foo:"bar"}});
|
||||||
return Context.load().then(function(){
|
Context.load().then(function(){
|
||||||
var context = Context.get("1","flowA");
|
var context = Context.get("1","flowA");
|
||||||
context.global.set("foo2","bar2");
|
context.global.set("foo2","bar2");
|
||||||
var keys = context.global.keys();
|
var keys = context.global.keys();
|
||||||
@ -177,7 +177,7 @@ describe('context', function() {
|
|||||||
|
|
||||||
it('should enumerate only context keys when GlobalContext was given - async', function(done) {
|
it('should enumerate only context keys when GlobalContext was given - async', function(done) {
|
||||||
Context.init({functionGlobalContext: {foo:"bar"}});
|
Context.init({functionGlobalContext: {foo:"bar"}});
|
||||||
return Context.load().then(function(){
|
Context.load().then(function(){
|
||||||
var context = Context.get("1","flowA");
|
var context = Context.get("1","flowA");
|
||||||
context.global.set("foo2","bar2");
|
context.global.set("foo2","bar2");
|
||||||
context.global.keys(function(err,keys) {
|
context.global.keys(function(err,keys) {
|
||||||
@ -193,7 +193,7 @@ describe('context', function() {
|
|||||||
|
|
||||||
it('returns functionGlobalContext value if store value undefined', function() {
|
it('returns functionGlobalContext value if store value undefined', function() {
|
||||||
Context.init({functionGlobalContext: {foo:"bar"}});
|
Context.init({functionGlobalContext: {foo:"bar"}});
|
||||||
return Context.load().then(function(){
|
Context.load().then(function(){
|
||||||
var context = Context.get("1","flowA");
|
var context = Context.get("1","flowA");
|
||||||
var v = context.global.get('foo');
|
var v = context.global.get('foo');
|
||||||
v.should.equal('bar');
|
v.should.equal('bar');
|
||||||
@ -279,18 +279,18 @@ describe('context', function() {
|
|||||||
describe('load modules',function(){
|
describe('load modules',function(){
|
||||||
it('should call open()', function() {
|
it('should call open()', function() {
|
||||||
Context.init({contextStorage:contextDefaultStorage});
|
Context.init({contextStorage:contextDefaultStorage});
|
||||||
return Context.load().then(function(){
|
Context.load().then(function(){
|
||||||
stubOpen.called.should.be.true();
|
stubOpen.called.should.be.true();
|
||||||
stubOpen2.called.should.be.true();
|
stubOpen2.called.should.be.true();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('should load memory module', function() {
|
it('should load memory module', function() {
|
||||||
Context.init({contextStorage:{memory:{module:"memory"}}});
|
Context.init({contextStorage:{memory:{module:"memory"}}});
|
||||||
return Context.load();
|
Context.load();
|
||||||
});
|
});
|
||||||
it('should load localfilesystem module', function() {
|
it('should load localfilesystem module', function() {
|
||||||
Context.init({contextStorage:{file:{module:"localfilesystem",config:{dir:resourcesDir}}}});
|
Context.init({contextStorage:{file:{module:"localfilesystem",config:{dir:resourcesDir}}}});
|
||||||
return Context.load();
|
Context.load();
|
||||||
});
|
});
|
||||||
it('should accept special storage name', function(done) {
|
it('should accept special storage name', function(done) {
|
||||||
Context.init({
|
Context.init({
|
||||||
@ -355,7 +355,7 @@ describe('context', function() {
|
|||||||
describe('close modules',function(){
|
describe('close modules',function(){
|
||||||
it('should call close()', function(done) {
|
it('should call close()', function(done) {
|
||||||
Context.init({contextStorage:contextDefaultStorage});
|
Context.init({contextStorage:contextDefaultStorage});
|
||||||
return Context.load().then(function(){
|
Context.load().then(function(){
|
||||||
return Context.close().then(function(){
|
return Context.close().then(function(){
|
||||||
stubClose.called.should.be.true();
|
stubClose.called.should.be.true();
|
||||||
stubClose2.called.should.be.true();
|
stubClose2.called.should.be.true();
|
||||||
@ -550,7 +550,7 @@ describe('context', function() {
|
|||||||
describe('delete context',function(){
|
describe('delete context',function(){
|
||||||
it('should not call delete() when external context storage is used', function(done) {
|
it('should not call delete() when external context storage is used', function(done) {
|
||||||
Context.init({contextStorage:contextDefaultStorage});
|
Context.init({contextStorage:contextDefaultStorage});
|
||||||
return Context.load().then(function(){
|
Context.load().then(function(){
|
||||||
Context.get("flowA");
|
Context.get("flowA");
|
||||||
return Context.delete("flowA").then(function(){
|
return Context.delete("flowA").then(function(){
|
||||||
stubDelete.called.should.be.false();
|
stubDelete.called.should.be.false();
|
||||||
@ -564,7 +564,7 @@ describe('context', function() {
|
|||||||
describe('clean context',function(){
|
describe('clean context',function(){
|
||||||
it('should call clean()', function(done) {
|
it('should call clean()', function(done) {
|
||||||
Context.init({contextStorage:contextDefaultStorage});
|
Context.init({contextStorage:contextDefaultStorage});
|
||||||
return Context.load().then(function(){
|
Context.load().then(function(){
|
||||||
return Context.clean({allNodes:{}}).then(function(){
|
return Context.clean({allNodes:{}}).then(function(){
|
||||||
stubClean.calledWithExactly([]).should.be.true();
|
stubClean.calledWithExactly([]).should.be.true();
|
||||||
stubClean2.calledWithExactly([]).should.be.true();
|
stubClean2.calledWithExactly([]).should.be.true();
|
||||||
|
Loading…
Reference in New Issue
Block a user