Skip to content

Commit

Permalink
tests moved to spec.js files
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed Mar 20, 2016
1 parent b804a12 commit 6b7346f
Show file tree
Hide file tree
Showing 21 changed files with 59 additions and 23 deletions.
36 changes: 36 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

.cdn-cache
_book


# npmignore - content above this line is automatically generated and modifications may be omitted
# see npmjs.com/npmignore for more details.
*.spec.js
test
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const describe = require('mocha').describe
const it = require('mocha').it
const expect = require('chai').expect
const downloadPkg = require('../../../app/plugins/bundle-service/download-pkg')
const downloadPkg = require('./download-pkg')
const path = require('path')

describe('Package', function () {
Expand All @@ -15,7 +15,7 @@ describe('Package', function () {
registry: {
url: 'http://registry.npmjs.org/',
},
storagePath: path.resolve(__dirname, '../../../.cdn-cache'),
storagePath: path.resolve(process.cwd(), './.cdn-cache'),
})
.then((pkg) => {
return pkg.readFile('./lib/bar.js')
Expand All @@ -38,7 +38,7 @@ describe('Package', function () {
registry: {
url: 'http://registry.npmjs.org/',
},
storagePath: path.resolve(__dirname, '../../../.cdn-cache'),
storagePath: path.resolve(process.cwd(), './.cdn-cache'),
})
.then((pkg) => {
return pkg.readFile('./bla-bla.js')
Expand All @@ -59,7 +59,7 @@ describe('Package', function () {
registry: {
url: 'http://registry.npmjs.org/',
},
storagePath: path.resolve(__dirname, '../../../.cdn-cache'),
storagePath: path.resolve(process.cwd(), './.cdn-cache'),
})
.then((pkg) => {
return pkg.readFile('./lib/bar.js')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const describe = require('mocha').describe
const it = require('mocha').it
const expect = require('chai').expect

const getMainFile = require('../../../app/plugins/bundle-service/get-main-file')
const getMainFile = require('./get-main-file')

describe('getMainFile', () => {
describe('js', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const describe = require('mocha').describe
const it = require('mocha').it
const expect = require('chai').expect
const createRegistry = require('../../../app/plugins/bundle-service/registry')
const createRegistry = require('./registry')

describe('Registry', function () {
it('should resolve version', function (done) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const describe = require('mocha').describe
const it = require('mocha').it
const expect = require('chai').expect
const fullCssUrl = require('../../app/utils/full-css-url')
const fullCssUrl = require('./full-css-url')

describe('full css urls', function () {
it('should replace relative URL', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const describe = require('mocha').describe
const it = require('mocha').it
const expect = require('chai').expect
const parseBundleRoute = require('../../app/utils/parse-bundle-route')
const parseBundleRoute = require('./parse-bundle-route')

describe('parse package url', function () {
it('should parse one package with version', function () {
Expand Down
12 changes: 6 additions & 6 deletions test/web/bundle.js → app/web/bundle/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const expect = require('chai').expect
const express = require('express')
const hexi = require('hexi')
const R = require('ramda')
const createBundleService = require('../../app/plugins/bundle-service')
const bundle = require('../../app/web/bundle')
const registry = require('../../app/plugins/registry')
const compareToFile = require('./compare-to-file')
const createBundleService = require('../../plugins/bundle-service')
const bundle = require('.')
const registry = require('../../plugins/registry')
const compareToFile = require('../test/compare-to-file')
const path = require('path')
const decamelize = require('decamelize')
const plugiator = require('plugiator')
Expand Down Expand Up @@ -158,7 +158,7 @@ const tests = [
{
name: 'should bundle local package',
path: '/bundle/local-pkg@1.0.0(index).js',
overridePath: path.resolve(__dirname, './local-pkg'),
overridePath: path.resolve(__dirname, '../test/local-pkg'),
expected: {
fileName: 'test6',
headers: {
Expand All @@ -181,7 +181,7 @@ describe('bundle', function () {
const bundleService = createBundleService({
maxAge: test.maxAge,
overridePath: test.overridePath,
storagePath: path.resolve(__dirname, '../../.cdn-cache'),
storagePath: path.resolve(process.cwd(), './.cdn-cache'),
})

return server
Expand Down
12 changes: 6 additions & 6 deletions test/web/raw.js → app/web/raw/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const it = require('mocha').it
const expect = require('chai').expect
const express = require('express')
const hexi = require('hexi')
const createBundleService = require('../../app/plugins/bundle-service')
const raw = require('../../app/web/raw')
const compareToFile = require('./compare-to-file')
const registry = require('../../app/plugins/registry')
const createBundleService = require('../../plugins/bundle-service')
const raw = require('.')
const compareToFile = require('../test/compare-to-file')
const registry = require('../../plugins/registry')
const path = require('path')
const plugiator = require('plugiator')
const request = require('supertest')
Expand All @@ -20,7 +20,7 @@ describe('raw', function () {
maxAge: {
'default': '4h',
},
storagePath: path.resolve(__dirname, '../../.cdn-cache'),
storagePath: path.resolve(process.cwd(), './.cdn-cache'),
})

server.register([
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('raw', function () {
maxAge: {
'default': '4h',
},
storagePath: path.resolve(__dirname, '../../.cdn-cache'),
storagePath: path.resolve(process.cwd(), './.cdn-cache'),
})

return server.register([
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"start": "node app",
"dev": "nodemon app",
"pretest": "rimraf .cdn-cache",
"test": "mocha test/{**/,/}*.js",
"test": "mocha app/{**/,/}*.spec.js",
"precoverage": "npm run pretest",
"coverage": "istanbul cover _mocha test/{**/,/}*.js -- -R spec",
"precoveralls": "npm run pretest && istanbul cover _mocha test/{**/,/}*.js --report lcovonly -- -R spec && npm i coveralls@2",
"coverage": "istanbul cover _mocha app/{**/,/}*.spec.js -- -R spec",
"precoveralls": "npm run pretest && istanbul cover _mocha app/{**/,/}*.spec.js --report lcovonly -- -R spec && npm i coveralls@2",
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"postcoveralls": "rm -rf ./coverage",
"docker:build": "docker-compose build",
Expand Down

0 comments on commit 6b7346f

Please sign in to comment.