-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(es2015+): refactoring in es2015+ syntax
- Loading branch information
Showing
33 changed files
with
2,491 additions
and
1,870 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ | |
node_modules | ||
coverage | ||
.history | ||
dist | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,2 @@ | ||
.DS_Store | ||
.idea | ||
.vscode | ||
._* | ||
.history | ||
node_modules | ||
coverage | ||
examples | ||
__tests__ | ||
.circleci | ||
.editorconfig | ||
.eslintrc | ||
.gitignore | ||
.npmignore | ||
.npmrc | ||
.prettierignore | ||
.travis.yml | ||
.yarnrc | ||
appveyor.yml | ||
codecov.yml | ||
static/cli.png | ||
static/node-minify.svg | ||
yarn.lock | ||
* | ||
!lib/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,63 @@ | ||
'use strict'; | ||
/*! | ||
* node-minify | ||
* Copyright(c) 2011-2018 Rodolphe Stoclin | ||
* MIT Licensed | ||
*/ | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000; | ||
|
||
var childProcess = require('child_process'); | ||
var nodeMinify = require('../lib/node-minify'); | ||
var cli = require('../lib/cli'); | ||
var utils = require('../lib/utils'); | ||
import childProcess from 'child_process'; | ||
import { minify } from '../src/node-minify'; | ||
import * as cli from '../src/cli'; | ||
import { utils } from '../src/utils'; | ||
|
||
describe('cli', function() { | ||
test('should minify to have been called', function() { | ||
var spy = jest.spyOn(nodeMinify, 'minify'); | ||
cli({ | ||
describe('cli', () => { | ||
test('should minify to have been called', () => { | ||
const spy = jest.spyOn(cli, 'run'); | ||
cli.run({ | ||
compressor: 'gcc', | ||
input: 'examples/public/js/sample.js', | ||
output: 'examples/public/js-dist/babili-es6.js' | ||
}); | ||
expect(spy).toHaveBeenCalled(); | ||
}); | ||
test('should minify to have been called with all compressors', function() { | ||
var spy = jest.spyOn(nodeMinify, 'minify'); | ||
return cli({ | ||
compressor: 'all', | ||
input: 'examples/public/js/sample.js', | ||
output: 'examples/public/js-dist/babili-es6.js' | ||
}).then(function() { | ||
expect(spy).toHaveBeenCalled(); | ||
}); | ||
test('should minify to have been called with all compressors', () => { | ||
const spy = jest.spyOn(cli, 'run'); | ||
return cli | ||
.run({ | ||
compressor: 'all', | ||
input: 'examples/public/js/sample.js', | ||
output: 'examples/public/js-dist/babili-es6.js' | ||
}) | ||
.then(() => expect(spy).toHaveBeenCalled()); | ||
}); | ||
}); | ||
|
||
describe('cli error', function() { | ||
beforeEach(function() { | ||
spyOn(childProcess, 'spawn').and.throwError('UnsupportedClassVersionError'); | ||
}); | ||
test('should minify to throw with all compressors', function() { | ||
var spy = jest.spyOn(nodeMinify, 'minify'); | ||
return cli({ | ||
compressor: 'all', | ||
input: 'examples/public/js/sample.js', | ||
output: 'examples/public/js-dist/babili-es6.js' | ||
}).catch(function(err) { | ||
expect(spy).toHaveBeenCalled(); | ||
return expect(err.message).toMatch( | ||
/(UnsupportedClassVersionError)|(Latest Google Closure Compiler requires Java >= 1.7, please update Java or use gcc-legacy)/ | ||
); | ||
}); | ||
describe('cli error', () => { | ||
beforeEach(() => spyOn(childProcess, 'spawn').and.throwError('UnsupportedClassVersionError')); | ||
test('should minify to throw with all compressors', () => { | ||
const spy = jest.spyOn(cli, 'run'); | ||
return cli | ||
.run({ | ||
compressor: 'all', | ||
input: 'examples/public/js/sample.js', | ||
output: 'examples/public/js-dist/babili-es6.js' | ||
}) | ||
.catch(err => { | ||
expect(spy).toHaveBeenCalled(); | ||
return expect(err.message).toMatch( | ||
/(UnsupportedClassVersionError)|(Latest Google Closure Compiler requires Java >= 1.7, please update Java or use gcc-legacy)/ | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('pretty bytes', function() { | ||
test('should throw when not a number', function() { | ||
expect(function() { | ||
utils.prettyBytes('a'); | ||
}).toThrow(); | ||
describe('pretty bytes', () => { | ||
test('should throw when not a number', () => { | ||
expect(() => utils.prettyBytes('a')).toThrow(); | ||
}); | ||
|
||
test('should return a negative number', function() { | ||
expect(utils.prettyBytes(-1)).toBe('-1 B'); | ||
}); | ||
test('should return a negative number', () => expect(utils.prettyBytes(-1)).toBe('-1 B')); | ||
|
||
test('should return 0', function() { | ||
expect(utils.prettyBytes(0)).toBe('0 B'); | ||
}); | ||
test('should return 0', () => expect(utils.prettyBytes(0)).toBe('0 B')); | ||
}); |
Oops, something went wrong.