-
Notifications
You must be signed in to change notification settings - Fork 2
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
Raymond Ottun
committed
Sep 27, 2021
1 parent
1a5806c
commit 12edcec
Showing
7 changed files
with
68 additions
and
67 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 |
---|---|---|
@@ -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", | ||
}, | ||
}; |
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,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); |
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
Binary file not shown.
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,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(); | ||
}); |