Skip to content

Commit

Permalink
openspp: soft tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
josephjclark committed Nov 9, 2023
1 parent 846499d commit 7a685ba
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 46 deletions.
86 changes: 46 additions & 40 deletions packages/openspp/test/Adaptor.test.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,67 @@
import { expect } from "chai";
import { expect } from 'chai';
import {
execute,
getServicePoint,
searchGroup,
searchIndividual,
} from "../src/Adaptor.js";
} from '../src/Adaptor.js';

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

describe("execute", () => {
it("executes each operation in sequence", done => {
const operations = [
state => {
return { counter: 1 };
},
state => {
return { counter: 2 };
},
state => {
return { counter: 3 };
},
];
// Unit tests are disabled here because they run against a live sandbox
// They should be re-enabled for local dev when this adaptor is next touched
describe.skip('openspp', () => {
describe('execute', () => {
it('executes each operation in sequence', done => {
const operations = [
state => {
return { counter: 1 };
},
state => {
return { counter: 2 };
},
state => {
return { counter: 3 };
},
];

execute(...operations)(state)
.then(finalState => {
expect(finalState).to.eql({ counter: 3 });
})
.then(done)
.catch(done);
execute(...operations)(state)
.then(finalState => {
expect(finalState).to.eql({ counter: 3 });
})
.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;
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;
});
});
});

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

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

0 comments on commit 7a685ba

Please sign in to comment.