Adding tests and linting.
This commit is contained in:
parent
5b11602a24
commit
d45a312def
30
.eslintrc.json
Normal file
30
.eslintrc.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"env": {
|
||||
"es6": true,
|
||||
"jest": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"sourceType": "module",
|
||||
"ecmaVersion": "2017"
|
||||
},
|
||||
"rules": {
|
||||
"indent": [
|
||||
"error",
|
||||
2
|
||||
],
|
||||
"linebreak-style": [
|
||||
"error",
|
||||
"unix"
|
||||
],
|
||||
"quotes": [
|
||||
"error",
|
||||
"single"
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
]
|
||||
}
|
||||
}
|
11
package.json
11
package.json
@ -9,14 +9,21 @@
|
||||
},
|
||||
"author": "mjswensen",
|
||||
"license": "MIT",
|
||||
"jest": {
|
||||
"rootDir": "lib"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel --out-dir lib src",
|
||||
"start": "watch 'yarn run build' src",
|
||||
"build": "eslint src && babel --out-dir lib src",
|
||||
"test": "yarn run build && jest",
|
||||
"start": "watch 'yarn run test' src",
|
||||
"prepublish": "yarn run build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.18.0",
|
||||
"babel-preset-latest": "^6.16.0",
|
||||
"eslint": "^3.12.2",
|
||||
"jest": "^18.1.0",
|
||||
"themer-colors-default": "^1.0.1",
|
||||
"watch": "^1.0.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
@ -1,4 +1,4 @@
|
||||
export const render = (colors, options) => {
|
||||
export const render = (colors) => {
|
||||
|
||||
const colorVars = colorSet => `
|
||||
let s:shade0 = "${colorSet.shade0}"
|
||||
@ -21,13 +21,13 @@ export const render = (colors, options) => {
|
||||
|
||||
const theme = `
|
||||
|
||||
${!!colors.dark ? `
|
||||
${'dark' in colors ? `
|
||||
if &background == 'dark'
|
||||
${colorVars(colors.dark)}
|
||||
endif
|
||||
` : ''}
|
||||
|
||||
${!!colors.light ? `
|
||||
${'light' in colors ? `
|
||||
if &background == 'light'
|
||||
${colorVars(colors.light)}
|
||||
endif
|
||||
|
21
src/index.spec.js
Normal file
21
src/index.spec.js
Normal file
@ -0,0 +1,21 @@
|
||||
import { render } from './index';
|
||||
import { colors } from 'themer-colors-default';
|
||||
|
||||
describe('themer vim lighline palette generator', () => {
|
||||
|
||||
const testColorSetConfiguration = (message, colors) => {
|
||||
it(message, async() => {
|
||||
const files = await Promise.all(render(colors, {}));
|
||||
const fileContents = files[0].contents.toString('utf8');
|
||||
expect(files.length).toBe(1);
|
||||
expect(/undefined/.test(fileContents)).toBe(false);
|
||||
expect(/'dark'/.test(fileContents)).toBe('dark' in colors);
|
||||
expect(/'light'/.test(fileContents)).toBe('light' in colors);
|
||||
});
|
||||
};
|
||||
|
||||
testColorSetConfiguration('should produce only one file containing both schemes if passed both a dark and light theme', colors);
|
||||
testColorSetConfiguration('should produce only one file containing only a dark scheme if passed only a dark color set', { dark: colors.dark });
|
||||
testColorSetConfiguration('should produce only one file containing only a light scheme if passed only a light color set', { light: colors.light });
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user