Skip to content
Permalink
Browse files

Switch to jest

  • Loading branch information...
Rowno committed Aug 4, 2017
1 parent d57450b commit b760d207037b0d8aec7ae2dcae9b2d0ee2bd24ff
@@ -0,0 +1 @@
**/__tests__/**/*
@@ -0,0 +1,46 @@
'use strict'
const path = require('path')
const fs = require('fs')
const exec = require('child_process').exec
// Test that the package.json bin config is correct
const CLI = path.resolve(require('../../package.json').bin['sitemap-urls'])
const fixtureUrls = require('./fixtures/urls.json')

const SITEMAP_FILE = path.join(__dirname, 'fixtures/sitemap.xml')
const FIXTURE_OUTPUT = fixtureUrls.join('\n') + '\n'

test('should extract urls from sitemap file', done => {
const child = exec(
CLI + ' ' + SITEMAP_FILE,
{cwd: __dirname},
(error, stdout, stderr) => {
if (error) {
return done(error)
}

expect(stdout, 'stdout').toBe(FIXTURE_OUTPUT)
expect(stderr, 'stderr').toBe('')
done()
}
)

child.stdin.end()
})

test('should extract urls from stdin', done => {
const child = exec(
CLI,
{cwd: __dirname},
(error, stdout, stderr) => {
if (error) {
return done(error)
}

expect(stdout, 'stdout').toBe(FIXTURE_OUTPUT)
expect(stderr, 'stderr').toBe('')
done()
}
)

fs.createReadStream(SITEMAP_FILE, {encoding: 'utf8'}).pipe(child.stdin)
})
File renamed without changes.
File renamed without changes.
@@ -2,18 +2,15 @@
'use strict'
const fs = require('fs')
const path = require('path')
const expect = require('chai').expect
const sitemapUrls = require('../')
const fixtureUrls = require('./fixtures/urls.json')

const fixtureXml = fs.readFileSync(path.join(__dirname, 'fixtures/sitemap.xml'), 'utf8')

describe('index', () => {
describe('#extractUrls', () => {
it('should extract urls', () => {
const urls = sitemapUrls.extractUrls(fixtureXml)
describe('#extractUrls', () => {
test('should extract urls', () => {
const urls = sitemapUrls.extractUrls(fixtureXml)

expect(urls).to.have.members(fixtureUrls)
})
expect(urls).toEqual(fixtureUrls)
})
})
@@ -16,7 +16,7 @@
"sitemap-urls": "lib/cli.js"
},
"scripts": {
"test": "mocha && xo"
"test": "jest && xo"
},
"engines": {
"node": ">=4"
@@ -29,7 +29,7 @@
},
"devDependencies": {
"chai": "^4.1.0",
"mocha": "^3.5.0",
"jest": "^20.0.4",
"xo": "^0.18.2"
},
"files": [
@@ -40,11 +40,8 @@
"semicolon": false,
"overrides": [
{
"files": "test/*.js",
"globals": [
"describe",
"it"
]
"files": "**/__tests__/**/*.js",
"envs": ["jest"]
}
]
}

This file was deleted.

0 comments on commit b760d20

Please sign in to comment.
You can’t perform that action at this time.