2019-11-14 07:06:30 -05:00
|
|
|
import { readmeFile } from '~/repository/utils/readme';
|
|
|
|
|
|
|
|
describe('readmeFile', () => {
|
2020-01-10 10:07:47 -05:00
|
|
|
it('prefers README with markup over plain text README', () => {
|
|
|
|
expect(readmeFile([{ name: 'README' }, { name: 'README.md' }])).toEqual({
|
|
|
|
name: 'README.md',
|
|
|
|
});
|
|
|
|
});
|
2019-11-14 07:06:30 -05:00
|
|
|
|
2020-01-10 10:07:47 -05:00
|
|
|
it('is case insensitive', () => {
|
|
|
|
expect(readmeFile([{ name: 'README' }, { name: 'readme.rdoc' }])).toEqual({
|
|
|
|
name: 'readme.rdoc',
|
2019-11-14 07:06:30 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-01-10 10:07:47 -05:00
|
|
|
it('returns the first README found', () => {
|
|
|
|
expect(readmeFile([{ name: 'INDEX.adoc' }, { name: 'README.md' }])).toEqual({
|
|
|
|
name: 'INDEX.adoc',
|
|
|
|
});
|
|
|
|
});
|
2019-11-14 07:06:30 -05:00
|
|
|
|
2020-01-10 10:07:47 -05:00
|
|
|
it('expects extension to be separated by dot', () => {
|
|
|
|
expect(readmeFile([{ name: 'readmeXorg' }, { name: 'index.org' }])).toEqual({
|
|
|
|
name: 'index.org',
|
2019-11-14 07:06:30 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-01-10 10:07:47 -05:00
|
|
|
it('returns plain text README when there is no README with markup', () => {
|
|
|
|
expect(readmeFile([{ name: 'README' }, { name: 'NOT_README.md' }])).toEqual({
|
|
|
|
name: 'README',
|
2019-11-14 07:06:30 -05:00
|
|
|
});
|
|
|
|
});
|
2020-01-10 10:07:47 -05:00
|
|
|
|
2020-01-12 22:07:51 -05:00
|
|
|
it('recognizes Readme.txt as a plain text README', () => {
|
|
|
|
expect(readmeFile([{ name: 'Readme.txt' }])).toEqual({
|
|
|
|
name: 'Readme.txt',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-01-10 10:07:47 -05:00
|
|
|
it('returns undefined when there are no appropriate files', () => {
|
|
|
|
expect(readmeFile([{ name: 'index.js' }, { name: 'md.README' }])).toBe(undefined);
|
|
|
|
expect(readmeFile([])).toBe(undefined);
|
|
|
|
});
|
2019-11-14 07:06:30 -05:00
|
|
|
});
|