New "browse" UI
Also, separated out browse, ?meta, and ?module request handlers. Fixes #82
This commit is contained in:
@ -1,39 +1,47 @@
|
||||
import getContentType from '../getContentType.js';
|
||||
|
||||
it('gets a content type of text/plain for LICENSE|README|CHANGES|AUTHORS|Makefile', () => {
|
||||
expect(getContentType('AUTHORS')).toBe('text/plain');
|
||||
expect(getContentType('CHANGES')).toBe('text/plain');
|
||||
expect(getContentType('LICENSE')).toBe('text/plain');
|
||||
expect(getContentType('Makefile')).toBe('text/plain');
|
||||
expect(getContentType('PATENTS')).toBe('text/plain');
|
||||
expect(getContentType('README')).toBe('text/plain');
|
||||
});
|
||||
describe('getContentType', () => {
|
||||
it('returns text/plain for LICENSE|README|CHANGES|AUTHORS|Makefile', () => {
|
||||
expect(getContentType('AUTHORS')).toBe('text/plain');
|
||||
expect(getContentType('CHANGES')).toBe('text/plain');
|
||||
expect(getContentType('LICENSE')).toBe('text/plain');
|
||||
expect(getContentType('Makefile')).toBe('text/plain');
|
||||
expect(getContentType('PATENTS')).toBe('text/plain');
|
||||
expect(getContentType('README')).toBe('text/plain');
|
||||
});
|
||||
|
||||
it('gets a content type of text/plain for .*rc files', () => {
|
||||
expect(getContentType('.eslintrc')).toBe('text/plain');
|
||||
expect(getContentType('.babelrc')).toBe('text/plain');
|
||||
expect(getContentType('.anythingrc')).toBe('text/plain');
|
||||
});
|
||||
it('returns text/plain for .*rc files', () => {
|
||||
expect(getContentType('.eslintrc')).toBe('text/plain');
|
||||
expect(getContentType('.babelrc')).toBe('text/plain');
|
||||
expect(getContentType('.anythingrc')).toBe('text/plain');
|
||||
});
|
||||
|
||||
it('gets a content type of text/plain for .git* files', () => {
|
||||
expect(getContentType('.gitignore')).toBe('text/plain');
|
||||
expect(getContentType('.gitanything')).toBe('text/plain');
|
||||
});
|
||||
it('returns text/plain for .git* files', () => {
|
||||
expect(getContentType('.gitignore')).toBe('text/plain');
|
||||
expect(getContentType('.gitanything')).toBe('text/plain');
|
||||
});
|
||||
|
||||
it('gets a content type of text/plain for .*ignore files', () => {
|
||||
expect(getContentType('.eslintignore')).toBe('text/plain');
|
||||
expect(getContentType('.anythingignore')).toBe('text/plain');
|
||||
});
|
||||
it('returns text/plain for .*ignore files', () => {
|
||||
expect(getContentType('.eslintignore')).toBe('text/plain');
|
||||
expect(getContentType('.anythingignore')).toBe('text/plain');
|
||||
});
|
||||
|
||||
it('gets a content type of text/plain for .ts files', () => {
|
||||
expect(getContentType('app.ts')).toBe('text/plain');
|
||||
expect(getContentType('app.d.ts')).toBe('text/plain');
|
||||
});
|
||||
it('returns text/plain for .ts(x) files', () => {
|
||||
expect(getContentType('app.ts')).toBe('text/plain');
|
||||
expect(getContentType('app.d.ts')).toBe('text/plain');
|
||||
expect(getContentType('app.tsx')).toBe('text/plain');
|
||||
});
|
||||
|
||||
it('gets a content type of text/plain for .flow files', () => {
|
||||
expect(getContentType('app.js.flow')).toBe('text/plain');
|
||||
});
|
||||
it('returns text/plain for .flow files', () => {
|
||||
expect(getContentType('app.js.flow')).toBe('text/plain');
|
||||
});
|
||||
|
||||
it('gets a content type of text/plain for .lock files', () => {
|
||||
expect(getContentType('yarn.lock')).toBe('text/plain');
|
||||
it('returns text/plain for .lock files', () => {
|
||||
expect(getContentType('yarn.lock')).toBe('text/plain');
|
||||
});
|
||||
|
||||
it('returns application/json for .map files', () => {
|
||||
expect(getContentType('react.js.map')).toBe('application/json');
|
||||
expect(getContentType('react.json.map')).toBe('application/json');
|
||||
});
|
||||
});
|
||||
|
||||
84
modules/utils/__tests__/getLanguageName-test.js
Normal file
84
modules/utils/__tests__/getLanguageName-test.js
Normal file
@ -0,0 +1,84 @@
|
||||
import getLanguageName from '../getLanguageName.js';
|
||||
|
||||
describe('getLanguageName', () => {
|
||||
// Hard-coded overrides
|
||||
|
||||
it('detects Flow files', () => {
|
||||
expect(getLanguageName('react.flow')).toBe('Flow');
|
||||
});
|
||||
|
||||
it('detects source maps', () => {
|
||||
expect(getLanguageName('react.map')).toBe('Source Map (JSON)');
|
||||
expect(getLanguageName('react.js.map')).toBe('Source Map (JSON)');
|
||||
expect(getLanguageName('react.json.map')).toBe('Source Map (JSON)');
|
||||
});
|
||||
|
||||
it('detects TypeScript files', () => {
|
||||
expect(getLanguageName('react.d.ts')).toBe('TypeScript');
|
||||
expect(getLanguageName('react.tsx')).toBe('TypeScript');
|
||||
});
|
||||
|
||||
// Content-Type lookups
|
||||
|
||||
it('detects JavaScript files', () => {
|
||||
expect(getLanguageName('react.js')).toBe('JavaScript');
|
||||
});
|
||||
|
||||
it('detects JSON files', () => {
|
||||
expect(getLanguageName('react.json')).toBe('JSON');
|
||||
});
|
||||
|
||||
it('detects binary files', () => {
|
||||
expect(getLanguageName('ionicons.bin')).toBe('Binary');
|
||||
});
|
||||
|
||||
it('detects EOT files', () => {
|
||||
expect(getLanguageName('ionicons.eot')).toBe('Embedded OpenType');
|
||||
});
|
||||
|
||||
it('detects SVG files', () => {
|
||||
expect(getLanguageName('react.svg')).toBe('SVG');
|
||||
});
|
||||
|
||||
it('detects TTF files', () => {
|
||||
expect(getLanguageName('ionicons.ttf')).toBe('TrueType Font');
|
||||
});
|
||||
|
||||
it('detects WOFF files', () => {
|
||||
expect(getLanguageName('ionicons.woff')).toBe('WOFF');
|
||||
});
|
||||
|
||||
it('detects WOFF2 files', () => {
|
||||
expect(getLanguageName('ionicons.woff2')).toBe('WOFF2');
|
||||
});
|
||||
|
||||
it('detects CSS files', () => {
|
||||
expect(getLanguageName('react.css')).toBe('CSS');
|
||||
});
|
||||
|
||||
it('detects HTML files', () => {
|
||||
expect(getLanguageName('react.html')).toBe('HTML');
|
||||
});
|
||||
|
||||
it('detects JSX files', () => {
|
||||
expect(getLanguageName('react.jsx')).toBe('JSX');
|
||||
});
|
||||
|
||||
it('detects Markdown files', () => {
|
||||
expect(getLanguageName('README.md')).toBe('Markdown');
|
||||
});
|
||||
|
||||
it('detects plain text files', () => {
|
||||
expect(getLanguageName('README')).toBe('Plain Text');
|
||||
expect(getLanguageName('LICENSE')).toBe('Plain Text');
|
||||
});
|
||||
|
||||
it('detects SCSS files', () => {
|
||||
expect(getLanguageName('some.scss')).toBe('SCSS');
|
||||
});
|
||||
|
||||
it('detects YAML files', () => {
|
||||
expect(getLanguageName('config.yml')).toBe('YAML');
|
||||
expect(getLanguageName('config.yaml')).toBe('YAML');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user