This repository has been archived by the owner on Apr 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
c.destroy broken test against master #103
Open
jadbox
wants to merge
2
commits into
garbles:master
Choose a base branch
from
jadbox:jadbox-cdestroy-broken-test
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* @flow weak */ | ||
|
||
import $ from 'jquery' | ||
import {Observable} from 'rxjs/Observable' | ||
import {renderInDocument} from './support/renderInDocument' | ||
import {h} from '../h' | ||
|
||
import 'rxjs/add/observable/interval' | ||
import 'rxjs/add/observable/from' | ||
import 'rxjs/add/observable/of' | ||
import 'rxjs/add/operator/map' | ||
import 'rxjs/add/operator/merge' | ||
import 'rxjs/add/operator/mergeMap' | ||
import 'rxjs/add/operator/scan' | ||
import 'rxjs/add/operator/startWith' | ||
import 'rxjs/add/operator/combineLatest' | ||
|
||
describe(`Issues regression tests`, () => { | ||
it(`Adds jsx null/empty elements`, () => { | ||
function NullChildren () { | ||
return h(`div`, {id: `children`}, [ | ||
null, | ||
Observable.from([null]), | ||
``, | ||
Observable.from([``]), | ||
Observable.of(h(`p`, null, `actual child`)), | ||
]) | ||
} | ||
|
||
const vnode = h(NullChildren) | ||
const {node, cleanup} = renderInDocument(vnode) | ||
|
||
assert.equal(node.children.length, 1) | ||
cleanup() | ||
}) | ||
|
||
it(`Removes simple children with text after clicking without keys: #101`, () => { | ||
function DestroyChildren ({createEventHandler}) { | ||
const handleAdd = createEventHandler(1) | ||
const handleRemove = createEventHandler(-1) | ||
|
||
const lenToElements = tag => (len: number) => { | ||
const els = Array(len) | ||
let i = -1 | ||
|
||
while (++i < len) { | ||
let elem = null | ||
if (tag === `b`) elem = h(`b`, {}, `b element`) | ||
else if (tag === `p`) elem = h(`p`, {}, `element`) | ||
|
||
els[i] = elem | ||
} | ||
|
||
return els | ||
} | ||
|
||
const addable = handleAdd.scan((acc, i) => acc + i, 1).startWith(1).map(lenToElements(`b`)) | ||
const removeable = handleRemove.scan((acc, i) => acc + i, 4).startWith(4).map(lenToElements(`p`)) | ||
|
||
return h(`div`, {id: `layer1`}, | ||
Observable.of(``), | ||
h(`div`, {id: `children`}, [ | ||
addable, | ||
removeable, | ||
]), | ||
h(`button`, {id: `add`, onClick: handleAdd}), | ||
h(`button`, {id: `remove`, onClick: handleRemove}) | ||
) | ||
} | ||
|
||
const component = h(DestroyChildren) | ||
const {node, cleanup} = renderInDocument(component) | ||
|
||
const adder = $(`#add`) | ||
const remover = $(`#remove`) | ||
const children = node.querySelector(`#children`) | ||
|
||
assert.equal(children.children.length, 5) | ||
assert.equal(children.children[0].tagName, `B`) | ||
assert.equal(children.children[1].tagName, `P`) | ||
assert.equal(children.children[2].tagName, `P`) | ||
assert.equal(children.children[3].tagName, `P`) | ||
assert.equal(children.children[4].tagName, `P`) | ||
|
||
remover.trigger(`click`) | ||
|
||
assert.equal(children.children.length, 4) | ||
assert.equal(children.children[0].tagName, `B`) | ||
assert.equal(children.children[1].tagName, `P`) | ||
assert.equal(children.children[2].tagName, `P`) | ||
assert.equal(children.children[3].tagName, `P`) | ||
|
||
remover.trigger(`click`) | ||
remover.trigger(`click`) | ||
|
||
assert.equal(children.children.length, 2) | ||
assert.equal(children.children[0].tagName, `B`) | ||
assert.equal(children.children[1].tagName, `P`) | ||
|
||
adder.trigger(`click`) | ||
adder.trigger(`click`) | ||
|
||
assert.equal(children.children.length, 4) | ||
assert.equal(children.children[0].tagName, `B`) | ||
assert.equal(children.children[1].tagName, `B`) | ||
assert.equal(children.children[2].tagName, `B`) | ||
assert.equal(children.children[3].tagName, `P`) | ||
|
||
cleanup() | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these two lines add anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They use to, but the code that used it was moved to the regression test file. It might be useful to keep them as they are such a common tool to use with Rx anyway.