Added babel-node

This commit is contained in:
Benjamin Barreto 2020-10-21 18:06:58 +02:00
parent fe72eddab1
commit 278e67ae75
7 changed files with 3148 additions and 42 deletions

6
js-jest/.babelrc Normal file
View File

@ -0,0 +1,6 @@
{
"presets": ["@babel/preset-env"],
"plugins": [
["@babel/transform-runtime"]
]
}

1
js-jest/.npmrc Normal file
View File

@ -0,0 +1 @@
engine-strict=true

3150
js-jest/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,8 +2,12 @@
"name": "gilded-rose-kata", "name": "gilded-rose-kata",
"version": "1.0.0", "version": "1.0.0",
"description": "Gilded Rose kata in JavaScript with Jest", "description": "Gilded Rose kata in JavaScript with Jest",
"engines": {
"node": ">=12.18.0",
"npm": ">=6.14.8"
},
"scripts": { "scripts": {
"start": "node ./test/texttest_fixture.js", "start": "babel-node ./test/texttest_fixture.js",
"test": "jest", "test": "jest",
"test:watch": "jest --watch", "test:watch": "jest --watch",
"test:coverage": "jest --coverage" "test:coverage": "jest --coverage"
@ -24,14 +28,23 @@
}, },
"homepage": "https://github.com/emilybache/GildedRose-Refactoring-Kata", "homepage": "https://github.com/emilybache/GildedRose-Refactoring-Kata",
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/node": "^7.12.1",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/register": "^7.12.1",
"@babel/runtime": "^7.12.1",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0",
"jest": "^24.9.0", "jest": "^24.9.0",
"standardx": "^5.0.0" "standardx": "^5.0.0"
}, },
"standardx": { "standardx": {
"parser": "babel-eslint", "parser": "babel-eslint",
"env": [ "env": [
"node", "jest" "node",
"jest"
], ],
"ignore": [ "ignore": [
"node_modules" "node_modules"

View File

@ -3,7 +3,7 @@
* Do not alter the Item class or Items property as those belong to the goblin in the corner who * Do not alter the Item class or Items property as those belong to the goblin in the corner who
* will insta-rage and one-shot you as he doesn't believe in shared code ownership * will insta-rage and one-shot you as he doesn't believe in shared code ownership
*/ */
class Item { export class Item {
constructor (name, sellIn, quality) { constructor (name, sellIn, quality) {
this.name = name this.name = name
this.sellIn = sellIn this.sellIn = sellIn
@ -11,7 +11,7 @@ class Item {
} }
} }
class RegularItem extends Item { export class RegularItem extends Item {
constructor (itemProps) { constructor (itemProps) {
const { name, sellIn, quality } = itemProps const { name, sellIn, quality } = itemProps
super(name, sellIn, quality) super(name, sellIn, quality)
@ -52,7 +52,7 @@ class RegularItem extends Item {
} }
} }
class Shop { export class Shop {
constructor (items = []) { constructor (items = []) {
this.items = items this.items = items
} }
@ -120,9 +120,3 @@ class Shop {
return this.items return this.items
} }
} }
module.exports = {
Item,
Shop,
RegularItem
}

View File

@ -1,4 +1,4 @@
const { RegularItem } = require('../src/gilded_rose') import { RegularItem } from '../src/gilded_rose'
// describe('Gilded Rose', function () { // describe('Gilded Rose', function () {
// it('should foo', function () { // it('should foo', function () {

View File

@ -1,5 +1,5 @@
const { Shop, Item } = require('../src/gilded_rose') import { Shop, Item } from '../src/gilded_rose'
const items = [ const items = [
new Item('+5 Dexterity Vest', 10, 20), new Item('+5 Dexterity Vest', 10, 20),