File tree Expand file tree Collapse file tree 2 files changed +74
-0
lines changed Expand file tree Collapse file tree 2 files changed +74
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { h , render , rerender } from 'preact' ;
2
+ import { route } from 'preact-router' ;
3
+ import App from 'components/app' ;
4
+ import 'style' ;
5
+
6
+ /*global sinon,expect*/
7
+
8
+ describe ( 'App' , ( ) => {
9
+ let scratch ;
10
+
11
+ before ( ( ) => {
12
+ scratch = document . createElement ( 'div' ) ;
13
+ ( document . body || document . documentElement ) . appendChild ( scratch ) ;
14
+ } ) ;
15
+
16
+ beforeEach ( ( ) => {
17
+ scratch . innerHTML = '' ;
18
+ } ) ;
19
+
20
+ after ( ( ) => {
21
+ scratch . parentNode . removeChild ( scratch ) ;
22
+ scratch = null ;
23
+ } ) ;
24
+
25
+
26
+ describe ( 'routing' , ( ) => {
27
+ it ( 'should render the homepage' , ( ) => {
28
+ render ( < App /> , scratch ) ;
29
+
30
+ expect ( scratch . innerHTML ) . to . contain ( 'Home' ) ;
31
+ } ) ;
32
+
33
+ it ( 'should render /profile' , ( ) => {
34
+ render ( < App /> , scratch ) ;
35
+ route ( '/profile' ) ;
36
+ rerender ( ) ;
37
+
38
+ expect ( scratch . innerHTML ) . to . contain ( 'Profile: me' ) ;
39
+ } ) ;
40
+
41
+ it ( 'should render /profile/:user' , ( ) => {
42
+ render ( < App /> , scratch ) ;
43
+ route ( '/profile/john' ) ;
44
+ rerender ( ) ;
45
+
46
+ expect ( scratch . innerHTML ) . to . contain ( 'Profile: john' ) ;
47
+ } ) ;
48
+ } ) ;
49
+ } ) ;
Original file line number Diff line number Diff line change
1
+ require ( 'babel-register' ) ;
2
+ var webpack = require ( '../webpack.config.babel.js' ) ;
3
+
4
+ module . exports = function ( config ) {
5
+ config . set ( {
6
+ basePath : '../' ,
7
+ frameworks : [ 'mocha' , 'chai-sinon' ] ,
8
+ reporters : [ 'mocha' ] ,
9
+
10
+ browsers : [ 'PhantomJS' ] ,
11
+
12
+ files : [
13
+ 'test/browser/**/*.js'
14
+ ] ,
15
+
16
+ preprocessors : {
17
+ 'test/**/*.js' : [ 'webpack' ] ,
18
+ 'src/**/*.js' : [ 'webpack' ] ,
19
+ '**/*.js' : [ 'sourcemap' ]
20
+ } ,
21
+
22
+ webpack : webpack ,
23
+ webpackMiddleware : { noInfo : true }
24
+ } ) ;
25
+ } ;
You can’t perform that action at this time.
0 commit comments