Skip to content

Instantly share code, notes, and snippets.

@ptim
Last active December 14, 2016 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptim/8032ddde1be3e4d292b1e7cff6a97891 to your computer and use it in GitHub Desktop.
Save ptim/8032ddde1be3e4d292b1e7cff6a97891 to your computer and use it in GitHub Desktop.
esnextbin sketch
<html>
<head>
<meta charset="utf-8">
<title>Mocha Tests</title>
<link href="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.css" rel="stylesheet" />
</head>
<body>
<div id="mocha"></div>
<script src="https://cdn.rawgit.com/jquery/jquery/2.1.4/dist/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/Automattic/expect.js/0.3.1/index.js"></script>
<script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
</body>
</html>
// based on: https://mochajs.org/#running-mocha-in-the-browser
mocha.setup('bdd')
mocha.checkLeaks();
mocha.globals(['jQuery']);
import React from 'react';
// import { shallow } from 'enzyme';
const props = {title: 'Hell World'};
const Component = ({ title }) => <h1>{title}</h1>;
// const rendered = React.renderToString(App);
console.log(Component(props));
describe('framework test', () => {
it('should pass', () => {
expect(true).to.be(true);
});
});
describe('<Component />', () => {
it('should be a function', () => {
expect(Component).to.be.a('function');
});
it('should be a h1', () => {
expect(Component(props).type).to.be('h1');
});
});
describe('enzyme <Component />', () => {
// const wrapper = shallow(<Component {...props} />);
// it('should be a function', () => {
// expect(wrapper.type).to.be('div');
// });
});
mocha.run();
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"devDependencies": {
"enzyme": "2.4.1",
"react-addons-test-utils": "15.2.1"
},
"dependencies": {
"react": "15.2.1"
}
}
'use strict';
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// based on: https://mochajs.org/#running-mocha-in-the-browser
mocha.setup('bdd');
mocha.checkLeaks();
mocha.globals(['jQuery']);
// import { shallow } from 'enzyme';
var props = { title: 'Hell World' };
var Component = function Component(_ref) {
var title = _ref.title;
return _react2.default.createElement(
'h1',
null,
title
);
};
// const rendered = React.renderToString(App);
console.log(Component(props));
describe('framework test', function () {
it('should pass', function () {
expect(true).to.be(true);
});
});
describe('<Component />', function () {
it('should be a function', function () {
expect(Component).to.be.a('function');
});
it('should be a h1', function () {
expect(Component(props).type).to.be('h1');
});
});
describe('enzyme <Component />', function () {
// const wrapper = shallow(<Component {...props} />);
// it('should be a function', () => {
// expect(wrapper.type).to.be('div');
// });
});
mocha.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment