Skip to content

Commit cfe0098

Browse files
authored
test(repository): add missing test cases for countAll (#147)
adds unit test cases for transactional, soft-crud and sequelize soft crud repo GH-146
1 parent a4d489f commit cfe0098

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

src/__tests__/unit/repository/default-transaction-soft-crud.repository.base.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,21 @@ describe('DefaultTransactionSoftCrudRepository', () => {
681681
});
682682
});
683683

684+
describe('countAll', () => {
685+
beforeEach(setupTestData);
686+
afterEach(clearTestData);
687+
it('should return total count when no conditions are passed', async () => {
688+
const count = await repo.countAll();
689+
expect(count.count).to.be.equal(4);
690+
});
691+
it('should return count for soft deleted entries when conditions specified', async () => {
692+
const count = await repo.countAll({
693+
694+
});
695+
expect(count.count).to.be.equal(1);
696+
});
697+
});
698+
684699
describe('deleteById', () => {
685700
beforeEach(setupTestData);
686701
afterEach(clearTestData);

src/__tests__/unit/repository/soft-crud.repository.unit.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,21 @@ describe('SoftCrudRepository', () => {
675675
});
676676
});
677677

678+
describe('countAll', () => {
679+
beforeEach(setupTestData);
680+
afterEach(clearTestData);
681+
it('should return total count when no conditions are passed', async () => {
682+
const count = await repo.countAll();
683+
expect(count.count).to.be.equal(4);
684+
});
685+
it('should return count for soft deleted entries when conditions specified', async () => {
686+
const count = await repo.countAll({
687+
688+
});
689+
expect(count.count).to.be.equal(1);
690+
});
691+
});
692+
678693
describe('deleteById', () => {
679694
beforeEach(setupTestData);
680695
afterEach(clearTestData);

src/__tests__/unit/sequelize/sequelize-soft-crud.unit.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,21 @@ describe('SoftCrudRepositoryMixin with Sequelize Repository', () => {
629629
});
630630
});
631631

632+
describe('countAll', () => {
633+
beforeEach(setupTestData);
634+
afterEach(clearTestData);
635+
it('should return total count when no conditions are passed', async () => {
636+
const count = await repo.countAll();
637+
expect(count.count).to.be.equal(4);
638+
});
639+
it('should return count for soft deleted entries when conditions specified', async () => {
640+
const count = await repo.countAll({
641+
642+
});
643+
expect(count.count).to.be.equal(1);
644+
});
645+
});
646+
632647
describe('deleteById', () => {
633648
beforeEach(setupTestData);
634649
afterEach(clearTestData);

0 commit comments

Comments
 (0)