-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decorations, Glyphs and Decorations/Categories endpoints
- Loading branch information
Showing
10 changed files
with
273 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const AbstractEndpoint = require("../endpoint") | ||
|
||
module.exports = class HomesteadEndpoint extends AbstractEndpoint { | ||
decorations() { | ||
return new DecorationsEndpoint(this) | ||
} | ||
|
||
glyphs() { | ||
return new GlyphsEndpoint(this) | ||
} | ||
} | ||
|
||
class DecorationsEndpoint extends AbstractEndpoint { | ||
constructor(client) { | ||
super(client) | ||
this.url = "/v2/homestead/decorations" | ||
this.isPaginated = true | ||
this.isBulk = true | ||
this.cacheTime = 24 * 60 * 60 | ||
} | ||
|
||
categories() { | ||
return new DecorationsCategoriesEndpoint(this) | ||
} | ||
} | ||
|
||
class GlyphsEndpoint extends AbstractEndpoint { | ||
constructor(client) { | ||
super(client) | ||
this.url = "/v2/homestead/glyphs" | ||
this.isPaginated = true | ||
this.isBulk = true | ||
this.cacheTime = 24 * 60 * 60 | ||
} | ||
} | ||
|
||
class DecorationsCategoriesEndpoint extends AbstractEndpoint { | ||
constructor(client) { | ||
super(client) | ||
this.url = "/v2/homestead/decorations/categories" | ||
this.isPaginated = true | ||
this.isBulk = true | ||
this.cacheTime = 24 * 60 * 60 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* eslint-env jest */ | ||
const {mockClient, fetchMock} = require("../mocks/client.mock") | ||
const Module = require("../../src/endpoints/homestead") | ||
|
||
describe("endpoints > homestead", () => { | ||
let endpoint | ||
beforeEach(() => { | ||
endpoint = new Module(mockClient) | ||
fetchMock.reset() | ||
}) | ||
|
||
it("test /v2/homestead/decorations", async () => { | ||
endpoint = endpoint.decorations() | ||
|
||
expect(endpoint.isPaginated).toEqual(true) | ||
expect(endpoint.isBulk).toEqual(true) | ||
expect(endpoint.isLocalized).toEqual(false) | ||
expect(endpoint.isAuthenticated).toEqual(false) | ||
expect(endpoint.cacheTime).not.toEqual(undefined) | ||
expect(endpoint.url).toEqual("/v2/homestead/decorations") | ||
|
||
fetchMock.addResponse({ | ||
id: 35, | ||
name: "Kodan Cottage Wall", | ||
description: "", | ||
categories: [19, 1], | ||
max_count: 250, | ||
icon: "https://render.guildwars2.com/file/EBBA1865F40A0E6EFBCACA609271191E6E9CDDCF/3375022.png", | ||
}) | ||
|
||
let content = await endpoint.get(35) | ||
expect(content.name).toEqual("Kodan Cottage Wall") | ||
}) | ||
|
||
it("test /v2/homestead/glyphs", async () => { | ||
endpoint = endpoint.glyphs() | ||
|
||
expect(endpoint.isPaginated).toEqual(true) | ||
expect(endpoint.isBulk).toEqual(true) | ||
expect(endpoint.isLocalized).toEqual(false) | ||
expect(endpoint.isAuthenticated).toEqual(false) | ||
expect(endpoint.cacheTime).not.toEqual(undefined) | ||
expect(endpoint.url).toEqual("/v2/homestead/glyphs") | ||
|
||
fetchMock.addResponse({ | ||
id: "volatility_harvesting", | ||
}) | ||
|
||
let content = await endpoint.get("volatility_harvesting") | ||
expect(content.id).toEqual("volatility_harvesting") | ||
}) | ||
|
||
it("test /v2/homestead/decorations/categories", async () => { | ||
endpoint = endpoint.decorations().categories() | ||
|
||
expect(endpoint.isPaginated).toEqual(true) | ||
expect(endpoint.isBulk).toEqual(true) | ||
expect(endpoint.isLocalized).toEqual(false) | ||
expect(endpoint.isAuthenticated).toEqual(false) | ||
expect(endpoint.cacheTime).not.toEqual(undefined) | ||
expect(endpoint.url).toEqual("/v2/homestead/decorations/categories") | ||
|
||
fetchMock.addResponse({ | ||
id: 1, | ||
name: "Architecture", | ||
}) | ||
|
||
let content = await endpoint.get(1) | ||
expect(content.name).toEqual("Architecture") | ||
}) | ||
}) |