any-of: test added for erroring out when no wrapped plugins configured (ref. #21)

merge-requests/6/merge
Michał 'rysiek' Woźniak 2021-11-11 12:01:08 +00:00
rodzic a797cd697a
commit ffe2b2c40c
1 zmienionych plików z 18 dodań i 2 usunięć

Wyświetl plik

@ -83,7 +83,23 @@ describe("plugin: any-of", () => {
expect(LibResilientPluginConstructors.get('any-of')(LR, init).name).toEqual('any-of');
});
test("it should return data from fetch()", async () => {
test("it should throw an error when there aren't any wrapped plugins configured", async () => {
require("../../plugins/any-of.js");
init = {
name: 'any-of',
uses: []
}
expect.assertions(2);
try {
await LibResilientPluginConstructors.get('any-of')(LR, init).fetch('https://resilient.is/test.json')
} catch (e) {
expect(e).toBeInstanceOf(Error)
expect(e.toString()).toMatch('No wrapped plugins configured!')
}
});
test("it should return data from a wrapped plugin", async () => {
require("../../plugins/any-of.js");
const response = await LibResilientPluginConstructors.get('any-of')(LR, init).fetch('https://resilient.is/test.json');
@ -93,7 +109,7 @@ describe("plugin: any-of", () => {
expect(response.url).toEqual('https://resilient.is/test.json')
});
test("it should return data from fetch()", async () => {
test("it should pass Request() init data onto wrapped plugins", async () => {
require("../../plugins/any-of.js");
var initTest = {