improve applink businesslogic tests and fixup api

This commit is contained in:
Johannes Zellner
2022-09-19 20:59:48 +02:00
parent bc3cb6acb5
commit 81b59eae36
2 changed files with 23 additions and 6 deletions

View File

@@ -30,11 +30,11 @@ describe('Applinks', function () {
};
it('can add applink', async function () {
APPLINK_0.id = await applinks.add(APPLINK_0);
APPLINK_0.id = await applinks.add(JSON.parse(JSON.stringify(APPLINK_0)));
});
it('can add second applink with attributes', async function () {
APPLINK_1.id = await applinks.add(APPLINK_1);
APPLINK_1.id = await applinks.add(JSON.parse(JSON.stringify(APPLINK_1)));
});
it('can list all without accessRestriction', async function () {
@@ -48,7 +48,7 @@ describe('Applinks', function () {
expect(result[1].label).to.eql(APPLINK_1.label);
expect(result[1].accessRestriction).to.eql(APPLINK_1.accessRestriction);
expect(result[1].tags).to.eql(APPLINK_1.tags);
expect(result[1].icon.toString()).to.eql(APPLINK_1.icon);
expect(result[1].icon.toString('base64')).to.eql(APPLINK_1.icon);
});
it('cannot get applink with wrong id', async function () {
@@ -70,11 +70,23 @@ describe('Applinks', function () {
expect(result.label).to.eql(APPLINK_1.label);
expect(result.accessRestriction).to.eql(APPLINK_1.accessRestriction);
expect(result.tags).to.eql(APPLINK_1.tags);
expect(result.icon.toString()).to.eql(APPLINK_1.icon);
expect(result.icon.toString('base64')).to.eql(APPLINK_1.icon);
});
it('can update applink', async function () {
// TODO
APPLINK_0.upstreamUri = 'https://duckduckgo.com';
APPLINK_0.icon = APPLINK_1.icon;
await applinks.update(APPLINK_0.id, JSON.parse(JSON.stringify(APPLINK_0)));
const result = await applinks.get(APPLINK_0.id);
expect(result.upstreamUri).to.equal('https://duckduckgo.com');
expect(result.icon.toString('base64')).to.eql(APPLINK_1.icon);
});
it('can get applink icon', async function () {
const result = await applinks.getIcon(APPLINK_0.id);
expect(result.toString('base64')).to.eql(APPLINK_1.icon);
});
it('cannot remove applink with wrong id', async function () {