Skip to content

Commit

Permalink
Merge pull request #46 from segayuu/Refactoring-test-es2016nify
Browse files Browse the repository at this point in the history
Refactoring test: es2016nify
  • Loading branch information
yoshinorin committed Oct 18, 2018
2 parents a1c9e11 + 8f87581 commit 4578651
Show file tree
Hide file tree
Showing 15 changed files with 220 additions and 230 deletions.
2 changes: 1 addition & 1 deletion test/index.js
@@ -1,6 +1,6 @@
'use strict';

describe('util', function() {
describe('util', () => {
require('./scripts/cache_stream');
require('./scripts/camel_case_keys');
require('./scripts/escape_diacritic');
Expand Down
20 changes: 10 additions & 10 deletions test/scripts/cache_stream.js
@@ -1,26 +1,26 @@
'use strict';

var Readable = require('stream').Readable;
const { Readable } = require('stream');

describe('CacheStream', function() {
var CacheStream = require('../../lib/cache_stream');
describe('CacheStream', () => {
const CacheStream = require('../../lib/cache_stream');

it('default', function() {
var src = new Readable();
var cacheStream = new CacheStream();
var content = Buffer.from('test');
it('default', () => {
const src = new Readable();
const cacheStream = new CacheStream();
const content = Buffer.from('test');

src.push(content);
src.push(null);
src.pipe(cacheStream);

cacheStream.on('finish', function() {
cacheStream.on('finish', () => {
cacheStream.getCache().should.eql(content);
});
});

it('destroy', function() {
var cacheStream = new CacheStream();
it('destroy', () => {
const cacheStream = new CacheStream();
cacheStream._cache = [Buffer.alloc(1)];

cacheStream.destroy();
Expand Down
24 changes: 12 additions & 12 deletions test/scripts/camel_case_keys.js
@@ -1,12 +1,12 @@
'use strict';

var should = require('chai').should(); // eslint-disable-line
const should = require('chai').should(); // eslint-disable-line

describe('camelCaseKeys', function() {
var camelCaseKeys = require('../../lib/camel_case_keys');
describe('camelCaseKeys', () => {
const camelCaseKeys = require('../../lib/camel_case_keys');

it('default', function() {
var result = camelCaseKeys({
it('default', () => {
const result = camelCaseKeys({
foo_bar: 'test'
});

Expand All @@ -16,25 +16,25 @@ describe('camelCaseKeys', function() {
});
});

it('obj must be an object', function() {
it('obj must be an object', () => {
try {
camelCaseKeys();
} catch (err) {
err.should.have.property('message', 'obj must be an object!');
}
});

it('setter', function() {
var result = camelCaseKeys({
it('setter', () => {
const result = camelCaseKeys({
foo_bar: 'test'
});

result.foo_bar = 'new';
result.fooBar.should.eql('new');
});

it('ignore prefixing underscore', function() {
var result = camelCaseKeys({
it('ignore prefixing underscore', () => {
const result = camelCaseKeys({
_foo_bar: 'test',
__bar_baz: 'foo'
});
Expand All @@ -47,8 +47,8 @@ describe('camelCaseKeys', function() {
});
});

it('do nothing if the key is camelCase', function() {
var result = camelCaseKeys({
it('do nothing if the key is camelCase', () => {
const result = camelCaseKeys({
fooBar: 'test'
});

Expand Down
10 changes: 5 additions & 5 deletions test/scripts/escape_diacritic.js
@@ -1,15 +1,15 @@
'use strict';

var should = require('chai').should(); // eslint-disable-line
const should = require('chai').should(); // eslint-disable-line

describe('escapeDiacritic', function() {
var escapeDiacritic = require('../../lib/escape_diacritic');
describe('escapeDiacritic', () => {
const escapeDiacritic = require('../../lib/escape_diacritic');

it('default', function() {
it('default', () => {
escapeDiacritic('Hell\u00F2 w\u00F2rld').should.eql('Hello world');
});

it('str must be a string', function() {
it('str must be a string', () => {
try {
escapeDiacritic();
} catch (err) {
Expand Down
10 changes: 5 additions & 5 deletions test/scripts/escape_html.js
@@ -1,15 +1,15 @@
'use strict';

var should = require('chai').should(); // eslint-disable-line
const should = require('chai').should(); // eslint-disable-line

describe('escapeHTML', function() {
var escapeHTML = require('../../lib/escape_html');
describe('escapeHTML', () => {
const escapeHTML = require('../../lib/escape_html');

it('default', function() {
it('default', () => {
escapeHTML('<p>Hello "world".</p>').should.eql('&lt;p&gt;Hello &quot;world&quot;.&lt;&#x2F;p&gt;');
});

it('str must be a string', function() {
it('str must be a string', () => {
try {
escapeHTML();
} catch (err) {
Expand Down
10 changes: 5 additions & 5 deletions test/scripts/escape_regexp.js
@@ -1,15 +1,15 @@
'use strict';

var should = require('chai').should(); // eslint-disable-line
const should = require('chai').should(); // eslint-disable-line

describe('escapeRegExp', function() {
var escapeRegExp = require('../../lib/escape_regexp');
describe('escapeRegExp', () => {
const escapeRegExp = require('../../lib/escape_regexp');

it('default', function() {
it('default', () => {
escapeRegExp('hello*world').should.eql('hello\\*world');
});

it('str must be a string', function() {
it('str must be a string', () => {
try {
escapeRegExp();
} catch (err) {
Expand Down
20 changes: 10 additions & 10 deletions test/scripts/hash.js
@@ -1,26 +1,26 @@
'use strict';

var should = require('chai').should(); // eslint-disable-line
var crypto = require('crypto');
const should = require('chai').should(); // eslint-disable-line
const crypto = require('crypto');

function sha1(content) {
var hash = crypto.createHash('sha1');
const hash = crypto.createHash('sha1');
hash.update(content);

return hash.digest();
}

describe('hash', function() {
var hash = require('../../lib/hash');
describe('hash', () => {
const hash = require('../../lib/hash');

it('hash', function() {
var content = '123456';
it('hash', () => {
const content = '123456';
hash.hash(content).should.eql(sha1(content));
});

it('HashStream', function() {
var content = '123456';
var stream = new hash.HashStream();
it('HashStream', () => {
const content = '123456';
const stream = new hash.HashStream();

stream.write(Buffer.from(content));
stream.end();
Expand Down

0 comments on commit 4578651

Please sign in to comment.