-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1421fd
commit ffc16ff
Showing
13 changed files
with
5,025 additions
and
5,599 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,71 @@ | ||
"use strict"; | ||
|
||
const presets = require("eslint-plugin-itgalaxy"); | ||
|
||
module.exports = { | ||
extends: [ | ||
"plugin:itgalaxy/jest", | ||
"plugin:itgalaxy/esnext", | ||
"plugin:itgalaxy/node", | ||
"plugin:itgalaxy/markdown" | ||
], | ||
overrides: [ | ||
// Jest | ||
{ | ||
env: { | ||
browser: true, | ||
node: true | ||
}, | ||
files: ["**/__tests__/**/*"], | ||
parserOptions: { | ||
sourceType: "module" | ||
}, | ||
rules: { | ||
// Allow to use `console` (example - `mocking`) | ||
"no-console": "off", | ||
// Allow all `es` features in tests, because we use `babel` | ||
"node/no-unsupported-features/es-syntax": "off" | ||
} | ||
}, | ||
|
||
// Configurations and node stuff | ||
{ | ||
env: { | ||
browser: false, | ||
node: true | ||
}, | ||
excludedFiles: ["src/**/*", "**/__tests__/**/*"], | ||
files: [".*.*", "**/*"], | ||
parserOptions: { | ||
sourceType: "script" | ||
}, | ||
rules: { | ||
"no-console": "off", | ||
"node/shebang": "off" | ||
} | ||
}, | ||
|
||
// Markdown | ||
{ | ||
env: { | ||
browser: true, | ||
node: true | ||
}, | ||
files: ["**/*.md"], | ||
parserOptions: { | ||
ecmaFeatures: { | ||
impliedStrict: true | ||
} | ||
}, | ||
rules: { | ||
"import/no-unresolved": "off", | ||
"no-console": "off", | ||
"no-undef": "off", | ||
"no-unused-vars": "off", | ||
"node/no-unpublished-require": "off", | ||
strict: "off" | ||
} | ||
} | ||
], | ||
root: true | ||
}; |
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,5 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
plugins: ["remark-preset-lint-itgalaxy"] | ||
}; |
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
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
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
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
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 |
---|---|---|
@@ -1,19 +1,13 @@ | ||
const Koa = require("koa"); | ||
const Router = require("koa-router"); | ||
const express = require("express"); | ||
const noopServiceWorkerMiddleware = require(".."); | ||
|
||
const app = new Koa(); | ||
const router = new Router(); | ||
const app = express(); | ||
|
||
app.use(noopServiceWorkerMiddleware()); | ||
app.use(noopServiceWorkerMiddleware("/custom-service-worker.js")); | ||
|
||
router.get("/", (ctx, next) => { | ||
ctx.body = "Hello World!"; | ||
|
||
return next(); | ||
app.get("/", (req, res) => { | ||
res.status(200).send("Hello World!"); | ||
}); | ||
|
||
app.use(router.routes()); | ||
|
||
module.exports = app; |
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,67 @@ | ||
const got = require("got"); | ||
const app = require("./app"); | ||
|
||
const port = 3100; | ||
|
||
jest.setTimeout(100000); | ||
|
||
describe("basic", () => { | ||
let server = null; | ||
|
||
beforeAll( | ||
() => | ||
new Promise((resolve, reject) => { | ||
server = app.listen(port, error => { | ||
if (error) { | ||
return reject(error); | ||
} | ||
|
||
return resolve(); | ||
}); | ||
}) | ||
); | ||
|
||
afterAll(() => server && server.close()); | ||
|
||
it("should responses with code 200", () => { | ||
expect.assertions(3); | ||
|
||
return got(`http://localhost:${port}`).then(response => { | ||
expect(response.headers["content-type"]).toBe("text/html; charset=utf-8"); | ||
expect(response.statusCode).toBe(200); | ||
expect(response.body).toBe("Hello World!"); | ||
|
||
return Promise.resolve(); | ||
}); | ||
}); | ||
|
||
it("should responses with code 200 and return service worker noop code", () => { | ||
expect.assertions(3); | ||
|
||
return got(`http://127.0.0.1:${port}/service-worker.js`).then(response => { | ||
expect(response.headers["content-type"]).toBe( | ||
"text/javascript; charset=utf-8" | ||
); | ||
expect(response.statusCode).toBe(200); | ||
expect(response.body).not.toHaveLength(0); | ||
|
||
return Promise.resolve(); | ||
}); | ||
}); | ||
|
||
it("should responses with code 200 and return service worker noop code (custom name)", () => { | ||
expect.assertions(3); | ||
|
||
return got(`http://127.0.0.1:${port}/custom-service-worker.js`).then( | ||
response => { | ||
expect(response.headers["content-type"]).toBe( | ||
"text/javascript; charset=utf-8" | ||
); | ||
expect(response.statusCode).toBe(200); | ||
expect(response.body).not.toHaveLength(0); | ||
|
||
return Promise.resolve(); | ||
} | ||
); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
hooks: { | ||
"pre-commit": "lint-staged" | ||
} | ||
}; |
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
Oops, something went wrong.