Skip to content

Commit 2e811f3

Browse files
authored
Merge pull request #5 from Hacksore/master
Add tests for Shortcut.getMetadata
2 parents ebeb5c4 + efeec99 commit 2e811f3

2 files changed

Lines changed: 33 additions & 8 deletions

File tree

.gitignore

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,5 @@ typings/
6060
# next.js build output
6161
.next
6262

63-
# test file
64-
test.js
65-
66-
# ignore eslint ignore
67-
.eslintignore
63+
# package lock
64+
package-lock.json

tests/test.js

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
/* eslint-env mocha */
2+
/* eslint max-nested-callbacks: 0 */
23

34
const chai = require("chai");
45
const assert = chai.assert;
56

67
const cap = require("chai-as-promised");
78
chai.use(cap);
89

9-
const { idFromURL, getShortcutDetails, Shortcut, singleIDRegex } = require("./..");
10+
const { idFromURL, getShortcutDetails, Shortcut, singleIDRegex, ShortcutMetadata, Action, ImportQuestion } = require("./..");
1011

1112
const id = "e04c0db9ef974178b60f94518daeb8f2";
1213

13-
describe("getShortcutDetails", () => {
14+
describe("getShortcutDetails()", () => {
1415
describe("resolutions", () => {
1516
const promise = getShortcutDetails(id);
1617

@@ -50,7 +51,34 @@ describe("getShortcutDetails", () => {
5051
});
5152
});
5253

53-
describe("idFromURL", () => {
54+
describe("<Shortcut>.getMetadata()", () => {
55+
describe("resolutions", () => {
56+
it("resolves to an instance of ShortcutMetadata", () => {
57+
return getShortcutDetails(id).then(shortcut => {
58+
assert.eventually.instanceOf(shortcut.getMetadata(), ShortcutMetadata);
59+
});
60+
});
61+
62+
it("<ShortcutMetadata>.actions is an array of Action classes", () => {
63+
return getShortcutDetails(id).then(shortcut => {
64+
return shortcut.getMetadata();
65+
}).then(metadata => metadata.actions.forEach(action => {
66+
assert.instanceOf(action, Action);
67+
}));
68+
});
69+
70+
it("<ShortcutMetadata>.importQuestions is an array of ImportQuestion classes", () => {
71+
return getShortcutDetails(id).then(shortcut => {
72+
return shortcut.getMetadata();
73+
}).then(metadata => metadata.importQuestions.forEach(question => {
74+
return assert.eventually.instanceOf(question, ImportQuestion);
75+
}));
76+
});
77+
78+
});
79+
});
80+
81+
describe("idFromURL()", () => {
5482
describe("return type", () => {
5583
it("returns string when valid", () => {
5684
assert.isString(idFromURL(id));

0 commit comments

Comments
 (0)