-
Notifications
You must be signed in to change notification settings - Fork 174
/
synergy.js
43 lines (36 loc) · 1.03 KB
/
synergy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const nba = require("../../");
const path = require("path");
const pify = require("pify");
const writeFile = pify(require("fs").writeFile);
const dir = path.join(__dirname, "../../responses");
function writeData (name, data) {
const str = JSON.stringify(data, null, 2);
return writeFile(path.join(dir, `synergy-${name}.json`), str);
}
global.SynergyData = {};
// stub for now, will add response shape verification for self-documenting responses
const verifyShape = shape => response => response;
const callMethod = (name, params = {}, shape) => () => {
params.season = 2016;
return nba.synergy[name](params)
.then(function (resp) {
writeData(`${name}-${params.category}`, resp);
});
};
describe("nba synergy API", function () {
const categories = [
"Transition",
"PRBallHandler",
"PRRollman",
"Postup",
"Spotup",
"Handoff",
"Cut",
"OffScreen",
"OffRebound",
"Misc",
];
categories.forEach(function (c) {
it(`category ${c}`, callMethod("playerPlayType", {category: c}));
});
});