-
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.
Merge pull request #140 from srod/es6
feat(es6): refactor to es6
- Loading branch information
Showing
34 changed files
with
2,255 additions
and
1,688 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 |
---|---|---|
|
@@ -6,3 +6,4 @@ node_modules | |
coverage | ||
dist | ||
.history | ||
dist |
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,24 +1,2 @@ | ||
.DS_Store | ||
.idea | ||
.vscode | ||
._* | ||
.history | ||
docs | ||
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.png | ||
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,66 +1,64 @@ | ||
'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 * as cli from '../lib/cli'; | ||
import { utils } from '../lib/utils'; | ||
|
||
describe('cli', function() { | ||
test('should minify to have been called', function() { | ||
var spy = jest.spyOn(nodeMinify, 'minify'); | ||
cli({ | ||
compressor: 'gcc', | ||
input: 'examples/public/js/sample.js', | ||
output: 'examples/public/js-dist/babili-es6.js', | ||
option: '{"createSourceMap": true}' | ||
}); | ||
expect(spy).toHaveBeenCalled(); | ||
describe('cli', () => { | ||
test('should minify to have been called with gcc', () => { | ||
const spy = jest.spyOn(cli, 'run'); | ||
return cli | ||
.run({ | ||
compressor: 'gcc', | ||
input: 'examples/public/js/sample.js', | ||
output: 'examples/public/js-dist/babili-es6.js', | ||
option: '{"createSourceMap": true}' | ||
}) | ||
.then(() => 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: 'gcc-java', | ||
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 gcc error', () => { | ||
const spy = jest.spyOn(cli, 'run'); | ||
return cli | ||
.run({ | ||
compressor: 'gcc-java', | ||
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.