initial import

This commit is contained in:
Emily Bache
2019-08-06 09:34:28 +02:00
commit bf6bfd3ddb
12 changed files with 173 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`example statement 1`] = `
"Statement for BigCo
Hamlet: $650.00 (55 seats)
As You Like It: $580.00 (35 seats)
Othello: $500.00 (40 seats)
Amount owed is $1,730.00
You earned 47 credits
"
`;

View File

@@ -0,0 +1,17 @@
{
"customer": "BigCo",
"performances": [
{
"playID": "hamlet",
"audience": 55
},
{
"playID": "as-like",
"audience": 35
},
{
"playID": "othello",
"audience": 40
}
]
}

View File

@@ -0,0 +1,13 @@
{
"customer": "BigCoII",
"performances": [
{
"playID": "henry-v",
"audience": 53
},
{
"playID": "as-like",
"audience": 55
}
]
}

View File

@@ -0,0 +1,4 @@
{
"henry-v": {"name": "Henry V", "type": "history"},
"as-like": {"name": "As You Like It", "type": "pastoral"}
}

View File

@@ -0,0 +1,5 @@
{
"hamlet": {"name": "Hamlet", "type": "tragedy"},
"as-like": {"name": "As You Like It", "type": "comedy"},
"othello": {"name": "Othello", "type": "tragedy"}
}

View File

@@ -0,0 +1,14 @@
const statement = require('../src/statement');
const fs=require('fs');
test('example statement', () => {
const invoice = JSON.parse(fs.readFileSync('test/invoice.json', 'utf8'));
const plays = JSON.parse(fs.readFileSync('test/plays.json', 'utf8'));
expect(statement(invoice, plays)).toMatchSnapshot();
});
test('statement with new play types', () => {
const invoice = JSON.parse(fs.readFileSync('test/invoice_new_plays.json', 'utf8'));
const plays = JSON.parse(fs.readFileSync('test/new_plays.json', 'utf8'));
expect(() => {statement(invoice, plays)}).toThrow(/unknown type/);
});