Skip to content

Commit

Permalink
[UPD] add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatnm0612 committed Nov 7, 2023
1 parent 44ceb1a commit 19fe85c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 14 deletions.
Binary file modified packages/openspp/assets/rectangle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages/openspp/src/Adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ export function getGroupMembers(registrant_id, offset=0, callback=false) {
if (callback) {
return callback(nextState);
}
return nextState;
} catch (err) {
console.log(`✗ Error: ${err}`);
return state;
Expand Down Expand Up @@ -296,6 +297,7 @@ export function getServicePoint(name, offset=0, callback=false) {
if (callback) {
return callback(nextState);
}
return nextState;
} catch (err) {
console.log(`✗ Error: ${err}`);
return state;
Expand Down
48 changes: 34 additions & 14 deletions packages/openspp/test/Adaptor.test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import { expect } from "chai";
import { execute } from "../src/Adaptor.js";
import {
execute,
getServicePoint,
searchGroup,
searchIndividual,
} from "../src/Adaptor.js";

const state = {
configuration: {
username: "admin",
password: "admin",
baseUrl: "https://demo.openspp.org/",
database: "openspp_adaptor",
},
references: [],
};

describe("execute", () => {
it("executes each operation in sequence", done => {
const state = {
configuration: {
username: "admin",
password: "935j-jv38-yeu9",
baseUrl: "https://dev.newlogic-demo.com/",
database: "devel",
},
};;
const operations = [
state => {
return { counter: 1 };
Expand All @@ -30,12 +37,25 @@ describe("execute", () => {
.then(done)
.catch(done);
});
});

describe("getServicePoint", () => {
it("get non-existing service point from demo server", async () => {
let finalState = await getServicePoint("n0n-3x15t1n6-53rv1c3-p01nt")(state);
expect(finalState.data).to.be.undefined;
});
});

it("assigns references, data to the initialState", () => {
const state = {};
describe("searchGroup", () => {
it("search non-existing group from demo server", async () => {
let finalState = await searchGroup([["id", "=", -1]])(state);
expect(finalState.data).to.be.undefined;
});
});

execute()(state).then(finalState => {
expect(finalState).to.eql({ references: [], data: null });
});
describe("searchIndividual", () => {
it("search non-existing individual from demo server", async () => {
let finalState = await searchIndividual([["id", "=", -1]])(state);
expect(finalState.data).to.be.undefined;
});
});
6 changes: 6 additions & 0 deletions packages/openspp/test/job.example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
getServicePoint("Agent 1");
searchGroup([["name", "ilike", "test group"]]);
searchIndividual([["name", "ilike", "butt"]]);
getGroup("GRP_7NAAH42X");
getIndividual("IND_EJFW8GUQ");
getProgram("PROG_2023_00000128");

0 comments on commit 19fe85c

Please sign in to comment.