|
1 | 1 | /* eslint-env mocha */ |
| 2 | +/* eslint max-nested-callbacks: 0 */ |
2 | 3 |
|
3 | 4 | const chai = require("chai"); |
4 | 5 | const assert = chai.assert; |
5 | 6 |
|
6 | 7 | const cap = require("chai-as-promised"); |
7 | 8 | chai.use(cap); |
8 | 9 |
|
9 | | -const { idFromURL, getShortcutDetails, Shortcut, singleIDRegex } = require("./.."); |
| 10 | +const { idFromURL, getShortcutDetails, Shortcut, singleIDRegex, ShortcutMetadata, Action, ImportQuestion } = require("./.."); |
10 | 11 |
|
11 | 12 | const id = "e04c0db9ef974178b60f94518daeb8f2"; |
12 | 13 |
|
13 | | -describe("getShortcutDetails", () => { |
| 14 | +describe("getShortcutDetails()", () => { |
14 | 15 | describe("resolutions", () => { |
15 | 16 | const promise = getShortcutDetails(id); |
16 | 17 |
|
@@ -50,7 +51,34 @@ describe("getShortcutDetails", () => { |
50 | 51 | }); |
51 | 52 | }); |
52 | 53 |
|
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()", () => { |
54 | 82 | describe("return type", () => { |
55 | 83 | it("returns string when valid", () => { |
56 | 84 | assert.isString(idFromURL(id)); |
|
0 commit comments