Add code
This commit is contained in:
7
data-tables/babel.config.js
Normal file
7
data-tables/babel.config.js
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
[ '@babel/env', {
|
||||
useBuiltIns: 'usage'
|
||||
}]
|
||||
]
|
||||
}
|
69
data-tables/features/json.feature
Normal file
69
data-tables/features/json.feature
Normal file
@ -0,0 +1,69 @@
|
||||
Feature:
|
||||
As the owner of a book collection
|
||||
I want to be able to generate JSON containing titles from this collection
|
||||
|
||||
Scenario:
|
||||
Given the following books by Simon Frank are in the collection:
|
||||
| id | title |
|
||||
| 1 | Der Gegenstand des Wissens |
|
||||
| 2 | Lebendiges Wissen |
|
||||
When I stringify it
|
||||
Then I should get:
|
||||
"""
|
||||
[{
|
||||
"id": 1,
|
||||
"title": "Der Gegenstand des Wissens"
|
||||
},{
|
||||
"id": 2,
|
||||
"title": "Lebendiges Wissen"
|
||||
}]
|
||||
"""
|
||||
|
||||
Given the following books by Søren Kierkegaard are in the collection:
|
||||
| id | title |
|
||||
| 1 | Die Krankheit zum Tode |
|
||||
| 2 | Entweder-Oder |
|
||||
When I stringify it
|
||||
Then I should get:
|
||||
"""
|
||||
[{
|
||||
"id": 1,
|
||||
"title": "Die Krankheit zum Tode"
|
||||
},{
|
||||
"id": 2,
|
||||
"title": "Entweder-Oder"
|
||||
}]
|
||||
"""
|
||||
|
||||
Given the following book is in the collection:
|
||||
| id | 1 |
|
||||
| title | Leonce und Lena |
|
||||
| author | Georg Büchner |
|
||||
When I stringify it
|
||||
Then I should get:
|
||||
"""
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Leonce und Lena",
|
||||
"author": "Georg Büchner"
|
||||
}
|
||||
"""
|
||||
|
||||
Given the following books are in the collection:
|
||||
| Friedrich Nietzsche | Die Geburt der Tragödie |
|
||||
| Jacques Derrida | Die unbedingte Universität |
|
||||
| Honoré de Balzac | Die Frau von 30 Jahren |
|
||||
When I stringify it
|
||||
Then I should get:
|
||||
"""
|
||||
[{
|
||||
"author": "Friedrich Nietzsche",
|
||||
"title": "Die Geburt der Tragödie"
|
||||
},{
|
||||
"author": "Jacques Derrida",
|
||||
"title": "Die unbedingte Universität"
|
||||
},{
|
||||
"author": "Honoré de Balzac",
|
||||
"title": "Die Frau von 30 Jahren"
|
||||
}]
|
||||
"""
|
50
data-tables/features/steps/json.js
Normal file
50
data-tables/features/steps/json.js
Normal file
@ -0,0 +1,50 @@
|
||||
import { Given, When, Then } from 'cucumber'
|
||||
import { expect } from 'chai'
|
||||
|
||||
Given('the following books by Simon Frank are in the collection:', function (dataTable) {
|
||||
this.objects = []
|
||||
dataTable.hashes().forEach(el => {
|
||||
this.objects.push({
|
||||
id: parseInt(el.id),
|
||||
title: el.title
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Given('the following books by Søren Kierkegaard are in the collection:', function (dataTable) {
|
||||
this.objects = []
|
||||
dataTable.rows().forEach(el => {
|
||||
this.objects.push({
|
||||
id: parseInt(el[0]),
|
||||
title: el[1]
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Given('the following book is in the collection:', function (dataTable) {
|
||||
const data = dataTable.rowsHash()
|
||||
this.objects = {
|
||||
id: parseInt(data.id),
|
||||
title: data.title,
|
||||
author: data.author
|
||||
}
|
||||
})
|
||||
|
||||
Given('the following books are in the collection:', function (dataTable) {
|
||||
this.objects = []
|
||||
dataTable.raw().forEach(el => {
|
||||
this.objects.push({
|
||||
author: el[0],
|
||||
title: el[1]
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
When('I stringify it', function () {
|
||||
this.result = JSON.stringify(this.objects)
|
||||
})
|
||||
|
||||
Then('I should get:', function (expected) {
|
||||
expect(JSON.parse(expected))
|
||||
.to.deep.equal(JSON.parse(this.result))
|
||||
})
|
1771
data-tables/package-lock.json
generated
Normal file
1771
data-tables/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
19
data-tables/package.json
Normal file
19
data-tables/package.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "data-tables",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "cucumber-js --require-module '@babel/register'"
|
||||
},
|
||||
"author": "Eugen Wissner <belka@caraus.de>",
|
||||
"license": "MPL-2.0",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.1.5",
|
||||
"@babel/preset-env": "^7.1.5",
|
||||
"@babel/register": "^7.0.0",
|
||||
"babel-loader": "^8.0.4",
|
||||
"chai": "^4.2.0",
|
||||
"cucumber": "^5.0.2"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user