Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit 251ae2c

Browse files
committed
Fix test runability. Remove tests that were not adding much value. Need to rethink overall testing strategy.
1 parent 26277f0 commit 251ae2c

File tree

5 files changed

+6
-118
lines changed

5 files changed

+6
-118
lines changed

.testem.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
12
framework: mocha
23

34
src_files:
45
- lib/**/*.js
56
- test/**/*.coffee
67

78
serve_files:
8-
- build/**/*.js
9+
- build/**/index.js
910

10-
before_tests: ./node_modules/.bin/webpack --config webpack.test.config.js
11+
before_tests: ./node_modules/.bin/webpack --config webpack.test.config.babel.js
1112

1213
launch_in_dev:
1314
- chrome
14-
- safari
15-
- firefox

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"react-hot-loader": "^1.2.4",
4545
"react-tappable": "^0.6.0",
4646
"style-loader": "^0.12.3",
47+
"testem": "^0.9.6",
4748
"webpack": "^1.12.1",
4849
"webpack-dev-server": "^1.10.1"
4950
},

test/_globals.coffee

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,3 @@ g.testUtils = React.addons.TestUtils
66
g.sim = testUtils.Simulate
77
g.Popover = require '../lib'
88
g.e = React.DOM
9-
Object.assign = require 'object.assign'
10-
11-
12-
13-
g.$ = (query, el)->
14-
if el
15-
React.findDOMNode(el).querySelector query
16-
else
17-
document.querySelector query
18-
19-
g.renderApp = (reactElementFactory, cb)->
20-
React.render reactElementFactory, $('#app'), cb
21-
22-
g.getPopoverPosition = ->
23-
measure $ '.Popover'
24-
25-
Object.assign window, require '../lib/utils'
26-
27-
before ->
28-
el = document.createElement 'div'
29-
el.id = 'app'
30-
document.body.appendChild el
31-
32-
afterEach ->
33-
#$ '#app'
34-
#.innerHTML = ''
35-

test/index.coffee

Lines changed: 1 addition & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,9 @@
11
require './_globals.coffee'
22

3-
Tracer = React.createFactory React.createClass
4-
name: 'tracer'
5-
6-
getInitialState: ->
7-
isOpen: false
8-
9-
getInitialProps: ->
10-
style: this.props.style || {}
11-
12-
togglePopover: ->
13-
this.setState
14-
isOpen: !this.state.isOpen
15-
16-
render: ->
17-
defaultStyle =
18-
position: 'absolute'
19-
background: 'red'
20-
top: 0
21-
left: 0
22-
width: 50
23-
height: 50
24-
25-
style = Object.assign defaultStyle, this.props.style
26-
27-
target = (
28-
e.div
29-
className: 'handle Target'
30-
style: style
31-
onClick: this.togglePopover
32-
)
33-
34-
React.createElement(Popover, {
35-
isOpen: this.props.isOpen
36-
}, target)
37-
38-
39-
40-
renderTracer = (props = {})->
41-
new Promise (resolve)->
42-
renderApp Tracer(props), ->
43-
targetEl = $ '.Target'
44-
sim.click targetEl, this
45-
resolve [targetEl, $ '.Popover']
46-
.tap -> Promise.delay 500
47-
48-
49-
50-
describe 'react-popover', ->
51-
52-
it 'is a rendered element', ->
53-
renderTracer (target, popover)->
54-
a popover, 'Popover is rendered'
55-
563

574

585
describe 'react-popover rendering', ->
596

60-
it 'should layout in the zone with the largest area', ->
61-
renderTracer style: left: '90%', transform: 'translateX(-50%)'
62-
.spread (l, p)->
63-
pb = calcBounds p
64-
lb = calcBounds l
65-
if isLandscape()
66-
console.log pb.y, lb.y
67-
a pb.x2 < lb.x, 'Popover is left of target'
68-
a pb.y is lb.y, 'Popover is equal y of target'
69-
else
70-
console.log pb.y, lb.y2
71-
a pb.y > lb.y2, 'Popover is bottom of target'
72-
a (pb.x < lb.x2 and pb.x2 > lb.x2), 'Popover is cross-axes-centered of target'
73-
7+
it 'should layout in the zone with the largest area'
748
it 'body should autosize to dimensions of content'
759
it 'body should not autosize beyond frame bounds'
76-
77-
78-
79-
80-
81-
82-
83-
calcOrientation = ->
84-
if window.innerWidth > window.innerHeight then 'landscape' else 'portrait'
85-
86-
isLandscape = ->
87-
calcOrientation() is 'landscape'
88-
89-
90-
91-

webpack.test.config.babel.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
},
1313
output: {
1414
path: outputDir,
15-
filename: `[name].js`,
15+
filename: `index.js`,
1616
},
1717
module: {
1818
loaders: [
@@ -21,7 +21,4 @@ export default {
2121
],
2222
},
2323
devtool: `source-map`,
24-
devServer: {
25-
contentBase: outputDir,
26-
},
2724
}

0 commit comments

Comments
 (0)