Skip to content

Commit

Permalink
Merge branch 'master' into react-draft
Browse files Browse the repository at this point in the history
  • Loading branch information
phulin committed Dec 23, 2019
2 parents fdc3ace + afc4685 commit d8f8441
Show file tree
Hide file tree
Showing 176 changed files with 32,092 additions and 8,010 deletions.
11 changes: 11 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": [
[
"@babel/preset-env", {
"targets": {
"node": "current"
}
}
]
]
}
15 changes: 15 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"env": {
"browser": true,
"jest/globals": true,
"node": true
},
"extends": ["airbnb", "prettier"],
"plugins": ["jest", "prettier"],
"rules": {
"prettier/prettier": ["error"],
"no-console": "off",
"global-require": "off",
"no-param-reassign": "off"
}
}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/public/bower_components
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"singleQuote": true,
"trailingComma": "all",
"parser": "flow",
"tabWidth": 2,
"semi": true,
"arrowParens": "always",
"printWidth": 120
}
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: node_js
node_js:
- "stable"
- 'stable'

before_install: "npm install jest beautify-lint"
install: "npm install"
install: 'npm install'
script:
- "npm run lint"
- "npm run test"
- 'npm run lint'
- 'npm run build'
- 'npm run test'
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Cube Cobra currently uses 4 languages: Javascript, Jade/PUG, CSS, and HTML. Plea

#### Javascript

For Javascript please make sure your code is formatted using the JS Beautify standard. This can be done by running `npm run-script beautify`.
For Javascript please make sure your code is formatted using the prettier standard. This can be done by running `npm run-script beautify`.

#### Jade/PUG CSS and HTML

Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ The resulting directory structure should look like this:

Then, run the following commands in the root of the cloned repository:


```sh
npm install
npm install nodemon -g
Expand All @@ -54,7 +53,7 @@ npm start # Start nodemon for backend server and webpack for f

# Windows users will need to use 2 terminal instances.
npm nodemon
npm webpack-dev-server
npm run-script webpack-dev-server
```

Alternatively, if you are on Windows, you can use bash to mimic the Linux/OSX steps:
Expand All @@ -72,4 +71,6 @@ Nodemon will restart the application anytime there is a change to a source file.

### Running tests

To run the test suite, run `npm run test`
To run the test suite, run `npm run test`.

If you make changes to `updatecards.js` or other code that will require remaking the fixture files in `fixtures/` you can use the helper: `node update_fixtures.js` after getting the lastest card info using `node force_update.js`. This will retain the same cards in the fixtures but with updated card details and fixture files.
253 changes: 127 additions & 126 deletions __tests__/serverjs/analytics.test.js
Original file line number Diff line number Diff line change
@@ -1,174 +1,175 @@
const analytics = require("../../serverjs/analytics");
const carddb = require("../../serverjs/cards");
const cubefixture = require("../../fixtures/examplecube");
const analytics = require('../../serverjs/analytics');
const carddb = require('../../serverjs/cards');
const cubefixture = require('../../fixtures/examplecube');

const fixturesPath = "fixtures";
const fixturesPath = 'fixtures';

beforeEach(() => {});

afterEach(() => {});

test("GetColorCat returns the expected results", () => {
test('GetColorCat returns the expected results', () => {
expect(analytics.GetColorCat('land', [])).toBe('l');
expect(analytics.GetColorCat('creature', [])).toBe('c');
expect(analytics.GetColorCat('creature', ['G', 'R'])).toBe('m');
expect(analytics.GetColorCat('creature', ['G'])).toBe('g');
});

test("GetColorIdentity returns the expected results", () => {
test('GetColorIdentity returns the expected results', () => {
expect(analytics.GetColorIdentity([])).toBe('Colorless');
expect(analytics.GetColorIdentity(["G", "R"])).toBe('Multicolored');
expect(analytics.GetColorIdentity(["G"])).toBe('Green');
expect(analytics.GetColorIdentity(['G', 'R'])).toBe('Multicolored');
expect(analytics.GetColorIdentity(['G'])).toBe('Green');
});

test("GetTypeByColor returns valid counts", () => {
test('GetTypeByColorIdentity returns valid counts', () => {
expect.assertions(1);
var promise = carddb.initializeCardDb(fixturesPath, true);
return promise.then(function() {
var expected = {
"Artifacts": {
"Black": 0,
"Blue": 2,
"Colorless": 1,
"Green": 0,
"Multi": 0,
"Red": 1,
"Total": 5,
"White": 1
Artifacts: {
Black: 0,
Blue: 2,
Colorless: 1,
Green: 0,
Multi: 0,
Red: 1,
Total: 5,
White: 1,
},
"Creatures": {
"Black": 7,
"Blue": 7,
"Colorless": 0,
"Green": 7,
"Multi": 4,
"Red": 6,
"Total": 40,
"White": 9
Creatures: {
Black: 7,
Blue: 7,
Colorless: 1,
Green: 6,
Multi: 4,
Red: 6,
Total: 40,
White: 9,
},
"Enchantments": {
"Black": 0,
"Blue": 1,
"Colorless": 0,
"Green": 1,
"Multi": 3,
"Red": 1,
"Total": 7,
"White": 1
Enchantments: {
Black: 0,
Blue: 1,
Colorless: 0,
Green: 1,
Multi: 3,
Red: 1,
Total: 7,
White: 1,
},
"Instants": {
"Black": 0,
"Blue": 0,
"Colorless": 0,
"Green": 1,
"Multi": 0,
"Red": 0,
"Total": 1,
"White": 0
Instants: {
Black: 0,
Blue: 0,
Colorless: 0,
Green: 0,
Multi: 0,
Red: 0,
Total: 1,
White: 1,
},
"Lands": {
"Black": 0,
"Blue": 0,
"Colorless": 7,
"Green": 0,
"Multi": 0,
"Red": 0,
"Total": 7,
"White": 0
Lands: {
Black: 1,
Blue: 1,
Colorless: 2,
Green: 1,
Multi: 0,
Red: 1,
Total: 7,
White: 1,
},
"Planeswalkers": {
"Black": 0,
"Blue": 0,
"Colorless": 0,
"Green": 0,
"Multi": 2,
"Red": 0,
"Total": 2,
"White": 0
Planeswalkers: {
Black: 0,
Blue: 1,
Colorless: 0,
Green: 0,
Multi: 1,
Red: 0,
Total: 2,
White: 0,
},
"Sorceries": {
"Black": 0,
"Blue": 0,
"Colorless": 0,
"Green": 0,
"Multi": 2,
"Red": 1,
"Total": 3,
"White": 0
Sorceries: {
Black: 0,
Blue: 0,
Colorless: 0,
Green: 0,
Multi: 2,
Red: 1,
Total: 3,
White: 0,
},
Total: {
Black: 8,
Blue: 12,
Colorless: 4,
Green: 8,
Multi: 10,
Red: 10,
Total: 65,
White: 13,
},
"Total": {
"Black": 7,
"Blue": 10,
"Colorless": 8,
"Green": 9,
"Multi": 11,
"Red": 9,
"Total": 65,
"White": 11
}
};
var result = analytics.GetTypeByColor(cubefixture.exampleCube.cards, carddb);
var result = analytics.GetTypeByColorIdentity(cubefixture.exampleCube.cards, carddb);
expect(result).toEqual(expected);
});
});

test("GetColorCounts returns valid counts", () => {
test('GetColorIdentityCounts returns valid counts', () => {
expect.assertions(1);
var expected = {
"Abzan": 0,
"Azorius": 1,
"Bant": 0,
"Black": 3,
"Blue": 4,
"Boros": 2,
"Dimir": 1,
"Esper": 0,
"FiveColor": 0,
"Golgari": 1,
"Green": 4,
"Grixis": 0,
"Gruul": 1,
"Izzet": 1,
"Jeskai": 0,
"Jund": 0,
"Mardu": 0,
"Naya": 0,
"NonBlack": 0,
"NonBlue": 0,
"NonGreen": 0,
"NonRed": 0,
"NonWhite": 0,
"Orzhov": 1,
"Rakdos": 0,
"Red": 4,
"Selesnya": 1,
"Simic": 1,
"Sultai": 0,
"Temur": 0,
"White": 5
Abzan: 0,
Azorius: 1,
Bant: 0,
Black: 11,
Blue: 15,
Boros: 2,
Colorless: 4,
Dimir: 1,
Esper: 0,
FiveColor: 0,
Golgari: 1,
Green: 12,
Grixis: 0,
Gruul: 1,
Izzet: 1,
Jeskai: 0,
Jund: 0,
Mardu: 0,
Naya: 0,
NonBlack: 0,
NonBlue: 0,
NonGreen: 0,
NonRed: 0,
NonWhite: 0,
Orzhov: 1,
Rakdos: 0,
Red: 14,
Selesnya: 2,
Simic: 0,
Sultai: 0,
Temur: 0,
White: 19,
};
var promise = carddb.initializeCardDb(fixturesPath, true);
return promise.then(function() {
var result = analytics.GetColorCounts(cubefixture.exampleCube.cards, carddb);
var result = analytics.GetColorIdentityCounts(cubefixture.exampleCube.cards, carddb);
expect(result).toEqual(expected);
});
});

test("GetCurve returns a valid curve structure", () => {
test('GetCurve returns a valid curve structure', () => {
expect.assertions(1);
var expected = {
"black": [0, 1, 2, 3, 0, 1, 0, 0, 0, 0],
"blue": [0, 1, 3, 6, 0, 0, 0, 0, 0, 0],
"colorless": [0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
"green": [0, 2, 3, 1, 1, 0, 1, 1, 0, 0],
"multi": [0, 0, 3, 2, 3, 1, 2, 0, 0, 0],
"red": [0, 1, 1, 3, 3, 0, 1, 0, 0, 0],
"total": [0, 7, 16, 19, 7, 3, 5, 1, 0, 0],
"white": [0, 2, 3, 4, 0, 1, 1, 0, 0, 0]
black: [0, 1, 2, 3, 0, 1, 0, 0, 0, 0],
blue: [0, 1, 3, 7, 0, 0, 0, 0, 0, 0],
colorless: [0, 0, 1, 0, 0, 0, 0, 1, 0, 0],
green: [0, 2, 2, 1, 1, 0, 1, 0, 0, 0],
multi: [0, 0, 3, 1, 3, 1, 2, 0, 0, 0],
red: [0, 1, 1, 3, 3, 0, 1, 0, 0, 0],
total: [0, 7, 16, 19, 7, 3, 5, 1, 0, 0],
white: [0, 2, 4, 4, 0, 1, 1, 0, 0, 0],
};
var promise = carddb.initializeCardDb(fixturesPath, true);
return promise.then(function() {
var result = analytics.GetCurve(cubefixture.exampleCube.cards, carddb);
expect(result).toEqual(expected);
});
});
});
Loading

0 comments on commit d8f8441

Please sign in to comment.