Browse Source

Init

master
sipp11 9 years ago
commit
78b2c94f86
  1. 6
      .babelrc
  2. 4
      .gitignore
  3. 15
      CHANGELOG.md
  4. 39
      README.md
  5. 13
      app/scripts/core/Counter.es6.js
  6. 7
      app/scripts/core/Foo.es6.js
  7. 14
      package.json
  8. 9
      test/jasmine.json
  9. 29
      test/spec/test.Counter.es6.js
  10. 7
      test/spec/test.Foo.es6.js

6
.babelrc

@ -0,0 +1,6 @@
{
"presets": [
"es2015",
"stage-0"
]
}

4
.gitignore vendored

@ -0,0 +1,4 @@
node_modules/
npm-debug.log
.DS_Store
bower_components

15
CHANGELOG.md

@ -0,0 +1,15 @@
v1.1 / 2015-12-14
=================
* Support ES2015 & Stage 0
v1.0 / 2015-11-17
=================
* Add support info
* Fixed path to register.js
* Clear dependencies
* Add docs about install, test and license
* Support Babel.js in Jasmine specs
* Initial commit

39
README.md

@ -0,0 +1,39 @@
# test-jasmine-babel
> Test project which use Babel.js as ES6 compiler to write unit tests
## Setup
```
npm install
```
## Test
Before you should have global installation of `jasmine` package.
```
npm test
```
## Support
Current support version:
- `Babel ^6.3.17`
Previously support:
- `Babel ^5.8.29`
## Build changelog
Use https://github.com/tj/git-extras/blob/master/Commands.md#git-changelog:
```
git changelog -a -n
```
## License
[The MIT License](http://piecioshka.mit-license.org)

13
app/scripts/core/Counter.es6.js

@ -0,0 +1,13 @@
export const INCREMENT_COUNTER = 'INCREMENT_COUNTER'
export const DECREMENT_COUNTER = 'DECREMENT_COUNTER'
export default function counter(state = 0, action) {
switch (action.type) {
case INCREMENT_COUNTER:
return state + 1
case DECREMENT_COUNTER:
return state - 1
default:
return state
}
}

7
app/scripts/core/Foo.es6.js

@ -0,0 +1,7 @@
class Foo {
static bar() {
return 'bar';
}
}
export default Foo;

14
package.json

@ -0,0 +1,14 @@
{
"private": true,
"name": "test-jasmine-babel",
"scripts": {
"clear": "rm -rf node_modules/",
"test": "jasmine JASMINE_CONFIG_PATH=test/jasmine.json"
},
"devDependencies": {
"babel-core": "^6.3.26",
"babel-preset-es2015": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"jasmine": "^2.4.1"
}
}

9
test/jasmine.json

@ -0,0 +1,9 @@
{
"spec_dir": "test",
"spec_files": [
"spec/test.*.es6.js"
],
"helpers": [
"../node_modules/babel-core/register.js"
]
}

29
test/spec/test.Counter.es6.js

@ -0,0 +1,29 @@
import counter from '../../app/scripts/core/Counter.es6';
describe('counter', () => {
it('should handle initial state', () => {
expect (
counter(0, { type: 'INCREMENT_COUNTER' })
).toEqual(1);
});
it('should handle INCREMENT_COUNTER', () => {
expect (
counter(1, { type: 'INCREMENT_COUNTER' })
).toEqual(2);
});
it('should handle DECREMENT_COUNTER', () => {
expect (
counter(2, { type: 'DECREMENT_COUNTER' })
).toEqual(1);
});
it('should handle unknown action type', () => {
expect (
counter(1, { type: 'SOMETHING_ELSE' })
).toEqual(1);
});
});

7
test/spec/test.Foo.es6.js

@ -0,0 +1,7 @@
import Foo from '../../app/scripts/core/Foo.es6';
describe('Foo', () => {
it('bar', () => {
expect(Foo.bar()).toEqual('bar');
});
});
Loading…
Cancel
Save