2020-11-04 17:11:19 +00:00
|
|
|
import { expect } from 'chai';
|
2021-05-07 01:47:10 +00:00
|
|
|
|
2022-08-17 23:35:08 +00:00
|
|
|
import * as commitStore from '~/src/compose/commit';
|
|
|
|
import * as db from '~/src/db';
|
2020-11-04 17:11:19 +00:00
|
|
|
|
|
|
|
describe('compose/commit', () => {
|
2022-09-06 18:03:23 +00:00
|
|
|
before(async () => await db.initialized());
|
2020-11-04 17:11:19 +00:00
|
|
|
|
|
|
|
describe('Fetching commits', () => {
|
|
|
|
beforeEach(async () => {
|
|
|
|
// Clear the commit values in the db
|
|
|
|
await db.models('currentCommit').del();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should fetch a commit for an appId', async () => {
|
|
|
|
const commit = 'abcdef';
|
|
|
|
await commitStore.upsertCommitForApp(1, commit);
|
|
|
|
|
|
|
|
expect(await commitStore.getCommitForApp(1)).to.equal(commit);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should fetch the correct commit value when there is multiple commits', async () => {
|
|
|
|
const commit = 'abcdef';
|
|
|
|
await commitStore.upsertCommitForApp(1, '123456');
|
|
|
|
await commitStore.upsertCommitForApp(2, commit);
|
|
|
|
|
|
|
|
expect(await commitStore.getCommitForApp(2)).to.equal(commit);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should correctly insert a commit when a commit for the same app already exists', async () => {
|
|
|
|
const commit = 'abcdef';
|
|
|
|
await commitStore.upsertCommitForApp(1, '123456');
|
|
|
|
await commitStore.upsertCommitForApp(1, commit);
|
|
|
|
expect(await commitStore.getCommitForApp(1)).to.equal(commit);
|
|
|
|
});
|
|
|
|
});
|