Skip to content

Commit

Permalink
fix: liting and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymond Ottun committed Sep 27, 2021
1 parent 1a5806c commit 12edcec
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 67 deletions.
46 changes: 23 additions & 23 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
module.exports = {
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
ecmaFeatures: {
jsx: true // Allows for the parsing of JSX
}
},
settings: {
react: {
version: "detect" // Tells eslint-plugin-react to automatically detect the version of React to use
}
},
extends: [
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
"prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
"plugin:prettier/recommended" // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
},
};
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
ecmaFeatures: {
jsx: true, // Allows for the parsing of JSX
},
},
settings: {
react: {
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
},
},
extends: [
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
},
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"deputy": "lib/deputy.js"
},
"scripts": {
"lint": "eslint '*/**/src/*.ts'",
"start": "node --inspect=5858 lib/deputy.js",
"clean": "rm -rf lib",
"build": "tsc",
Expand Down
64 changes: 30 additions & 34 deletions random.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,62 @@
const axios = require('axios')
const axios = require('axios');

const BASE_URL = 'https://localhost:8080'
const BASE_URL = 'https://localhost:8080';

const randomMethod = () => {
const METHODS = ['GET', 'POST', 'DELETE', 'PUT']
const randIndex = Math.floor(Math.random() * (METHODS.length - 1))
return METHODS[randIndex]
}
const METHODS = ['GET', 'POST', 'DELETE', 'PUT'];
const randIndex = Math.floor(Math.random() * (METHODS.length - 1));
return METHODS[randIndex];
};

const randomFaang = () => {
const FAANG = ['google', 'facebook', 'twitter', 'apple']
const randIndex = Math.floor(Math.random() * (FAANG.length - 1))
return FAANG[randIndex]
}
const FAANG = ['google', 'facebook', 'twitter', 'apple'];
const randIndex = Math.floor(Math.random() * (FAANG.length - 1));
return FAANG[randIndex];
};

const randomDevice = () => {
const DEVICES = ['iphone', 'motorola', 'nokia', 'pixel', 'samsung']
const randIndex = Math.floor(Math.random() * (DEVICES.length - 1))
return DEVICES[randIndex]
}
const DEVICES = ['iphone', 'motorola', 'nokia', 'pixel', 'samsung'];
const randIndex = Math.floor(Math.random() * (DEVICES.length - 1));
return DEVICES[randIndex];
};

const randomBody = () => {
return {
[randomFaang()]: Math.floor(Math.random() * 100),
[randomFaang()]: Math.floor(Math.random() * 100),
[randomFaang()]: Math.floor(Math.random() * 100),
[randomFaang()]: Math.floor(Math.random() * 100)
}
}
[randomFaang()]: Math.floor(Math.random() * 100),
};
};

const fillHellos = async (max) => {
for (let i = 0; i <= max; i++) {
const url = i % 2 === 0 ? `${BASE_URL}/hello/${i}` : `${BASE_URL}/hello`
const url = i % 2 === 0 ? `${BASE_URL}/hello/${i}` : `${BASE_URL}/hello`;
try {
await axios(
url, { method: randomMethod(), data: randomBody() }
)
await axios(url, { method: randomMethod(), data: randomBody() });
} catch (e) {
console.error(url, e.message)
console.error(url, e.message);
}
}
}
};

const fillCustomer = async (max) => {
for (let i = 0; i <= max; i++) {
const url = `${BASE_URL}/customer/${i}?device=${randomDevice()}`
const url = `${BASE_URL}/customer/${i}?device=${randomDevice()}`;
try {
await axios(
url, {
await axios(url, {
method: randomMethod(),
headers: {
cookie: `Token=${Math.random() * 100};Marketing=true;`,
'x-customer': randomFaang()
'x-customer': randomFaang(),
},
data: randomBody()
}
)
data: randomBody(),
});
} catch (e) {
console.error(url, e.message)
console.error(url, e.message);
}
}
}
};

fillHellos(2)
fillCustomer(3)
fillHellos(2);
fillCustomer(3);
2 changes: 1 addition & 1 deletion src/deputy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const args = yargs(hideBin(process.argv))
}).argv;

const startServer = async () => {
let app = await createServer({ ...(args as any) });
const app = await createServer({ ...(args as any) });
app.start();
logInfo(args);
return app;
Expand Down
Binary file modified ui/public/favicon.ico
Binary file not shown.
4 changes: 2 additions & 2 deletions ui/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="The behave ui" content="behave ui" />
<meta name="Deputy Server" content="deputy server" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
Expand All @@ -22,7 +22,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Behave Server UI</title>
<title>Deputy Server</title>
</head>

<body>
Expand Down
18 changes: 11 additions & 7 deletions ui/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';
// import React from 'react';
// import { render, screen } from '@testing-library/react';
// import App from './App';

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
// test('renders learn react link', () => {
// render(<App />);
// const linkElement = screen.getByText(/learn react/i);
// expect(linkElement).toBeInTheDocument();
// });
import { mock } from './api';
test('App Test', () => {
expect(mock).not.toThrow();
});

0 comments on commit 12edcec

Please sign in to comment.