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

Conforming to current jasmine api. Passing needed test values #42

Merged
merged 1 commit into from
Jun 6, 2018
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
2 changes: 1 addition & 1 deletion jasmine-runner.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var Jasmine = require('jasmine');
var SpecReporter = require('jasmine-spec-reporter');
var { SpecReporter } = require('jasmine-spec-reporter');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jasmine-spec-reporter has a couple objects. Dunno if it always did

var noop = function () {};

var jrunner = new Jasmine();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"An API to help facilitate the use of the Yahoo! Fantasy Sports API in NodeJS projects.",
"main": "index.js",
"scripts": {
"test": "node -r @std/esm jasmine-runner.js",
"test": "node -r esm jasmine-runner.js",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scoped package @std/esm is not currently in the package.json, but plain esm is. Could alternatively switch the package.json to @std/esm.

"istanbul": "istanbul cover --include-all-sources jasmine-node tests"
},
"repository": {
Expand Down
40 changes: 20 additions & 20 deletions tests/gameResource.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe("resource : gameResource", function() {
// leagues
describe(": leagues", function() {
it("should build a proper url to retrieve league data for a single league using a numeric game key", function() {
game.leagues(328, "328.l.34014", null);
game.leagues(328, "328.l.34014", () => {});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just need to provide some callback, even though we aren't testing the value called-back-with.


expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -83,7 +83,7 @@ describe("resource : gameResource", function() {
});

it("should build a proper url to retrieve league data for a single league using a string game key", function() {
game.leagues("mlb", "mlb.l.34014", null);
game.leagues("mlb", "mlb.l.34014", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -93,7 +93,7 @@ describe("resource : gameResource", function() {
});

it("should build a proper url to retrieve league data for a single league using a numeric game key and league as an array", function() {
game.leagues(328, ["328.l.34014"], null);
game.leagues(328, ["328.l.34014"], () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -103,7 +103,7 @@ describe("resource : gameResource", function() {
});

it("should build a proper url to retrieve league data for a single league using a string game key and league as an array", function() {
game.leagues("mlb", ["mlb.l.34014"], null);
game.leagues("mlb", ["mlb.l.34014"], () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -113,7 +113,7 @@ describe("resource : gameResource", function() {
});

it("should build a proper url to retrieve league data for a multiple leagues using a numeric game key", function() {
game.leagues(328, ["328.l.34014", "328.l.24281"], null);
game.leagues(328, ["328.l.34014", "328.l.24281"], () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -123,7 +123,7 @@ describe("resource : gameResource", function() {
});

it("should build a proper url to retrieve league data for a multiple leagues using a string game key", function() {
game.leagues("mlb", ["mlb.l.34014", "mlb.l.24281"], null);
game.leagues("mlb", ["mlb.l.34014", "mlb.l.24281"], () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -135,7 +135,7 @@ describe("resource : gameResource", function() {

// players
it("should build a proper url to retrieve player data for a single player using a numeric game key", function() {
game.players(328, "328.p.6619", null);
game.players(328, "328.p.6619", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -145,7 +145,7 @@ describe("resource : gameResource", function() {
});

it("should build a proper url to retrieve player data for a single player using a string game key", function() {
game.players("mlb", "mlb.p.6619", null);
game.players("mlb", "mlb.p.6619", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -155,7 +155,7 @@ describe("resource : gameResource", function() {
});

it("should build a proper url to retrieve player data for a single player using a numeric game key and player as an array", function() {
game.players(328, ["328.p.6619"], null);
game.players(328, ["328.p.6619"], () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -165,7 +165,7 @@ describe("resource : gameResource", function() {
});

it("should build a proper url to retrieve player data for a single player using a string game key and player as an array", function() {
game.players("mlb", ["mlb.p.6619"], null);
game.players("mlb", ["mlb.p.6619"], () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -175,7 +175,7 @@ describe("resource : gameResource", function() {
});

it("should build a proper url to retrieve player data for a multiple players using a numeric game key", function() {
game.players(328, ["328.p.6619", "328.p.8172"], null);
game.players(328, ["328.p.6619", "328.p.8172"], () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -185,7 +185,7 @@ describe("resource : gameResource", function() {
});

it("should build a proper url to retrieve player data for a multiple players using a string game key", function() {
game.players("mlb", ["mlb.p.6619", "mlb.p.8172"], null);
game.players("mlb", ["mlb.p.6619", "mlb.p.8172"], () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -196,7 +196,7 @@ describe("resource : gameResource", function() {

// game_weeks
it("should build a proper url to retrieve game weeks using a numeric game key", function() {
game.game_weeks(328, null);
game.game_weeks(328, () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -206,7 +206,7 @@ describe("resource : gameResource", function() {
});

it("should build a proper url to retrieve game weeks using a string game key", function() {
game.game_weeks("nfl", null);
game.game_weeks("nfl", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -217,7 +217,7 @@ describe("resource : gameResource", function() {

// stat_categories
it("should build a proper url to retrieve stat categories using a numeric game key", function() {
game.stat_categories(328, null);
game.stat_categories(328, () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -227,7 +227,7 @@ describe("resource : gameResource", function() {
});

it("should build a proper url to retrieve stat categories using a string game key", function() {
game.stat_categories("nfl", null);
game.stat_categories("nfl", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -238,7 +238,7 @@ describe("resource : gameResource", function() {

// position_types
it("should build a proper url to retrieve position types using a numeric game key", function() {
game.position_types(328, null);
game.position_types(328, () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -248,7 +248,7 @@ describe("resource : gameResource", function() {
});

it("should build a proper url to retrieve position types using a string game key", function() {
game.position_types("nfl", null);
game.position_types("nfl", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -259,7 +259,7 @@ describe("resource : gameResource", function() {

// roster_positions
it("should build a proper url to retrieve roster positions using a numeric game key", function() {
game.roster_positions(328, null);
game.roster_positions(328, () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -269,7 +269,7 @@ describe("resource : gameResource", function() {
});

it("should build a proper url to retrieve roster positions using a string game key", function() {
game.roster_positions("nfl", null);
game.roster_positions("nfl", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand Down
2 changes: 1 addition & 1 deletion tests/gamesCollection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("collection: gamesCollection", function() {
.get("/fantasy/v2/game/328/metadata?format=json")
.reply(200, {});

games.fetch(328, null);
games.fetch(328, () => {});

// expect(yf.api)
// .toHaveBeenCalledWith("http://fantasysports.yahooapis.com/fantasy/v2/game/328/metadata?format=json");
Expand Down
52 changes: 26 additions & 26 deletions tests/leagueResource.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ describe("resource: leagueResource", function() {
it("should build a proper url to retrieve metadata via a league key", function() {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/league/328.l.34014/metadata?format=json")
.reply(200, {});
.reply(200, require("./nock-data/leagueMeta").meta);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to return some data, because the object mapping classes expect there to be at least a fantasy_content field.


league.meta("328.l.34014", null);
league.meta("328.l.34014", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -66,9 +66,9 @@ describe("resource: leagueResource", function() {
it("should build a proper url to retrieve settings via a league key", function() {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/league/328.l.34014/settings?format=json")
.reply(200, {});
.reply(200, require("./nock-data/leagueSettings"));

league.settings("328.l.34014", null);
league.settings("328.l.34014", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -81,9 +81,9 @@ describe("resource: leagueResource", function() {
it("should build a proper url to retrieve standings via a league key", function() {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/league/328.l.34014/standings?format=json")
.reply(200, {});
.reply(200, require("./nock-data/leagueStandings"));

league.standings("328.l.34014", null);
league.standings("328.l.34014", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -96,9 +96,9 @@ describe("resource: leagueResource", function() {
it("should build a proper url to retrieve scoreboard via a league key", function() {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/league/328.l.34014/scoreboard?format=json")
.reply(200, {});
.reply(200, require("./nock-data/leagueScoreboard"));

league.scoreboard("328.l.34014", null);
league.scoreboard("328.l.34014", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -111,9 +111,9 @@ describe("resource: leagueResource", function() {
it("should build a proper url to retrieve teams via a league key", function() {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/league/328.l.34014/teams?format=json")
.reply(200, {});
.reply(200, require("./nock-data/leagueTeams"));

league.teams("328.l.34014", null);
league.teams("328.l.34014", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -122,28 +122,28 @@ describe("resource: leagueResource", function() {
);
});

// players
it("should build a proper url to retrieve players via a league key", function() {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/league/328.l.34014/players?format=json")
.reply(200, {});
// // players
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was commented out in the source, so there is nothing to test

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya the tests are a never ending process :P

// it("should build a proper url to retrieve players via a league key", function() {
// nock("https://fantasysports.yahooapis.com")
// .get("/fantasy/v2/league/328.l.34014/players?format=json")
// .reply(200, {});

league.players("328.l.34014", null);
// league.players("328.l.34014", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/players?format=json",
jasmine.any(Function)
);
});
// expect(yf.api).toHaveBeenCalledWith(
// "GET",
// "https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/players?format=json",
// jasmine.any(Function)
// );
// });

// draft_results
it("should build a proper url to retrieve draft_results via a league key", function() {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/league/328.l.34014/draft_results?format=json")
.reply(200, {});
.reply(200, require("./nock-data/leagueDraftResults"));

league.draft_results("328.l.34014", null);
league.draft_results("328.l.34014", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -156,9 +156,9 @@ describe("resource: leagueResource", function() {
it("should build a proper url to retrieve transactions via a league key", function() {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/league/328.l.34014/transactions?format=json")
.reply(200, {});
.reply(200, require("./nock-data/leagueTransaction"));

league.transactions("328.l.34014", null);
league.transactions("328.l.34014", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand Down
20 changes: 10 additions & 10 deletions tests/playerResource.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ describe("resource: playerResource", function() {
it("should build a proper url to retrieve metadata via a player key", function() {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/player/328.p.6619/metadata?format=json")
.reply(200, {});
.reply(200, require("./nock-data/playerMeta"));

player.meta("328.p.6619", null);
player.meta("328.p.6619", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -58,9 +58,9 @@ describe("resource: playerResource", function() {
it("should build a proper url to retrieve player stats via a player key", function() {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/player/328.p.6619/stats?format=json")
.reply(200, {});
.reply(200, require("./nock-data/playerStats"));

player.stats("328.p.6619", null);
player.stats("328.p.6619", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -73,9 +73,9 @@ describe("resource: playerResource", function() {
it("should build a proper url to retrieve player ownership percentage via a player key", function() {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/player/328.p.6619/percent_owned?format=json")
.reply(200, {});
.reply(200, require("./nock-data/playerPercentOwned"));

player.percent_owned("328.p.6619", null);
player.percent_owned("328.p.6619", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -90,9 +90,9 @@ describe("resource: playerResource", function() {
.get(
"/fantasy/v2/league/328.l.34014/players;player_keys=328.p.6619/ownership?format=json"
)
.reply(200, {});
.reply(200, require("./nock-data/playerOwnershipOwned"));

player.ownership("328.p.6619", "328.l.34014", null);
player.ownership("328.p.6619", "328.l.34014", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand All @@ -107,9 +107,9 @@ describe("resource: playerResource", function() {
it("should build a proper url to retrieve player draft analysis via a player key", function() {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/player/328.p.6619/teams?format=json")
.reply(200, {});
.reply(200, require("./nock-data/playerDraftAnalysis"));

player.draft_analysis("328.p.6619", null);
player.draft_analysis("328.p.6619", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand Down
2 changes: 1 addition & 1 deletion tests/rosterResource.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("resource: rosterResource", function() {
.get("/fantasy/v2/team/328.l.34014.t.1/roster/players?format=json")
.reply(200, {});

roster.players("328.l.34014.t.1", null);
roster.players("328.l.34014.t.1", () => {});

expect(yf.api).toHaveBeenCalledWith(
"GET",
Expand Down
Loading