Skip to content

Instantly share code, notes, and snippets.

@ahuggins
ahuggins / EditDatasource.spec.js
Created January 25, 2019 16:46
Example with Wrapper, adding MemoryRouter
import React from 'react';
import { render, mount, shallow } from 'enzyme';
import EditDatasource from './EditDatasource';
import { MemoryRouter } from 'react-router-dom';
describe('tests for EditDatasource', function () {
it.only('changes the datasource.type when a select button is clicked', function () {
const wrap = mount(
<MemoryRouter>
<EditDatasource
@ahuggins
ahuggins / EditDatasource.spec.js
Created January 25, 2019 16:36
Real World Example of Wrapper issues
import React from 'react';
import { render, mount, shallow } from 'enzyme';
import EditDatasource from './EditDatasource';
describe('tests for EditDatasource', function () {
it.only('changes the datasource.type when a select button is clicked', function () {
const wrap = mount(
<EditDatasource
notify={notify}
navigate={navigate}
@ahuggins
ahuggins / Foo.spec.js
Created January 25, 2019 15:42
Use .hostNodes() to see only DOM output
import React from 'react';
import { render, mount, shallow } from 'enzyme';
import { Foo } from 'Foo';
describe.only('Test for Foo component', function () {
it('can mount Foo component', function () {
const wrap = mount(
<Foo />
);
console.log(wrap.find('.someCustomClass').hostNodes().debug());
@ahuggins
ahuggins / Foo.spec.js
Created January 25, 2019 15:28
Debug className issue
import React from 'react';
import { render, mount, shallow } from 'enzyme';
import { Foo } from 'Foo';
describe.only('Test for Foo component', function () {
it('can mount Foo component', function () {
const wrap = mount(
<Foo />
);
console.log(wrap.find('.someCustomClass').debug());
@ahuggins
ahuggins / foo.spec.js
Created January 25, 2019 15:17
Testing className passed as a prop
import React from 'react';
import { render, mount, shallow } from 'enzyme';
import { Foo } from 'Foo';
describe.only('Test for Foo component', function () {
it('can mount Foo component', function () {
const wrap = mount(
<Foo />
);
@ahuggins
ahuggins / Foo.js
Created January 25, 2019 15:05
Another simple component example
import React from 'react';
export function Foo() {
return <div>
<div className="fooClass">
<Bar className="someCustomClass" />
</div>
</div>;
}
@ahuggins
ahuggins / Foo.spec.js
Created January 25, 2019 02:14
Foo spec for testing
import React from 'react';
import { render, mount, shallow } from 'enzyme';
import { Foo } from 'Foo';
describe('Test for Foo component', function () {
it('can mount Foo component', function () {
const wrap = shallow(
<Foo />
);
@ahuggins
ahuggins / Foo.js
Last active January 25, 2019 02:13
A simple Foo Component
import React from 'react';
import { Bar } from './Bar';
export function Foo() {
return <div>
<div className="fooClass">
<Bar />
</div>
</div>;
}
@ahuggins
ahuggins / Bar.js
Created January 24, 2019 21:23
Simple Bar Component
import React from 'react';
export function Bar() {
return <div>
<div className="barClass">Something here</div>
</div>;
}
Sample Game:
327/XX8/9/4/247/11
How many frames scored a 20 or more?
frame 1 2 3 4 5 6 7 8 9 10
balls 32 7/ X X 8/ 9/ 4/ 24 7/ 11
score 5 20 28 20 19 14 12 6 11 2
In the example above, there are 3.