Vaguely working webpack test
parent
f60dd93660
commit
d7801ef3a4
|
@ -2,23 +2,73 @@
|
||||||
var webpack = require('webpack');
|
var webpack = require('webpack');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* It's a pain to have to wait for webpack to build everything; however it's
|
||||||
|
* the easiest way to load our dependencies from node_modules.
|
||||||
|
*/
|
||||||
module.exports = function (config) {
|
module.exports = function (config) {
|
||||||
config.set({
|
config.set({
|
||||||
browsers: ['Chrome'],
|
// frameworks to use
|
||||||
singleRun: true,
|
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||||
frameworks: ['mocha'],
|
frameworks: ['mocha'],
|
||||||
|
|
||||||
|
// list of files / patterns to load in the browser
|
||||||
files: [
|
files: [
|
||||||
'tests/tests.js'
|
'test/tests.js'
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// preprocess matching files before serving them to the browser
|
||||||
|
// available preprocessors:
|
||||||
|
// https://npmjs.org/browse/keyword/karma-preprocessor
|
||||||
preprocessors: {
|
preprocessors: {
|
||||||
'tests/tests.js': ['webpack', 'sourcemap']
|
'test/tests.js': ['webpack', 'sourcemap']
|
||||||
},
|
},
|
||||||
reporters: ['dots'],
|
|
||||||
|
// 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',
|
||||||
|
//'PhantomJS',
|
||||||
|
],
|
||||||
|
|
||||||
|
// Continuous Integration mode
|
||||||
|
// if true, Karma captures browsers, runs the tests and exits
|
||||||
|
singleRun: true,
|
||||||
|
|
||||||
|
// Concurrency level
|
||||||
|
// how many browser should be started simultaneous
|
||||||
|
concurrency: Infinity,
|
||||||
|
|
||||||
webpack: {
|
webpack: {
|
||||||
module: {
|
module: {
|
||||||
loaders: [
|
loaders: [
|
||||||
{ test: /\.json$/, loader: "json" },
|
{ test: /\.json$/, loader: "json" },
|
||||||
{ test: /\.js$/, loader: "babel", include: path.resolve('./src') },
|
{ test: /\.js$/, loader: "babel",
|
||||||
|
include: [path.resolve('./src'),
|
||||||
|
path.resolve('./test'),
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
noParse: [
|
noParse: [
|
||||||
// don't parse the languages within highlight.js. They
|
// don't parse the languages within highlight.js. They
|
||||||
|
@ -32,6 +82,8 @@ module.exports = function (config) {
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'matrix-react-sdk': path.resolve('src/index.js'),
|
'matrix-react-sdk': path.resolve('src/index.js'),
|
||||||
|
// todo: make this go via an include path?
|
||||||
|
'test-component-index': path.resolve('test/test-component-index.js'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
var React = require('react');
|
||||||
|
var TestUtils = require('react-addons-test-utils');
|
||||||
|
var expect = require('expect');
|
||||||
|
|
||||||
|
var sdk = require('matrix-react-sdk');
|
||||||
|
var MatrixChat;
|
||||||
|
|
||||||
|
describe('MatrixChat', function () {
|
||||||
|
before(function() {
|
||||||
|
MatrixChat = sdk.getComponent('structures.MatrixChat');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('gives a login panel by default', function () {
|
||||||
|
var res = TestUtils.renderIntoDocument(
|
||||||
|
<MatrixChat config={{}}/>
|
||||||
|
);
|
||||||
|
|
||||||
|
// we expect a single <Login> component
|
||||||
|
TestUtils.findRenderedComponentWithType(
|
||||||
|
res, sdk.getComponent('structures.login.Login'));
|
||||||
|
});
|
||||||
|
});
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
// this is a handly place to make sure the sdk has been skinned
|
// this is a handly place to make sure the sdk has been skinned
|
||||||
var sdk = require("matrix-react-sdk");
|
var sdk = require("matrix-react-sdk");
|
||||||
sdk.loadSkin(require('../src/component-index'));
|
sdk.loadSkin(require('test-component-index'));
|
||||||
|
|
||||||
var context = require.context('.', true, /-test\.jsx?$/);
|
var context = require.context('.', true, /-test\.jsx?$/);
|
||||||
context.keys().forEach(context);
|
context.keys().forEach(context);
|
|
@ -1,11 +0,0 @@
|
||||||
var React = require('react');
|
|
||||||
var expect = require('expect');
|
|
||||||
|
|
||||||
var sdk = require("matrix-react-sdk");
|
|
||||||
|
|
||||||
var MatrixChat = sdk.getComponent('structures.MatrixChat');
|
|
||||||
|
|
||||||
describe('MatrixChat', function () {
|
|
||||||
it('does something', function () {
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
Reference in New Issue