Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
c56fde89
Unverified
Commit
c56fde89
authored
Nov 15, 2016
by
Benjamin Coe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add test coverage
parent
462c12ba
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
131 additions
and
45 deletions
+131
-45
.babelrc
.babelrc
+14
-0
.gitignore
.gitignore
+4
-0
.travis.yml
.travis.yml
+1
-0
README.md
README.md
+2
-0
gulpfile.js
gulpfile.js
+10
-30
document.js
lib/document.js
+3
-1
package.json
package.json
+38
-3
head.js
test/fixtures/basic/pages/head.js
+0
-1
link.js
test/fixtures/basic/pages/link.js
+5
-0
integration.test.js
test/integration.test.js
+15
-10
shallow-equals.test.js
test/lib/shallow-equals.test.js
+39
-0
No files found.
.babelrc
0 → 100644
View file @
c56fde89
{
"presets": ["es2015", "react"],
"plugins": [
"transform-async-to-generator",
"transform-object-rest-spread",
"transform-class-properties",
"transform-runtime"
],
"env": {
"test": {
"plugins": ["istanbul"]
}
}
}
.gitignore
View file @
c56fde89
...
@@ -10,3 +10,7 @@ npm-debug.log
...
@@ -10,3 +10,7 @@ npm-debug.log
# other
# other
.next
.next
# coverage
.nyc_output
coverage
.travis.yml
View file @
c56fde89
...
@@ -6,3 +6,4 @@ node_js:
...
@@ -6,3 +6,4 @@ node_js:
cache
:
cache
:
directories
:
directories
:
-
node_modules
-
node_modules
after_script
:
npm run coveralls
README.md
View file @
c56fde89
<img
width=
"112"
alt=
"screen shot 2016-10-25 at 2 37 27 pm"
src=
"https://cloud.githubusercontent.com/assets/13041/19686250/971bf7f8-9ac0-11e6-975c-188defd82df1.png"
>
<img
width=
"112"
alt=
"screen shot 2016-10-25 at 2 37 27 pm"
src=
"https://cloud.githubusercontent.com/assets/13041/19686250/971bf7f8-9ac0-11e6-975c-188defd82df1.png"
>
[

](https://travis-ci.org/zeit/next.js)
[

](https://travis-ci.org/zeit/next.js)
[

](https://coveralls.io/r/zeit/next.js?branch=master)
[

](https://zeit.chat)
[

](https://zeit.chat)
Next.js is a minimalistic framework for server-rendered React applications.
Next.js is a minimalistic framework for server-rendered React applications.
...
...
gulpfile.js
View file @
c56fde89
const
fs
=
require
(
'fs'
)
const
gulp
=
require
(
'gulp'
)
const
gulp
=
require
(
'gulp'
)
const
babel
=
require
(
'gulp-babel'
)
const
babel
=
require
(
'gulp-babel'
)
const
cache
=
require
(
'gulp-cached'
)
const
cache
=
require
(
'gulp-cached'
)
...
@@ -8,15 +9,7 @@ const sequence = require('run-sequence')
...
@@ -8,15 +9,7 @@ const sequence = require('run-sequence')
const
webpack
=
require
(
'webpack-stream'
)
const
webpack
=
require
(
'webpack-stream'
)
const
del
=
require
(
'del'
)
const
del
=
require
(
'del'
)
const
babelOptions
=
{
const
babelOptions
=
JSON
.
parse
(
fs
.
readFileSync
(
'.babelrc'
,
'utf-8'
))
presets
:
[
'es2015'
,
'react'
],
plugins
:
[
'transform-async-to-generator'
,
'transform-object-rest-spread'
,
'transform-class-properties'
,
'transform-runtime'
]
}
gulp
.
task
(
'compile'
,
[
gulp
.
task
(
'compile'
,
[
'compile-bin'
,
'compile-bin'
,
...
@@ -57,14 +50,6 @@ gulp.task('compile-client', () => {
...
@@ -57,14 +50,6 @@ gulp.task('compile-client', () => {
.
pipe
(
notify
(
'Compiled client files'
))
.
pipe
(
notify
(
'Compiled client files'
))
})
})
gulp
.
task
(
'compile-test'
,
()
=>
{
return
gulp
.
src
(
'test/*.js'
)
.
pipe
(
cache
(
'test'
))
.
pipe
(
babel
(
babelOptions
))
.
pipe
(
gulp
.
dest
(
'dist/test'
))
.
pipe
(
notify
(
'Compiled test files'
))
})
gulp
.
task
(
'copy'
,
[
'copy-pages'
])
gulp
.
task
(
'copy'
,
[
'copy-pages'
])
gulp
.
task
(
'copy-pages'
,
()
=>
{
gulp
.
task
(
'copy-pages'
,
()
=>
{
...
@@ -72,11 +57,6 @@ gulp.task('copy-pages', () => {
...
@@ -72,11 +57,6 @@ gulp.task('copy-pages', () => {
.
pipe
(
gulp
.
dest
(
'dist/pages'
))
.
pipe
(
gulp
.
dest
(
'dist/pages'
))
})
})
gulp
.
task
(
'copy-test-fixtures'
,
()
=>
{
return
gulp
.
src
(
'test/fixtures/**/*'
)
.
pipe
(
gulp
.
dest
(
'dist/test/fixtures'
))
})
gulp
.
task
(
'compile-bench'
,
()
=>
{
gulp
.
task
(
'compile-bench'
,
()
=>
{
return
gulp
.
src
(
'bench/*.js'
)
return
gulp
.
src
(
'bench/*.js'
)
.
pipe
(
cache
(
'bench'
))
.
pipe
(
cache
(
'bench'
))
...
@@ -153,9 +133,13 @@ gulp.task('build-client', ['compile-lib', 'compile-client'], () => {
...
@@ -153,9 +133,13 @@ gulp.task('build-client', ['compile-lib', 'compile-client'], () => {
.
pipe
(
notify
(
'Built release client'
))
.
pipe
(
notify
(
'Built release client'
))
})
})
gulp
.
task
(
'test'
,
[
'compile'
,
'copy'
,
'compile-test'
,
'copy-test-fixtures'
],
()
=>
{
gulp
.
task
(
'test'
,
()
=>
{
return
gulp
.
src
(
'dist/test/*.js'
)
process
.
env
.
NODE_ENV
=
'test'
.
pipe
(
ava
())
return
gulp
.
src
(
'test/**/**.test.js'
)
.
pipe
(
ava
({
verbose
:
true
,
nyc
:
true
}))
})
})
gulp
.
task
(
'bench'
,
[
'compile'
,
'copy'
,
'compile-bench'
,
'copy-bench-fixtures'
],
()
=>
{
gulp
.
task
(
'bench'
,
[
'compile'
,
'copy'
,
'compile-bench'
,
'copy-bench-fixtures'
],
()
=>
{
...
@@ -209,10 +193,6 @@ gulp.task('clean', () => {
...
@@ -209,10 +193,6 @@ gulp.task('clean', () => {
return
del
(
'dist'
)
return
del
(
'dist'
)
})
})
gulp
.
task
(
'clean-test'
,
()
=>
{
return
del
(
'dist/test'
)
})
gulp
.
task
(
'default'
,
[
gulp
.
task
(
'default'
,
[
'compile'
,
'compile'
,
'build'
,
'build'
,
...
@@ -227,7 +207,7 @@ gulp.task('release', (cb) => {
...
@@ -227,7 +207,7 @@ gulp.task('release', (cb) => {
'build'
,
'build'
,
'copy'
,
'copy'
,
'test'
'test'
],
'clean-test'
,
cb
)
],
cb
)
})
})
// avoid logging to the console
// avoid logging to the console
...
...
lib/document.js
View file @
c56fde89
import
React
from
'react'
import
React
from
'react'
import
htmlescape
from
'htmlescape'
import
htmlescape
from
'htmlescape'
import
pkg
from
'../../package.json'
import
readPkgUp
from
'read-pkg-up'
const
pkg
=
readPkgUp
.
sync
({
normalize
:
false
}).
pkg
export
default
({
head
,
css
,
html
,
data
,
dev
,
staticMarkup
,
cdn
})
=>
{
export
default
({
head
,
css
,
html
,
data
,
dev
,
staticMarkup
,
cdn
})
=>
{
return
<
html
>
return
<
html
>
...
...
package.json
View file @
c56fde89
...
@@ -16,13 +16,35 @@
...
@@ -16,13 +16,35 @@
},
},
"scripts"
:
{
"scripts"
:
{
"build"
:
"gulp"
,
"build"
:
"gulp"
,
"test"
:
"npm run lint && gulp test"
,
"pretest"
:
"npm run lint"
,
"test"
:
"gulp test"
,
"lint"
:
"standard && standard bin/*"
,
"lint"
:
"standard && standard bin/*"
,
"html-report"
:
"nyc report --reporter=html"
,
"coveralls"
:
"nyc report --reporter=text-lcov | coveralls"
,
"prepublish"
:
"gulp release"
,
"prepublish"
:
"gulp release"
,
"precommit"
:
"npm run lint"
"precommit"
:
"npm run lint"
},
},
"ava"
:
{
"nyc"
:
{
"babel"
:
{}
"require"
:
[
"babel-register"
],
"exclude"
:
[
"gulpfile.js"
,
"css.js"
,
"link.js"
,
"head.js"
,
"client/**"
,
"**/pages/**"
,
"**/coverage/**"
,
"**/client/**"
,
"**/test/**"
,
"**/dist/**"
,
"**/examples/**"
,
"**/bench/**"
],
"all"
:
true
,
"sourceMap"
:
false
,
"instrument"
:
false
},
},
"standard"
:
{
"standard"
:
{
"parser"
:
"babel-eslint"
"parser"
:
"babel-eslint"
...
@@ -54,11 +76,14 @@
...
@@ -54,11 +76,14 @@
"react"
:
"15.4.0"
,
"react"
:
"15.4.0"
,
"react-dom"
:
"15.4.0"
,
"react-dom"
:
"15.4.0"
,
"react-hot-loader"
:
"3.0.0-beta.6"
,
"react-hot-loader"
:
"3.0.0-beta.6"
,
"read-pkg-up"
:
"2.0.0"
,
"send"
:
"0.14.1"
,
"send"
:
"0.14.1"
,
"sockjs-client"
:
"1.1.1"
,
"strip-ansi"
:
"3.0.1"
,
"strip-ansi"
:
"3.0.1"
,
"url"
:
"0.11.0"
,
"url"
:
"0.11.0"
,
"webpack"
:
"1.13.3"
,
"webpack"
:
"1.13.3"
,
"webpack-dev-server"
:
"1.16.2"
,
"webpack-dev-server"
:
"1.16.2"
,
<<<<<<<
HEAD
"sockjs-client"
:
"1.1.1"
,
"sockjs-client"
:
"1.1.1"
,
"write-file-webpack-plugin"
:
"3.4.2"
"write-file-webpack-plugin"
:
"3.4.2"
},
},
...
@@ -67,6 +92,15 @@
...
@@ -67,6 +92,15 @@
"babel-eslint"
:
"7.1.1"
,
"babel-eslint"
:
"7.1.1"
,
"babel-plugin-transform-remove-strict-mode"
:
"0.0.2"
,
"babel-plugin-transform-remove-strict-mode"
:
"0.0.2"
,
"benchmark"
:
"2.1.2"
,
"benchmark"
:
"2.1.2"
,
"write-file-webpack-plugin"
:
"3.3.0"
},
"devDependencies"
:
{
"ava"
:
"0.16.0"
,
"babel-eslint"
:
"7.0.0"
,
"babel-plugin-istanbul"
:
"3.0.0"
,
"babel-plugin-transform-remove-strict-mode"
:
"0.0.2"
,
"benchmark"
:
"2.1.1"
,
"coveralls"
:
"2.11.15"
,
"gulp"
:
"3.9.1"
,
"gulp"
:
"3.9.1"
,
"gulp-ava"
:
"0.15.0"
,
"gulp-ava"
:
"0.15.0"
,
"gulp-babel"
:
"6.1.2"
,
"gulp-babel"
:
"6.1.2"
,
...
@@ -74,6 +108,7 @@
...
@@ -74,6 +108,7 @@
"gulp-cached"
:
"1.1.1"
,
"gulp-cached"
:
"1.1.1"
,
"gulp-notify"
:
"2.2.0"
,
"gulp-notify"
:
"2.2.0"
,
"husky"
:
"0.11.9"
,
"husky"
:
"0.11.9"
,
"nyc"
:
"9.0.1"
,
"run-sequence"
:
"1.2.2"
,
"run-sequence"
:
"1.2.2"
,
"standard"
:
"8.5.0"
,
"standard"
:
"8.5.0"
,
"webpack-stream"
:
"3.2.0"
"webpack-stream"
:
"3.2.0"
...
...
test/fixtures/basic/pages/head.js
View file @
c56fde89
import
React
from
'react'
import
React
from
'react'
import
Head
from
'next/head'
import
Head
from
'next/head'
...
...
test/fixtures/basic/pages/link.js
0 → 100644
View file @
c56fde89
import
React
from
'react'
import
Link
from
'next/link'
export
default
()
=>
(
<
div
>
Hello
World
.
<
Link
href
=
'/about'
>
About
<
/Link></
div
>
)
test/in
dex
.js
→
test/in
tegration.test
.js
View file @
c56fde89
...
@@ -7,35 +7,40 @@ const dir = join(__dirname, 'fixtures', 'basic')
...
@@ -7,35 +7,40 @@ const dir = join(__dirname, 'fixtures', 'basic')
test
.
before
(()
=>
build
(
dir
))
test
.
before
(()
=>
build
(
dir
))
test
(
async
t
=>
{
test
(
'renders a stateless component'
,
async
t
=>
{
const
html
=
await
render
(
'/stateless'
)
const
html
=
await
render
(
'/stateless'
)
t
.
true
(
html
.
includes
(
'<meta charset="utf-8" class="next-head"/>'
))
t
.
true
(
html
.
includes
(
'<meta charset="utf-8" class="next-head"/>'
))
t
.
true
(
html
.
includes
(
'<h1>My component!</h1>'
))
t
.
true
(
html
.
includes
(
'<h1>My component!</h1>'
))
})
})
test
(
async
t
=>
{
test
(
'renders a stateful component'
,
async
t
=>
{
const
html
=
await
render
(
'/css'
)
t
.
true
(
html
.
includes
(
'.css-im3wl1'
))
t
.
true
(
html
.
includes
(
'<div class="css-im3wl1">This is red</div>'
))
})
test
(
async
t
=>
{
const
html
=
await
render
(
'/stateful'
)
const
html
=
await
render
(
'/stateful'
)
t
.
true
(
html
.
includes
(
'<div><p>The answer is 42</p></div>'
))
t
.
true
(
html
.
includes
(
'<div><p>The answer is 42</p></div>'
))
})
})
test
(
async
t
=>
{
test
(
'header helper renders header information'
,
async
t
=>
{
const
html
=
await
(
render
(
'/head'
))
const
html
=
await
(
render
(
'/head'
))
t
.
true
(
html
.
includes
(
'<meta charset="iso-8859-5" class="next-head"/>'
))
t
.
true
(
html
.
includes
(
'<meta charset="iso-8859-5" class="next-head"/>'
))
t
.
true
(
html
.
includes
(
'<meta content="my meta" class="next-head"/>'
))
t
.
true
(
html
.
includes
(
'<meta content="my meta" class="next-head"/>'
))
t
.
true
(
html
.
includes
(
'<div><h1>I can haz meta tags</h1></div>'
))
t
.
true
(
html
.
includes
(
'<div><h1>I can haz meta tags</h1></div>'
))
})
})
test
(
async
t
=>
{
test
(
'css helper renders styles'
,
async
t
=>
{
const
html
=
await
render
(
'/css'
)
t
.
true
(
html
.
includes
(
'.css-im3wl1'
))
t
.
true
(
html
.
includes
(
'<div class="css-im3wl1">This is red</div>'
))
})
test
(
'renders properties populated asynchronously'
,
async
t
=>
{
const
html
=
await
render
(
'/async-props'
)
const
html
=
await
render
(
'/async-props'
)
t
.
true
(
html
.
includes
(
'<p>Diego Milito</p>'
))
t
.
true
(
html
.
includes
(
'<p>Diego Milito</p>'
))
})
})
test
(
'renders a link component'
,
async
t
=>
{
const
html
=
await
render
(
'/link'
)
t
.
true
(
html
.
includes
(
'<a href="/about">About</a>'
))
})
function
render
(
url
,
ctx
)
{
function
render
(
url
,
ctx
)
{
return
_render
(
url
,
ctx
,
{
dir
,
staticMarkup
:
true
})
return
_render
(
url
,
ctx
,
{
dir
,
staticMarkup
:
true
})
}
}
test/lib/shallow-equals.test.js
0 → 100644
View file @
c56fde89
import
test
from
'ava'
import
shallowEquals
from
'../../lib/shallow-equals'
test
(
'returns true if all key/value pairs match'
,
t
=>
{
t
.
true
(
shallowEquals
({
a
:
1
,
b
:
2
,
c
:
99
},
{
a
:
1
,
b
:
2
,
c
:
99
}))
})
test
(
'returns false if any key/value pair is different'
,
t
=>
{
t
.
false
(
shallowEquals
({
a
:
1
,
b
:
2
,
c
:
99
},
{
a
:
1
,
b
:
2
,
c
:
99
,
d
:
33
}))
})
test
(
'returns false if nested objects are contained'
,
t
=>
{
t
.
false
(
shallowEquals
({
a
:
1
,
b
:
2
,
c
:
{}
},
{
a
:
1
,
b
:
2
,
c
:
{}
}))
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment