Skip to content

Commit

Permalink
feat(graduated_tiered_pricing): add adrianliz typescript solution (Co…
Browse files Browse the repository at this point in the history
…delyTV#56)

feat(graduated_tiered_pricing): add typescript solution
  • Loading branch information
JavierCane authored Apr 3, 2023
2 parents 3ff37e8 + 312ceeb commit 3be68c0
Show file tree
Hide file tree
Showing 29 changed files with 30,800 additions and 0 deletions.
21 changes: 21 additions & 0 deletions exercises/graduated_tiered_prices/solutions/adrianliz/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
parser: "@typescript-eslint/parser",
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
],
plugins: ["eslint-plugin-html", "simple-import-sort", "import"],
parserOptions: {
ecmaVersion: 12,
sourceType: "module",
},
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
},
ignorePatterns: ["webpack.*.js"],
};
28 changes: 28 additions & 0 deletions exercises/graduated_tiered_prices/solutions/adrianliz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# Build output
dist
21 changes: 21 additions & 0 deletions exercises/graduated_tiered_prices/solutions/adrianliz/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 CodelyTV

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
57 changes: 57 additions & 0 deletions exercises/graduated_tiered_prices/solutions/adrianliz/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Product pricing: TypeScript

TypeScript codebase for the [Graduated Product pricing](../../README.md) exercise.

## Setup

```
# install dependencies
npm install
```

## Testing

### Unit Testing

```
npm run test
```

### E2E Testing

```
# run in dev mode on port 8080
npm run dev
# open Cypress to run tests on dev mode
npm run cy:open
# open Cypress on CLI
npm run cy:run
```

## Running the app

```
# install dependencies
npm install
# run in dev mode on port 8080
npm run dev
# generate production build
npm run build
# run generated content in dist folder on port 8080
npm run start
```

## Linting

```
# run linter
npm run lint
# fix lint issues
npm run lint:fix
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "usage",
"corejs": "3.9.1"
}
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"baseUrl": "http://localhost:8080",
"video": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
describe("The Home Page", () => {
it("successfully loads", () => {
cy.visit("/");
cy.findByRole("heading", { name: /product pricing/i }).should("exist");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

/**
* @type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

import "@testing-library/cypress/add-commands";
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"noEmit": true,
"types": ["cypress", "@testing-library/cypress"]
},
"include": ["../node_modules/cypress", "./**/*.ts"]
}
12 changes: 12 additions & 0 deletions exercises/graduated_tiered_prices/solutions/adrianliz/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<h1>Product pricing</h1>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
testMatch: ["**/tests/*.(spec|test).ts"],
transform: {
"\\.[jt]sx?$": "ts-jest",
},
moduleNameMapper: {
"\\.(css|less)$": "identity-obj-proxy",
},
testEnvironment: "jsdom",
};
Loading

0 comments on commit 3be68c0

Please sign in to comment.