Skip to content

Commit

Permalink
Move examples, delete old files and add basic testing example
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed May 18, 2015
1 parent 664ead3 commit b22aae3
Show file tree
Hide file tree
Showing 75 changed files with 98 additions and 231 deletions.
49 changes: 0 additions & 49 deletions examples/bundle.js

This file was deleted.

1 change: 0 additions & 1 deletion examples/bundle.js.map

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions examples/dustbin-simple/__tests__/Box-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import TestUtils from 'react/lib/ReactTestUtils';
import wrapInTestContext from '../../shared/wrapInTestContext';
import expect from 'expect';
import Box from '../Box';

describe('Box', () => {
it('changes opacity when dragged', () => {
const BoxContext = wrapInTestContext(Box);

const root = TestUtils.renderIntoDocument(<BoxContext name='test' />);
const backend = root.getManager().getBackend();

let div = TestUtils.findRenderedDOMComponentWithTag(root, 'div');
expect(div.props.style.opacity).toEqual(1);

const box = TestUtils.findRenderedComponentWithType(root, Box);
backend.simulateBeginDrag([box.getHandlerId()]);

div = TestUtils.findRenderedDOMComponentWithTag(root, 'div');
expect(div.props.style.opacity).toEqual(0.4);
});
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 0 additions & 9 deletions examples/index.html

This file was deleted.

61 changes: 0 additions & 61 deletions examples/index.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions examples/shared/wrapInTestContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, { Component } from 'react';
import { createTestBackend } from 'dnd-core';
import { DragDropContext } from 'react-dnd';

export default function wrapInTestContext(DecoratedComponent) {
@DragDropContext(createTestBackend)
class TestStub extends Component {
render() {
return <DecoratedComponent {...this.props} />;
}
}

return TestStub;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 0 additions & 33 deletions examples/styles.css

This file was deleted.

24 changes: 0 additions & 24 deletions examples/webpack.config.js

This file was deleted.

40 changes: 0 additions & 40 deletions examples/webpack.config.production.js

This file was deleted.

33 changes: 33 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var path = require('path');

module.exports = function (config) {
config.set({
browsers: ['Chrome'],
singleRun: true,
frameworks: ['mocha'],
files: [
'tests.webpack.js'
],
preprocessors: {
'tests.webpack.js': ['webpack', 'sourcemap']
},
reporters: ['dots'],
webpack: {
devtool: 'inline-source-map',
module: {
loaders: [
{ test: /\.js$/, loaders: ['babel'], exclude: /node_modules/ }
]
},
resolve: {
alias: {
'react-dnd/modules': path.join(__dirname, './src'),
'react-dnd': path.join(__dirname, './src')
}
}
},
webpackServer: {
noInfo: true
}
});
};
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"build-site": "./scripts/buildStaticSite.sh",
"publish-site": "./scripts/publishStaticSite.sh",
"build": "./scripts/build.sh",
"test": "./scripts/test.sh",
"prepublish": "npm run build"
},
"repository": {
Expand Down Expand Up @@ -35,7 +36,7 @@
"homepage": "https://github.com/gaearon/react-dnd",
"dependencies": {
"disposables": "^1.0.1",
"dnd-core": "^1.0.2",
"dnd-core": "^1.1.0",
"invariant": "^2.0.0",
"lodash": "^3.1.0"
},
Expand All @@ -51,18 +52,26 @@
"babel-loader": "^5.0.0",
"css-loader": "^0.9.1",
"eslint": "^0.20.0",
"expect": "^1.6.0",
"extract-text-webpack-plugin": "^0.3.8",
"faker": "^2.1.3",
"file-loader": "^0.8.1",
"glob": "^4.3.5",
"html-loader": "^0.2.3",
"karma": "^0.12.31",
"karma-chrome-launcher": "^0.1.12",
"karma-cli": "0.0.4",
"karma-mocha": "^0.1.10",
"karma-sourcemap-loader": "^0.3.4",
"karma-webpack": "^1.5.1",
"less": "^2.2.0",
"less-loader": "^2.0.0",
"marked": "^0.3.2",
"mocha": "^2.2.5",
"null-loader": "^0.1.0",
"postcss": "^4.0.2",
"postcss-custom-properties": "3.0.1",
"react": "~0.13.0",
"react": "^0.13.3",
"react-hot-loader": "^1.2.3",
"react-router": "~0.13.2",
"request": "2.46.0",
Expand Down
3 changes: 3 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

./node_modules/.bin/karma start
24 changes: 12 additions & 12 deletions site/IndexPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ const APIDocs = {
};

const Examples = {
DUSTBIN_SIMPLE: require('../examples/_dustbin-simple'),
DUSTBIN_INTERESTING: require('../examples/_dustbin-interesting'),
DUSTBIN_STRESS: require('../examples/_dustbin-stress'),
DRAG_AROUND_NAIVE: require('../examples/_drag-around-naive'),
DRAG_AROUND_CUSTOM: require('../examples/_drag-around-custom'),
NESTING_SOURCES: require('../examples/_nesting-sources'),
NESTING_TARGETS: require('../examples/_nesting-targets'),
SORTABLE_SIMPLE: require('../examples/_sortable-simple'),
SORTABLE_CANCELABLE: require('../examples/_sortable-cancelable'),
SORTABLE_STRESS: require('../examples/_sortable-stress'),
CUSTOMIZE_HANDLES: require('../examples/_customize-handles'),
CUSTOMIZE_EFFECTS: require('../examples/_customize-effects')
DUSTBIN_SIMPLE: require('../examples/dustbin-simple'),
DUSTBIN_INTERESTING: require('../examples/dustbin-interesting'),
DUSTBIN_STRESS: require('../examples/dustbin-stress'),
DRAG_AROUND_NAIVE: require('../examples/drag-around-naive'),
DRAG_AROUND_CUSTOM: require('../examples/drag-around-custom'),
NESTING_SOURCES: require('../examples/nesting-sources'),
NESTING_TARGETS: require('../examples/nesting-targets'),
SORTABLE_SIMPLE: require('../examples/sortable-simple'),
SORTABLE_CANCELABLE: require('../examples/sortable-cancelable'),
SORTABLE_STRESS: require('../examples/sortable-stress'),
CUSTOMIZE_HANDLES: require('../examples/customize-handles'),
CUSTOMIZE_EFFECTS: require('../examples/customize-effects')
};

export default class IndexPage extends Component {
Expand Down
2 changes: 2 additions & 0 deletions tests.webpack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var context = require.context('./examples', true, /-test\.js$/);
context.keys().forEach(context);

0 comments on commit b22aae3

Please sign in to comment.