Merge pull request #44 from pivotaltracker/add-testing-framework
Add karma/jasmine + tests for emoji-index and pickerrelease
commit
82da9f2c7c
|
@ -0,0 +1,73 @@
|
|||
// Karma configuration
|
||||
// Generated on Fri Jan 27 2017 13:33:03 GMT-0700 (MST)
|
||||
var webpackConfig = require('./src/webpack.config.js');
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: '',
|
||||
|
||||
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: ['jasmine'],
|
||||
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
'src/**/*Spec.js',
|
||||
],
|
||||
|
||||
|
||||
// list of files to exclude
|
||||
exclude: [
|
||||
],
|
||||
|
||||
|
||||
// preprocess matching files before serving them to the browser
|
||||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
||||
preprocessors: {
|
||||
'src/**/*Spec.js': ['webpack'],
|
||||
},
|
||||
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||
reporters: ['progress'],
|
||||
|
||||
|
||||
// web server port
|
||||
port: 9876,
|
||||
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
logLevel: config.LOG_INFO,
|
||||
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: true,
|
||||
|
||||
|
||||
// start these browsers
|
||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||
browsers: ['Chrome'],
|
||||
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: false,
|
||||
|
||||
// Concurrency level
|
||||
// how many browser should be started simultaneous
|
||||
concurrency: Infinity,
|
||||
|
||||
webpack: webpackConfig,
|
||||
})
|
||||
}
|
|
@ -32,6 +32,12 @@
|
|||
"emoji-datasource": "2.4.4",
|
||||
"emojilib": "2.0.2",
|
||||
"inflection": "1.10.0",
|
||||
"jasmine-core": "^2.5.2",
|
||||
"karma": "^1.4.0",
|
||||
"karma-chrome-launcher": "^2.0.0",
|
||||
"karma-cli": "^1.0.1",
|
||||
"karma-jasmine": "^1.1.0",
|
||||
"karma-webpack": "^2.0.2",
|
||||
"mkdirp": "0.5.1",
|
||||
"react": "15.2.0",
|
||||
"react-addons-test-utils": "15.2.0",
|
||||
|
@ -52,7 +58,7 @@
|
|||
"react:clean": "rimraf node_modules/{react,react-dom,react-addons-test-utils}",
|
||||
"react:14": "npm run react:clean && npm i react@^0.14 react-dom@^0.14 react-addons-test-utils@^0.14 --save-dev",
|
||||
"react:15": "npm run react:clean && npm i react@^15 react-dom@^15 react-addons-test-utils@^15 --save-dev",
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"test": "NODE_ENV=test ./node_modules/karma/bin/karma start",
|
||||
"prepublish": "npm run clean && npm run build"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
import React from 'react';
|
||||
import TestUtils from 'react-addons-test-utils';
|
||||
import Picker from './picker';
|
||||
|
||||
const {
|
||||
click
|
||||
} = TestUtils.Simulate;
|
||||
|
||||
const {
|
||||
renderIntoDocument,
|
||||
scryRenderedComponentsWithType,
|
||||
findRenderedComponentWithType,
|
||||
} = TestUtils;
|
||||
|
||||
describe('Picker', () => {
|
||||
let subject;
|
||||
|
||||
it('works', () => {
|
||||
subject = render();
|
||||
expect(subject).toBeDefined();
|
||||
});
|
||||
|
||||
// This is the unit test for pull request (https://github.com/missive/emoji-mart/pull/43)
|
||||
// describe('categories', () => {
|
||||
// it('shows 10 by default', () => {
|
||||
// subject = render();
|
||||
// expect(subject.categories.length).toEqual(10);
|
||||
// });
|
||||
//
|
||||
// it('will not show some based upon our filter', () => {
|
||||
// subject = render({emojisToShowFilter: (unified) => false});
|
||||
// expect(subject.categories.length).toEqual(2);
|
||||
// });
|
||||
// });
|
||||
|
||||
function render(props = {}) {
|
||||
const defaultProps = {
|
||||
};
|
||||
return renderIntoDocument(
|
||||
<Picker {...defaultProps} {...props} />
|
||||
);
|
||||
}
|
||||
});
|
|
@ -0,0 +1,23 @@
|
|||
import emojiIndex from './emoji-index';
|
||||
|
||||
describe('#emojiIndex', () => {
|
||||
describe('search', function() {
|
||||
it('should work', () => {
|
||||
expect(emojiIndex.search('pineapple')).toEqual([{
|
||||
id: 'pineapple',
|
||||
name: 'Pineapple',
|
||||
colons: ':pineapple:',
|
||||
emoticons: [ ],
|
||||
skin: null,
|
||||
native: '🍍'
|
||||
}]);
|
||||
});
|
||||
|
||||
// This is the unit test for pull request (https://github.com/missive/emoji-mart/pull/43)
|
||||
// it('should filter only emojis we care about, exclude pineapple', () => {
|
||||
// let emojisToShowFilter = (unified) => unified !== '1F34D';
|
||||
// expect(emojiIndex.search('apple', emojisToShowFilter).map((obj) => obj.id))
|
||||
// .not.toContain('pineapple');
|
||||
// });
|
||||
});
|
||||
});
|
|
@ -2,6 +2,9 @@ var path = require('path')
|
|||
var pack = require('../package.json')
|
||||
var webpack = require('webpack')
|
||||
|
||||
var PROD = process.env.NODE_ENV === 'production';
|
||||
var TEST = process.env.NODE_ENV === 'test';
|
||||
|
||||
module.exports = {
|
||||
entry: path.resolve('src/index.js'),
|
||||
output: {
|
||||
|
@ -11,7 +14,7 @@ module.exports = {
|
|||
libraryTarget: 'umd',
|
||||
},
|
||||
|
||||
externals: [{
|
||||
externals: !TEST && [{
|
||||
'react': {
|
||||
root: 'React',
|
||||
commonjs2: 'react',
|
||||
|
|
Loading…
Reference in New Issue