jsmdb
Version:
JSMumps Database Component
630 lines (445 loc) • 9.72 kB
JavaScript
const jsmdb = require("../lib/jsmdb");
let jsm = new jsmdb();
describe("JSMumps Database API", function() {
/*
afterAll(function() {
jsm.shutdown();
});
*/
describe("get()", function() {
it("works synchronously", function() {
var result = jsm.get({
global: "^VCLJSMT",
subscripts: [],
synchronous: true
});
expect(result.data).toBe(1);
});
it("works in callback mode", function(done) {
jsm.get({
global: "^VCLJSMT",
subscripts: [],
callback: true,
onComplete: function(error, result) {
expect(result).toBe(1);
done();
}
});
});
it("works using child processes in promise mode", function(done) {
jsm.get({
global: "^VCLJSMT",
subscripts: [],
childProcess: true
}).then((result) => {
expect(result).toBe(1);
done();
});
});
it("works using child processes in callback mode", function(done) {
jsm.get({
global: "^VCLJSMT",
subscripts: [],
childProcess: true,
callback: true,
onComplete: function(error, result) {
expect(result.data).toBe(1);
done();
}
});
});
it("works with promises", function(done) {
jsm.get({
global: "^VCLJSMT",
subscripts: []
}).then((result) => {
expect(result).toBe(1);
done();
});
});
});
describe("set()", function() {
it("works synchronously", function() {
var result = jsm.set({
global: "^VCLJSMT",
subscripts: ["set"],
data: "setSync",
synchronous: true
});
result = jsm.get({
global: "^VCLJSMT",
subscripts: ["set"],
synchronous: true
});
expect(result.data).toBe("setSync");
});
it("works in callback mode", function(done) {
jsm.set({
global: "^VCLJSMT",
subscripts: ["set"],
data: "setCallbackNative",
callback: true,
onComplete: function(error, result) {
if(error) {
var scratch = 0;
expect(scratch).toBe(1);
}
jsm.get({
global: "^VCLJSMT",
subscripts: ["set"],
callback: true,
onComplete: function(error, result) {
if(error) {
var scratch2 = 0;
expect(scratch2).toBe(1);
}
expect(result).toBe("setCallbackNative");
done();
}
});
}
});
});
it("works using child processes in promise mode", function(done) {
var result = jsm.set({
global: "^VCLJSMT",
subscripts: ["set"],
data: "setCPPromise",
childProcess: true
}).then((result) => {
tresult = jsm.get({
global: "^VCLJSMT",
subscripts: ["set"],
synchronous: true
});
expect(tresult.data).toBe("setCPPromise");
done();
});
});
it("works using child processes in callback mode", function(done) {
var result = jsm.set({
global: "^VCLJSMT",
subscripts: ["set"],
data: "setCPCallback",
childProcess: true,
callback: true,
onComplete: function(error, result) {
var tresult = jsm.get({
global: "^VCLJSMT",
subscripts: ["set"],
synchronous: true
});
expect(tresult.data).toBe("setCPCallback");
done();
}
});
});
it("works with promises", function(done) {
jsm.set({
global: "^VCLJSMT",
subscripts: ["set"],
data: "setPromises"}).then((result) => {
var tresult = jsm.get({
global: "^VCLJSMT",
subscripts: ["set"],
synchronous: true
});
expect(tresult.data).toBe("setPromises");
done();
});
});
});
describe("merge()", function() {
it("works synchronously", function() {
jsm.set({
global: "^VCLJSMM",
subscripts: [],
data: "test"
});
jsm.merge({
from: {
global: "^VCLJSMM",
subscripts: []
},
to: {
global: "^VCLJSMM2",
subscripts: []
},
synchronous: true
});
var result = jsm.get({
global: "^VCLJSMM2",
subscripts: [],
synchronous: true
});
expect(result.data).toBe("test");
});
it("works in callback mode", function(done) {
jsm.set({
global: "^VCLJSMM2",
subscripts: [],
data: ""
});
jsm.set({
global: "^VCLJSMM",
subscripts: [],
data: "test"
});
jsm.merge({
from: {
global: "^VCLJSMM",
subscripts: []
},
to: {
global: "^VCLJSMM2",
subscripts: []
},
callback: true,
onComplete: function(error, result) {
if(error) {
var scratch = 0;
expect(scratch).toBe(1);
}
var tresult = jsm.get({
global: "^VCLJSMM2",
subscripts: [],
synchronous: true
});
expect(tresult.data).toBe("test");
done();
}
});
});
it("works using child processes in promise mode", function(done) {
jsm.set({
global: "^VCLJSMM2",
subscripts: [],
data: ""
});
jsm.set({
global: "^VCLJSMM",
subscripts: [],
data: "test"
});
jsm.merge({
from: {
global: "^VCLJSMM",
subscripts: []
},
to: {
global: "^VCLJSMM2",
subscripts: []
},
childProcess: true
}).then((result) => {
var tresult = jsm.get({
global: "^VCLJSMM2",
subscripts: [],
synchronous: true
});
expect(tresult.data).toBe("test");
done();
});
});
it("works using child processes in callback mode", function(done) {
jsm.set({
global: "^VCLJSMM2",
subscripts: [],
data: ""
});
jsm.set({
global: "^VCLJSMM",
subscripts: [],
data: "test"
});
jsm.merge({
from: {
global: "^VCLJSMM",
subscripts: []
},
to: {
global: "^VCLJSMM2",
subscripts: []
},
childProcess: true,
callback: true,
onComplete: function(error, result) {
if(error) {
var scratch = 0;
expect(scratch).toBe(1);
}
var tresult = jsm.get({
global: "^VCLJSMM2",
subscripts: [],
synchronous: true
});
expect(tresult.data).toBe("test");
done();
}
});
});
it("works with promises", function(done) {
jsm.set({
global: "^VCLJSMM2",
subscripts: [],
data: ""
});
jsm.set({
global: "^VCLJSMM",
subscripts: [],
data: "test"
});
jsm.merge({
from: {
global: "^VCLJSMM",
subscripts: []
},
to: {
global: "^VCLJSMM2",
subscripts: []
},
}).then((result) => {
var tresult = jsm.get({
global: "^VCLJSMM2",
subscripts: [],
synchronous: true
});
expect(tresult.data).toBe("test");
done();
});
});
});
/*
describe("kill()", function() {
it("works synchronously", function() {
});
it("works in callback mode", function(done) {
done();
});
it("works using child processes in promise mode", function(done) {
done();
});
it("works using child processes in callback mode", function(done) {
done();
});
it("works with promises", function(done) {
done();
});
});
describe("lock()", function() {
it("works synchronously", function() {
});
it("works in callback mode", function(done) {
done();
});
it("works using child processes in promise mode", function(done) {
done();
});
it("works using child processes in callback mode", function(done) {
done();
});
it("works with promises", function(done) {
done();
});
});
describe("unlock()", function() {
it("works synchronously", function() {
});
it("works in callback mode", function(done) {
done();
});
it("works using child processes in promise mode", function(done) {
done();
});
it("works using child processes in callback mode", function(done) {
done();
});
it("works with promises", function(done) {
done();
});
});
describe("data()", function() {
it("works synchronously", function() {
});
it("works in callback mode", function(done) {
done();
});
it("works using child processes in promise mode", function(done) {
done();
});
it("works using child processes in callback mode", function(done) {
done();
});
it("works with promises", function(done) {
done();
});
});
describe("order()", function() {
it("works synchronously", function() {
});
it("works in callback mode", function(done) {
done();
});
it("works using child processes in promise mode", function(done) {
done();
});
it("works using child processes in callback mode", function(done) {
done();
});
it("works with promises", function(done) {
done();
});
});
describe("query()", function() {
it("works synchronously", function() {
});
it("works in callback mode", function(done) {
done();
});
it("works using child processes in promise mode", function(done) {
done();
});
it("works using child processes in callback mode", function(done) {
done();
});
it("works with promises", function(done) {
done();
});
});
describe("import()", function() {
it("works synchronously", function() {
});
it("works asyncronously", function(done) {
done();
});
});
describe("function()", function() {
it("works synchronously", function() {
});
it("works asyncronously", function(done) {
done();
});
});
describe("procedure()", function() {
it("works synchronously", function() {
});
it("works asyncronously", function(done) {
done();
});
});
describe("getObject()", function() {
it("works synchronously", function() {
});
it("works asyncronously", function(done) {
done();
});
});
describe("setObject()", function() {
it("works synchronously", function() {
});
it("works asyncronously", function(done) {
done();
});
});
*/
});