debian-mirror-gitlab/spec/frontend/repository/utils/readme_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
1.3 KiB
JavaScript
Raw Normal View History

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