Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 16838eb

Browse files
committedOct 16, 2019
created unit tests for components under renderer
added in babel plugin for css in jsx added in more tests
1 parent 735ddaf commit 16838eb

7 files changed

+92
-1
lines changed
 

‎.babelrc

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"presets": [
3+
"@babel/preset-env",
4+
"@babel/preset-react",
5+
],
6+
"plugins": [
7+
"@babel/plugin-proposal-class-properties",
8+
"@babel/plugin-proposal-object-rest-spread",
9+
"@babel/plugin-transform-runtime",
10+
"styled-jsx/babel"
11+
]
12+
}

‎package.json

+29-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"private": true,
1515
"main": "main/index.js",
1616
"scripts": {
17-
"test": "xo",
17+
"test": "xo && ava --verbose",
1818
"start": "yarn && electron .",
1919
"build": "next build renderer && next export renderer",
2020
"dist": "npm run build && electron-builder",
@@ -25,6 +25,8 @@
2525
"name": "Kap"
2626
},
2727
"dependencies": {
28+
"@babel/preset-react": "^7.0.0",
29+
"@babel/runtime": "^7.6.2",
2830
"@ffmpeg-installer/ffmpeg": "^1.0.20",
2931
"@sentry/browser": "^5.6.3",
3032
"@sentry/electron": "^0.17.3",
@@ -68,15 +70,25 @@
6870
"react-dom": "^16.9.0",
6971
"react-linkify": "^0.2.2",
7072
"semver": "^6.3.0",
73+
"styled-jsx": "^3.2.2",
7174
"tempy": "^0.3.0",
7275
"tildify": "^2.0.0",
7376
"tmp": "^0.1.0",
7477
"unstated": "^1.2.0"
7578
},
7679
"devDependencies": {
80+
"@babel/plugin-proposal-class-properties": "^7.5.5",
81+
"@babel/plugin-proposal-object-rest-spread": "^7.6.2",
82+
"@babel/plugin-transform-runtime": "^7.6.2",
83+
"@babel/preset-env": "^7.6.2",
84+
"@babel/register": "^7.6.2",
85+
"ava": "^1.0.0-beta.8",
7786
"babel-eslint": "^10.0.3",
87+
"browser-env": "^3.2.6",
7888
"electron": "6.0.9",
7989
"electron-builder": "^21.2.0",
90+
"enzyme": "^3.10.0",
91+
"enzyme-adapter-react-16": "^1.14.0",
8092
"eslint-config-xo-react": "^0.20.0",
8193
"eslint-plugin-react": "^7.14.3",
8294
"eslint-plugin-react-hooks": "^2.0.1",
@@ -107,6 +119,22 @@
107119
"renderer/out"
108120
]
109121
},
122+
"ava": {
123+
"files": [
124+
"test/window-header.js",
125+
"test/keyboard-number-input.js",
126+
"test/open-files.js",
127+
"test/encoding.js",
128+
"!/test/editor"
129+
],
130+
"require": [
131+
"@babel/register",
132+
"@babel/preset-react",
133+
"./test/helpers/browser-env.js",
134+
"@babel/plugin-proposal-class-properties",
135+
"@babel/plugin-proposal-object-rest-spread"
136+
]
137+
},
110138
"husky": {
111139
"hooks": {
112140
"pre-commit": "npm test",

‎test/encoding.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import test from 'ava';
2+
import ffmpeg from '@ffmpeg-installer/ffmpeg';
3+
import execa from 'execa';
4+
5+
test('it should be able to find ffmpeg', t => {
6+
t.deepEqual(ffmpeg, ffmpeg);
7+
});
8+
9+
test('it should be able to find execa', t => {
10+
t.deepEqual(execa, execa);
11+
});
12+

‎test/helpers/browser-env.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('browser-env')();

‎test/keyboard-number-input.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import test from 'ava';
2+
import React from 'react';
3+
import {mount, configure} from 'enzyme';
4+
import Adapter from 'enzyme-adapter-react-16';
5+
import KeyboardNumberInput from '../renderer/components/keyboard-number-input';
6+
7+
configure({adapter: new Adapter()});
8+
9+
test('it should render input', t => {
10+
const wrapper = mount(<KeyboardNumberInput/>);
11+
wrapper.find('input[type="text"]').at(2);
12+
const input = wrapper.simulate('change', {target: {value: 72}});
13+
t.is((input.length), 1);
14+
});

‎test/open-files.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import test from 'ava';
2+
import supportedVideoExtensions from '../main/common/constants';
3+
4+
test('it should support mp4 mov and m4v', t => {
5+
t.deepEqual(supportedVideoExtensions, {supportedVideoExtensions: ['mp4', 'mov', 'm4v']});
6+
});
7+
8+
test('file extensions should equal .mp4 .mov and .m4v', t => {
9+
const supportedVideoExtensions = ['mp4', 'mov', 'm4v'];
10+
const fileExtensions = supportedVideoExtensions.map(ext => `.${ext}`);
11+
t.deepEqual(fileExtensions, ['.mp4', '.mov', '.m4v']);
12+
});

‎test/window-header.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import test from 'ava';
2+
import React from 'react';
3+
import {shallow, configure} from 'enzyme';
4+
import Adapter from 'enzyme-adapter-react-16';
5+
import WindowHeader from '../renderer/components/window-header';
6+
7+
configure({adapter: new Adapter()});
8+
9+
test('can mount component window header', t => {
10+
const wrapper = shallow(<WindowHeader/>);
11+
t.true(wrapper.hasClass('window-header'));
12+
});

0 commit comments

Comments
 (0)
Please sign in to comment.