import test from 'ava';
import testCollection from '../../../_util/_mocks/testCollection.json';
import renderDefinitionContentNextEntries from '../renderDefinitionContentNextEntries';
test('first item', (t) => {
const { title, slug } = testCollection[0].data;
t.is(
renderDefinitionContentNextEntries(title, slug, testCollection),
``
);
});
test('last item', (t) => {
const { title, slug } = testCollection[testCollection.length - 1].data;
t.is(
renderDefinitionContentNextEntries(title, slug, testCollection),
``
);
});
test('throws if no title has been passed', (t) => {
const error = t.throws(() => {
renderDefinitionContentNextEntries();
});
t.is(error.message, 'E_NO_TITLE');
});
test('throws if no slug has been passed', (t) => {
const error = t.throws(() => {
renderDefinitionContentNextEntries('title');
});
t.is(error.message, 'E_NO_SLUG');
});
test('throws if no collection has been passed', (t) => {
const error = t.throws(() => {
renderDefinitionContentNextEntries(
testCollection[0].data.title,
testCollection[0].data.slug
);
});
t.is(error.message, 'E_NO_COLLECTION');
});