Skip to content

Commit

Permalink
Added tests for RepositoryUniqueChecker
Browse files Browse the repository at this point in the history
  • Loading branch information
allouis committed Jun 28, 2023
1 parent 8c78f77 commit 18e0bff
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions ghost/collections/test/RepositoryUniqueChecker.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import assert from 'assert/strict';
import {CollectionsRepositoryInMemory} from '../src/CollectionsRepositoryInMemory';
import {Collection} from '../src/Collection';
import {RepositoryUniqueChecker} from '../src/RepositoryUniqueChecker';

describe('RepositoryUniqueChecker', function () {
let uniqueChecker: RepositoryUniqueChecker;

beforeEach(async function () {
const repository = new CollectionsRepositoryInMemory();
const collection = await Collection.create({
title: 'Test',
slug: 'not-unique'
});
repository.save(collection);
uniqueChecker = new RepositoryUniqueChecker(repository);
});
it('should return true if slug is unique', async function () {
const actual = await uniqueChecker.isUniqueSlug('unique');
const expected = true;

assert.equal(actual, expected, 'The slug "unique" should be unique');
});

it('should return false if slug is not unique', async function () {
const actual = await uniqueChecker.isUniqueSlug('not-unique');
const expected = false;

assert.equal(actual, expected, 'The slug "not-unique" should not be unique');
});
});

0 comments on commit 18e0bff

Please sign in to comment.