Skip to content

Commit

Permalink
Revert "Webworker Analytics"
Browse files Browse the repository at this point in the history
  • Loading branch information
dekkerglen authored Jan 15, 2020
1 parent caa2556 commit a9a726e
Show file tree
Hide file tree
Showing 23 changed files with 1,124 additions and 1,105 deletions.
175 changes: 175 additions & 0 deletions __tests__/serverjs/analytics.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
const analytics = require('../../serverjs/analytics');
const carddb = require('../../serverjs/cards');
const cubefixture = require('../../fixtures/examplecube');

const fixturesPath = 'fixtures';

beforeEach(() => {});

afterEach(() => {});

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', () => {
expect(analytics.GetColorIdentity([])).toBe('Colorless');
expect(analytics.GetColorIdentity(['G', 'R'])).toBe('Multicolored');
expect(analytics.GetColorIdentity(['G'])).toBe('Green');
});

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,
},
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,
},
Instants: {
Black: 0,
Blue: 0,
Colorless: 0,
Green: 0,
Multi: 0,
Red: 0,
Total: 1,
White: 1,
},
Lands: {
Black: 1,
Blue: 1,
Colorless: 2,
Green: 1,
Multi: 0,
Red: 1,
Total: 7,
White: 1,
},
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,
},
Total: {
Black: 8,
Blue: 12,
Colorless: 4,
Green: 8,
Multi: 10,
Red: 10,
Total: 65,
White: 13,
},
};
var result = analytics.GetTypeByColorIdentity(cubefixture.exampleCube.cards, carddb);
expect(result).toEqual(expected);
});
});

test('GetColorIdentityCounts returns valid counts', () => {
expect.assertions(1);
var expected = {
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.GetColorIdentityCounts(cubefixture.exampleCube.cards, carddb);
expect(result).toEqual(expected);
});
});

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, 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);
});
});
43 changes: 18 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"passport-local": "^1.0.0",
"pug": "^2.0.3",
"quickselect": "^2.0.0",
"react-tagcloud": "^2.0.0",
"request": "^2.88.0",
"rss": "^1.2.2",
"sanitize-html": "^1.20.1",
Expand Down
Loading

0 comments on commit a9a726e

Please sign in to comment.