Browse Source

convert to typescript

master
Loopcruitment 3 years ago
parent
commit
6e9709db28
10 changed files with 706 additions and 233 deletions
  1. +2
    -1
      .gitignore
  2. +8
    -8
      README.md
  3. +7
    -0
      jest.config.js
  4. +655
    -201
      package-lock.json
  5. +8
    -4
      package.json
  6. +0
    -10
      src/get-arnie-quotes.js
  7. +1
    -1
      src/get-arnie-quotes.spec.ts
  8. +9
    -0
      src/get-arnie-quotes.ts
  9. +2
    -8
      src/mock-http-interface.ts
  10. +14
    -0
      tsconfig.json

+ 2
- 1
.gitignore View File

@ -1 +1,2 @@
node_modules
node_modules
dist

+ 8
- 8
README.md View File

@ -3,23 +3,23 @@
## System Requirements ## System Requirements
The coding challenge requires the following to be installed on your development machine; The coding challenge requires the following to be installed on your development machine;
* [nodejs](https://nodejs.org/en/download/) version 10 or above.
* [nodejs](https://nodejs.org/en/download/) version 12 or above.
* A [git](https://git-scm.com/downloads) client. * A [git](https://git-scm.com/downloads) client.
## Installation ## Installation
1. Fork the `javascript-developer-test` repository to your personal github account.
2. Clone the `javascript-developer-test` repository from your personal github account onto your development machine.
3. Open a terminal and `cd` into the root directory of the `javascript-developer-test` repository.
1. Fork the `ts-test` repository to your personal github account.
2. Clone the `ts-test` repository from your personal github account onto your development machine.
3. Open a terminal and `cd` into the root directory of the `ts-test` repository.
4. Execute `npm install` in the terminal. 4. Execute `npm install` in the terminal.
## Challenge Instructions ## Challenge Instructions
Your challenge is to implement the `getArnieQuotes()` function, which is exported from `./src/get-arnie-quotes.js`.
Your challenge is to implement the `getArnieQuotes()` function, which is exported from `./src/get-arnie-quotes.ts`.
The `getArnieQuotes()` function accepts an array of strings, with each string containing a URL. The `getArnieQuotes()` function accepts an array of strings, with each string containing a URL.
The unit tests in `./src/get-arnie-quotes.test.js` will provide pre-defined URLs to the function and test your function's implementation. To run the unit tests, execute `npm test` in the terminal.
The unit tests in `./src/get-arnie-quotes.spec.ts` will provide pre-defined URLs to the function and test your function's implementation. To run the unit tests, execute `npm test` in the terminal.
The goal is to write an implementation of `getArnieQuotes()` that meets all requirements and passes all unit tests. The goal is to write an implementation of `getArnieQuotes()` that meets all requirements and passes all unit tests.
## Requirements ## Requirements
@ -34,8 +34,8 @@ Finally, the `getArnieQuotes()` function's return value must be a promise that r
Note that for this challenge, the HTTP calls are mocked. You *must* use the provided `httpGet` function to perform your HTTP requests. Note that for this challenge, the HTTP calls are mocked. You *must* use the provided `httpGet` function to perform your HTTP requests.
## Tips ## Tips
* Only modify the `get-arnie-quotes.js` file.
* You may introduce additional internal functions in `get-arnie-quotes.js`
* Only modify the `get-arnie-quotes.ts` file.
* You may introduce additional internal functions in `get-arnie-quotes.ts`
* Exploring all of the code files may provide you with useful hints. * Exploring all of the code files may provide you with useful hints.
* Not all of the requirements are covered by the unit tests. * Not all of the requirements are covered by the unit tests.
* We are most impressed with readable code that works. * We are most impressed with readable code that works.


+ 7
- 0
jest.config.js View File

@ -0,0 +1,7 @@
module.exports = {
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: '(/__tests__/.*|(src|test)/.*(\\.|-|/)(test|spec))\\.(jsx?|tsx?)$',
moduleFileExtensions: ['ts', 'tsx', 'json', 'js', 'jsx'],
};

+ 655
- 201
package-lock.json
File diff suppressed because it is too large
View File


+ 8
- 4
package.json View File

@ -1,14 +1,18 @@
{ {
"name": "@loopcruitment/js-test",
"name": "@loopcruitment/ts-test",
"version": "2.0.2", "version": "2.0.2",
"description": "", "description": "",
"main": "./index.js", "main": "./index.js",
"author": "Smokeball Development Team", "author": "Smokeball Development Team",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "jest"
"test": "jest",
"build": "tsc"
}, },
"dependencies": {
"jest": "27.0.6"
"devDependencies": {
"@types/jest": "^26.0.24",
"jest": "^27.0.6",
"ts-jest": "^27.0.4",
"typescript": "^4.0.0"
} }
} }

+ 0
- 10
src/get-arnie-quotes.js View File

@ -1,10 +0,0 @@
const { httpGet } = require('./mock-http-interface');
const getArnieQuotes = async (urls) => {
// TODO: Implement this function.
// return results;
};
module.exports = {
getArnieQuotes,
};

src/get-arnie-quotes.test.js → src/get-arnie-quotes.spec.ts View File


+ 9
- 0
src/get-arnie-quotes.ts View File

@ -0,0 +1,9 @@
import { httpGet } from './mock-http-interface';
type TResult = {"Arnie Quote" : string} | { "FAILURE" : string}
export const getArnieQuotes = async (urls : string[]) : Promise<TResult[]> => {
// TODO: Implement this function.
return [];
};

src/mock-http-interface.js → src/mock-http-interface.ts View File


+ 14
- 0
tsconfig.json View File

@ -0,0 +1,14 @@
{
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"],
"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"incremental": false,
"strict": true,
"module": "commonjs",
"noImplicitAny": true,
"target": "es2019",
"lib": ["es2020"]
}
}

Loading…
Cancel
Save