-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from mantovanig/test/GM_integration-tests
Integration Tests
- Loading branch information
Showing
6 changed files
with
497 additions
and
327 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.155.1/containers/javascript-node/.devcontainer/base.Dockerfile | ||
|
||
# [Choice] Node.js version: 14, 12, 10 | ||
ARG VARIANT="14-buster" | ||
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT} | ||
|
||
# [Optional] Uncomment this section to install additional OS packages. | ||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ | ||
# && apt-get -y install --no-install-recommends <your-package-list-here> | ||
|
||
# [Optional] Uncomment if you want to install an additional version of node using nvm | ||
# ARG EXTRA_NODE_VERSION=10 | ||
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}" | ||
|
||
# [Optional] Uncomment if you want to install more global node modules | ||
# RUN su node -c "npm install -g <your-package-list-here>" |
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,29 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.155.1/containers/javascript-node | ||
{ | ||
"name": "Node.js", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
// Update 'VARIANT' to pick a Node version: 10, 12, 14 | ||
"args": { "VARIANT": "12" } | ||
}, | ||
|
||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"terminal.integrated.shell.osx": "/bin/zsh" | ||
}, | ||
|
||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"dbaeumer.vscode-eslint" | ||
], | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "yarn install", | ||
|
||
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
"remoteUser": "node" | ||
} |
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,7 @@ | ||
describe('healthcheck', () => { | ||
it('1 equals 1', () => { | ||
expect(1).toBe(1); | ||
}); | ||
}); | ||
|
||
|
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,109 @@ | ||
import { createClient } from "../mburger"; | ||
|
||
const MBURGER_API_KEY = "7f24ae161f9070567363630870fb90d58ab67fcd"; | ||
|
||
describe("MBurger SDK", () => { | ||
it("create a MBurger client", () => { | ||
const client = createClient({ | ||
api_key: MBURGER_API_KEY, | ||
}); | ||
|
||
expect(Boolean(client["getSection"])).toBeTruthy(); | ||
expect(Boolean(client["getBlocks"])).toBeTruthy(); | ||
expect(Boolean(client["getBlock"])).toBeTruthy(); | ||
}); | ||
|
||
it("Try to create a client without an api_key", () => { | ||
expect(() => { | ||
createClient(); | ||
}).toThrow(); | ||
}); | ||
|
||
it("Get a block", async () => { | ||
const client = createClient({ | ||
api_key: MBURGER_API_KEY, | ||
}); | ||
|
||
const res = await client.getBlock({ | ||
block_id: "1782", | ||
}); | ||
|
||
expect(res).toBeInstanceOf(Array); | ||
}); | ||
|
||
it("Get a block with a specific locale", async () => { | ||
const client = createClient({ | ||
api_key: MBURGER_API_KEY, | ||
}); | ||
|
||
const res = await client.getBlock({ | ||
block_id: "1782", | ||
|
||
locale: "en", | ||
}); | ||
|
||
// TODO(mantovanig): missing assertion on locale | ||
expect(res).toBeInstanceOf(Array); | ||
}); | ||
|
||
it("Get a error with an invalid block id", async () => { | ||
const client = createClient({ | ||
api_key: MBURGER_API_KEY, | ||
}); | ||
|
||
expect(async () => await client.getBlock({ block_id: "9999" })).rejects.toThrow(TypeError); | ||
}); | ||
|
||
it("Get a section", async () => { | ||
const client = createClient({ | ||
api_key: MBURGER_API_KEY, | ||
}); | ||
|
||
const res = await client.getSection({ | ||
section_id: "321640", | ||
}); | ||
|
||
expect(res.meta.id).toBe(321640); | ||
}); | ||
|
||
it("Get a error with an invalid section id", async () => { | ||
const client = createClient({ | ||
api_key: MBURGER_API_KEY, | ||
}); | ||
|
||
expect(async () => await client.getSection({ section_id: "9999" })).rejects.toThrow(TypeError); | ||
}); | ||
|
||
it("Get blocks array", async () => { | ||
const client = createClient({ | ||
api_key: MBURGER_API_KEY, | ||
}); | ||
|
||
const res = await client.getBlocks({ | ||
block_ids: [1782, 1787], | ||
}); | ||
|
||
expect(res.Product.meta.id).toBe(1782); | ||
expect(res.Categories.meta.id).toBe(1787); | ||
}) | ||
|
||
it("Get a error calling getBlocks without block_ids", async () => { | ||
const client = createClient({ | ||
api_key: MBURGER_API_KEY, | ||
}); | ||
|
||
expect(async () => await client.getBlocks()).rejects.toThrow(TypeError); | ||
}) | ||
|
||
it("Get a error calling getBlocks with id that does not exist", async () => { | ||
const client = createClient({ | ||
api_key: MBURGER_API_KEY, | ||
}); | ||
|
||
const res = await client.getBlocks({ | ||
block_ids: [9999], | ||
}); | ||
|
||
expect(res).toStrictEqual({}); | ||
}) | ||
}); |
Empty file.
Oops, something went wrong.