Skip to content

Commit

Permalink
test: add more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jul 24, 2020
1 parent 5b3d41d commit ca0700f
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,39 @@ describe('Front-matter', () => {
});
});

it('yaml mode - no content', () => {
const str = [
'---',
'foo',
'---'
].join('\n');

yfm.split(str).should.eql({
data: 'foo',
content: '',
separator: '---',
prefixSeparator: true
});
});

it('yaml mode - content conflict', () => {
const str = [
'---',
'foo',
'---',
'bar',
'---',
'baz'
].join('\n');

yfm.split(str).should.eql({
data: 'foo',
content: 'bar\n---\nbaz',
separator: '---',
prefixSeparator: true
});
});

it('json mode', () => {
const str = [
';;;',
Expand All @@ -39,6 +72,21 @@ describe('Front-matter', () => {
});
});

it('json mode - no content', () => {
const str = [
';;;',
'foo',
';;;'
].join('\n');

yfm.split(str).should.eql({
data: 'foo',
content: '',
separator: ';;;',
prefixSeparator: true
});
});

it('yaml mode: new', () => {
const str = [
'foo',
Expand All @@ -54,6 +102,37 @@ describe('Front-matter', () => {
});
});

it('yaml mode: new - no content', () => {
const str = [
'foo',
'---'
].join('\n');

yfm.split(str).should.eql({
data: 'foo',
content: '',
separator: '---',
prefixSeparator: false
});
});

it('yaml mode: new - content conflict', () => {
const str = [
'foo',
'---',
'bar',
'---',
'baz'
].join('\n');

yfm.split(str).should.eql({
data: 'foo',
content: 'bar\n---\nbaz',
separator: '---',
prefixSeparator: false
});
});

it('json mode: new', () => {
const str = [
'foo',
Expand All @@ -69,6 +148,20 @@ describe('Front-matter', () => {
});
});

it('json mode: new - no content', () => {
const str = [
'foo',
';;;'
].join('\n');

yfm.split(str).should.eql({
data: 'foo',
content: '',
separator: ';;;',
prefixSeparator: false
});
});

it('without data', () => {
const str = [
'foo',
Expand Down

0 comments on commit ca0700f

Please sign in to comment.