Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add simplest scoring calculation #1

Merged
merged 2 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ module.exports = {
'plugin:cypress/recommended',
'airbnb',
],
parser: '@babel/eslint-parser',
parser: 'babel-eslint',
plugins: [
'react',
'react-hooks',
'cypress',
'jest',
'@babel',
],
settings: {
'import/resolver': {
Expand Down
61 changes: 61 additions & 0 deletions cypress/fixtures/acceptance/BreweriesSample1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"state-fish": "Cutthroat Trout",
"state-bird": "Western Meadowloark",
"breweries": [
{
"name": "Madison River Brewing",
"location": {
"address": "20900 Frontage Rd Building B",
"state": "MT",
"city": "Belgrade",
"zip-code": "59714"
},
"food-available": false,
"beers": [
{
"name": "Salmon Fly Honey Rye",
"color": "Gold",
"international-bitterness-units": 12,
"alcohol-by-volume": 0.04
},
{
"name": "Copper John Scotch Ale",
"color": "Copper",
"international-bitterness-units": 35,
"alcohol-by-volume": 0.055
},
{
"name": "Dropper IPA",
"color": "Amber",
"international-bitterness-units": 108,
"alcohol-by-volume": 0.065
}
]
},
{
"name": "Bozeman Brewing",
"location": {
"city": "Bozeman",
"address": "504 N. Broadway",
"state": "MT",
"zip-code": "59715"
},
"food-available": true,
"beers": [
{
"name": "Bozone Amber Ale",
"color": "Amber",
"international-bitterness-units": 29,
"alcohol-by-volume": 0.054
},
{
"name": "Plum Street Porter",
"international-bitterness-units": 52,
"color": "Dark",
"alcohol-by-volume": 0.06
}
]
}
],
"state": "MT"
}
61 changes: 61 additions & 0 deletions cypress/fixtures/acceptance/BreweriesSample2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"state": "MT",
"state-bird": "Western Meadowloark",
"state-fish": "Brown Trout",
"breweries": [
{
"name": "Madison River Brewing",
"location": {
"address": "20900 Frontage Rd Building B",
"city": "Belgrade",
"state": null,
"zip-code": "59714"
},
"food-available": false,
"beers": [
{
"name": "Salmon Fly Honey Rye",
"color": "Gold",
"international-bitterness-units": 10,
"alcohol-by-volume": 0.06
},
{
"name": "Copper John Scotch Ale",
"color": "Copper",
"international-bitterness-units": 32,
"alcohol-by-volume": 0.05
},
{
"name": "Dropper IPA",
"color": "Amberish",
"international-bitterness-units": 108,
"alcohol-by-volume": 0.065
}
]
},
{
"name": "Bozeman Brewing",
"location": {
"address": "504 N. Park Place",
"city": null,
"state": "MT",
"zip-code": "59715"
},
"food-available": false,
"beers": [
{
"name": "Bozone Amber Ale",
"color": "Amber",
"international-bitterness-units": "29",
"alcohol-by-volume": 0.054
},
{
"name": "Plum Street Porter",
"color": "Really Dark",
"international-bitterness-units": 52,
"alcohol-by-volume": "0.06"
}
]
}
]
}
85 changes: 85 additions & 0 deletions cypress/fixtures/acceptance/BreweriesSample3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"state": "MT",
"state-bird": "Western Meadowloark",
"state-fish": "Cutthroat Trout",
"breweries": [
{
"name": "Madison River Brewing",
"location": {
"address": "20900 Frontage Rd Building B",
"city": "Belgrade",
"state": "MT",
"zip-code": "59714"
},
"food-available": false,
"beers": [
{
"name": "Salmon Fly Honey Rye",
"color": "Gold",
"international-bitterness-units": 12,
"alcohol-by-volume": 0.04
},
{
"name": "Copper John Scotch Ale",
"color": "Copper",
"international-bitterness-units": 35,
"alcohol-by-volume": 0.055
},
{
"name": "Dropper IPA",
"color": "Amber",
"international-bitterness-units": 108,
"alcohol-by-volume": 0.065
},
{
"name": "Black Ghost Oatmeal Stout",
"color": "Dark",
"international-bitterness-units": 30,
"alcohol-by-volume": 0.075
}
]
},
{
"name": "Bozeman Brewing",
"location": {
"address": "504 N. Broadway",
"city": "Bozeman",
"state": "MT",
"zip-code": "59715"
},
"food-available": true,
"beers": [
{
"name": "Bozone Amber Ale",
"color": "Amber",
"international-bitterness-units": 29,
"alcohol-by-volume": 0.054
},
{
"name": "Plum Street Porter",
"color": "Dark",
"international-bitterness-units": 52,
"alcohol-by-volume": 0.06
}
]
},
{
"name": "Red Lodge Ales",
"location": {
"address": "1445 North Broadway",
"city": "Red Lodge",
"state": "MT",
"zip-code": "59068"
},
"food-available": true,
"beers": [
{
"name": "Helio Hefeweizen",
"color": "Gold",
"international-bitterness-units": 17,
"alcohol-by-volume": 0.055
}
]
}
]
}
51 changes: 51 additions & 0 deletions cypress/fixtures/acceptance/BreweriesSample4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"state": "MT",
"breweries": [
{
"name": "Madison River Brewing",
"food-available": false,
"beer-list": [
{
"name": "Salmon Fly Honey Rye",
"international-bitterness-units": 12,
"alcohol-by-volume": 0.04
},
{
"name": "Copper John Scotch Ale",
"color": "Copper",
"international-bitterness-units": 35,
"alcohol-by-volume": 0.055
},
{
"name": "Dropper IPA",
"color": "Amber",
"international-bitterness-units": 108,
"alcohol-by-volume": 0.065
}
]
},
{
"name": "Bozeman Brewing",
"address": {
"streetaddress": "504 N. Broadway",
"city": "Bozeman",
"zip-code": "59715"
},
"food-available": true,
"beer-list": [
{
"name": "Bozone Amber Ale",
"color": "Amber",
"international-bitterness-units": 29,
"alcohol-by-volume": 0.054
},
{
"name": "Plum Street Porter",
"color": "Dark",
"international-bitterness-units": 52,
"alcohol-by-volume": 0.06
}
]
}
]
}
69 changes: 69 additions & 0 deletions cypress/fixtures/acceptance/BreweriesSample5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"state": "MT",
"state-bird": "Western Meadowloark",
"state-fish": "Cutthroat Trout",
"breweries": [
{
"name": "Madison River Brewing",
"location": {
"address": "20900 Frontage Rd Building B",
"city": "Belgrade",
"state": "MT",
"zip-code": "59714",
"GPS": {
"lat": 45.44,
"long": 111.04
}
},
"food-available": false,
"beers": [
{
"name": "Salmon Fly Honey Rye",
"color": "Gold",
"international-bitterness-units": 12,
"alcohol-by-volume": 0.04
},
{
"name": "Copper John Scotch Ale",
"color": "Copper",
"international-bitterness-units": 35,
"alcohol-by-volume": 0.055
},
{
"name": "Dropper IPA",
"color": "Amber",
"international-bitterness-units": 108,
"alcohol-by-volume": 0.065
}
]
},
{
"name": "Bozeman Brewing",
"location": {
"address": "504 N. Broadway",
"city": "Bozeman",
"state": "MT",
"zip-code": "59715",
"GPS": {
"lat": 45.64,
"long": 111.02
}
},
"food-available": true,
"beers": [
{
"name": "Bozone Amber Ale",
"color": "Amber",
"international-bitterness-units": 29,
"alcohol-by-volume": 0.054
},
{
"name": "Plum Street Porter",
"color": "Dark",
"international-bitterness-units": 52,
"alcohol-by-volume": 0.06
}
]
}
]
}
16 changes: 15 additions & 1 deletion cypress/integration/app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,21 @@ describe('The scoring app', () => {
cy.contains('Compare').click();

// assert
cy.contains('Score: 1');
cy.contains('Score: 100.00%');
});
});
context('when the files are different', () => {
it('should show the score as a percentage', () => {
// arrange
const fileNameA = 'BreweriesMaster.json';
const fileNameB = 'BreweriesSample4.json';
cy.drop('File A', fileNameA);
cy.drop('File B', fileNameB);
// act
cy.contains('Compare').click();

// assert
cy.contains('Score: 35.71%');
});
});
});
Expand Down
6 changes: 1 addition & 5 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import 'cypress-file-upload';

Cypress.Commands.add('drop', (containerName, fileName, okMessage = `File ${fileName} successfully added.`) => {
Cypress.Commands.add('drop', (containerName, fileName) => {
const json = `acceptance/${fileName}`;

cy.contains(containerName).attachFile(json, { subjectType: 'drag-n-drop' });
cy.contains(containerName).parent().parent().contains(fileName);
cy.contains(okMessage).get('.MuiIconButton-label').click();
cy.contains(okMessage).should('not.exist');
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500); // Drag-dropping works in mysterious ways
});
9 changes: 9 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"~/*": ["./*"]
}
},
"exclude": ["node_modules"]
}
Loading