kopia lustrzana https://gitlab.com/rysiekpl/libresilient
service-worker: more tests (ref. #8)
rodzic
48ecda0968
commit
fca8d56a2d
|
@ -1,5 +1,4 @@
|
||||||
const makeServiceWorkerEnv = require('service-worker-mock');
|
const makeServiceWorkerEnv = require('service-worker-mock');
|
||||||
//global.fetch = require('service-worker-mock/fetch');
|
|
||||||
|
|
||||||
global.fetch = require('node-fetch');
|
global.fetch = require('node-fetch');
|
||||||
jest.mock('node-fetch')
|
jest.mock('node-fetch')
|
||||||
|
@ -30,6 +29,30 @@ describe("service-worker", () => {
|
||||||
self.LibResilientPlugins = new Array()
|
self.LibResilientPlugins = new Array()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("basic set-up: LibResilientPlugins", async () => {
|
||||||
|
self.LibResilientPlugins = false
|
||||||
|
self.LibResilientConfig = {
|
||||||
|
plugins: {
|
||||||
|
},
|
||||||
|
loggedComponents: [
|
||||||
|
'service-worker'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
require("../service-worker.js");
|
||||||
|
expect(self.LibResilientPlugins).toBeInstanceOf(Array)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("basic set-up: LibResilientConfig", async () => {
|
||||||
|
self.LibResilientConfig = null
|
||||||
|
try {
|
||||||
|
require("../service-worker.js");
|
||||||
|
} catch(e) {}
|
||||||
|
expect(typeof self.LibResilientConfig).toEqual('object')
|
||||||
|
expect(self.LibResilientConfig.defaultPluginTimeout).toBe(10000)
|
||||||
|
expect(typeof self.LibResilientConfig.plugins).toEqual('object')
|
||||||
|
expect(self.LibResilientConfig.loggedComponents).toBeInstanceOf(Array)
|
||||||
|
})
|
||||||
|
|
||||||
test("fetching content should work", async () => {
|
test("fetching content should work", async () => {
|
||||||
self.LibResilientConfig = {
|
self.LibResilientConfig = {
|
||||||
plugins: {
|
plugins: {
|
||||||
|
|
Ładowanie…
Reference in New Issue