# dem-testing-tool

> > A Node.js Command Line Application

Latest version **1.2.4** (published 2023-03-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install dem-testing-tool
pnpm add dem-testing-tool
yarn add dem-testing-tool
bun add dem-testing-tool
```

Provides the command `dem`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.4 |
| Published | 2023-03-07 |
| First published | 2022-05-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 30 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | gnommys |

## Links

- npm: https://www.npmjs.com/package/dem-testing-tool
- npm.io page: https://npm.io/package/dem-testing-tool

## Dependencies (7)

- [glob](https://npm.io/package/glob.md) ^8.0.3
- [cheerio](https://npm.io/package/cheerio.md) ^1.0.0-rc.11
- [signale](https://npm.io/package/signale.md) ^1.4.0
- [cli-color](https://npm.io/package/cli-color.md) ^2.0.2
- [commander](https://npm.io/package/commander.md) ^9.2.0
- [cli-progress](https://npm.io/package/cli-progress.md) ^3.11.1
- [html-validator](https://npm.io/package/html-validator.md) ^6.0.1

## Recent versions

- 1.2.4 (latest) — 2023-03-07
- 1.2.3 — 2022-11-25
- 1.2.2 — 2022-11-25
- 1.2.1 — 2022-08-23
- 1.2.0 — 2022-08-23
- 1.1.5 — 2022-07-29
- 1.1.4 — 2022-07-21
- 1.1.3 — 2022-07-07
- 1.1.2 — 2022-07-07
- 1.1.1 — 2022-07-04
- 1.1.0 — 2022-06-29
- 1.0.10 — 2022-06-22
- 1.0.9 — 2022-06-21
- 1.0.8 — 2022-06-21
- 1.0.7 — 2022-06-09
- … 7 more at https://npm.io/package/dem-testing-tool/versions

## README

# Dem Testing Tool

> A Node.js Command Line Application

## Table of Contents

- [General Info](#general-information)
- [Setup](#setup)
- [How To Update](#how-to-update)
- [Usage](#usage)
- [Technologies Used](#technologies-used)
- [Tests](#test-list)
- [Edit Command](#edit-command)
- [Screenshot](#screenshot)
- [Changelog](#changelog)

## General Information

This is a command line app for automate some of the test we made for our DEM.

## Setup

##### If you don't have node.js installed, please download and install it from here

[https://nodejs.org/it/download/](https://nodejs.org/it/download/)

##### Open your terminal and install the package globally:

- `npm i -g dem-testing-tool`

_**Important: Open your terminal as administrator on Windows, on Mac OS & Linux you will need to use `sudo npm i -g dem-testing-tool`**_

_**Important: In Windows you could need to edit the ExecutionPolicy settings to use this command line:**_

- Open PowerShell as administrator and paste this command:
  - `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned`

Reference: [https://docs.microsoft.com/it-it/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.2](https://docs.microsoft.com/it-it/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.2)

_**Important: In your mjml file add this classes:**_

- Facebook anchor: `class="facebook-link"`
- Youtube anchor: `class="youtube-link"`
- Linkedin anchor: `class="linkedin-link"`
- Disclaimer (sicurezza) anchor: `class="disclaimer-link"`
- Disclaimer text: `css-class="disclaimer-text"`

## How to update

##### Open your terminal and install the package globally:

- `npm update -g dem-testing-tool`

_**Important: Open your terminal as administrator on Windows, on Mac OS & Linux you will need to use `sudo npm update -g dem-testing-tool`**_

## Usage

1. Navigate **inside the general dem folder** - **(NOT the id dem folder)**
   - Example:
     - Here > _**Motore Italia Digitale - soluzioni e-commerce_v3**_
     - Not here > **Motore Italia Digitale - soluzioni e-commerce_v3/5449/**
2. Open the terminal, and launch the command `dem test`
3. Wait for the test to complete

## Technologies Used

- Node.js
- cli-color
- glob
- html-validator
- signale
- cli-color
- cli-progress

## Tests

List of the tests here:

- ##### File Html - Verificare presenza di `<div style>`
  Regex: `<div style>`

	- _Function name => `testStyle()`_
---

- ##### Cartella /images/ - Verificare che immagini siano max 250kb

	- _Function name => `testImagesSize()`_

---

- ##### Cartella /images/ - Verificare che non ci siano immagini inutilizate nella cartella images (estensioni: png, jpg, jpeg, gif)

	- _Function name => `testUnusedImages()`_

---

- ##### File Html - Verificare se c'è ubuntu (font size inutilizzato, sia come chiamata che come font assegnato ad elementi)
  Regex: `ubuntu`

	- _Function name => `testUbuntu()`_

---

- ##### File Html - Verificare presenza di ;; in codice
  Regex: `;;`

	- _Function name => `testDoubleSemicolon()`_

---

- ##### File Html - Verificare presenza classe cta-box-shadow e in caso rimuovere
  Regex: `cta-box-shadow`

	- _Function name => `testCtaBoxShadow()`_

---

- ##### File Html - Verificare presenza di cdn in link immagini
  Regex: `cdn`

	- _Function name => `testCdn()`_

---

- ##### File Html - Verificare presenza di width 90% in ogni tag `<a>`
  Regex: `width:90%`

	- _Function name => `testWidthCta()`_

---

- ##### Cartella images - Verificare che non ci siano caratteri accentati o particolari nei nomi file
   _Caratteri speciali: [!$%^&\*()+|~=`{}\[\]:\/;<>?,@#_]

  - _Function name => `testImagesNames()`_

---

- ##### File Html - Verificare che non ci sia icona twitter.
  Regex:`twitter_icon.png`

  - _Function name => `testTwitterIcon()`_

---

- ##### File Html - Verifica se i link facebook, youtube, linkedin, e sicurezza sono corretti
  Regex:
  `href="https://www.facebook.com/intesasanpaolo/"`
  `href="https://www.youtube.com/user/intesasanpaolo"`
  `href="https://www.linkedin.com/company/intesa-sanpaolo/"`
  `href="https://www.intesasanpaolo.com/it/common/footer/sicurezza.html"`
  
    - _Function name => `testSocialLink()`_
---

- ##### File Html - Varifica che tutti i link (anchor) abbiano come target \_blank
  Regex: `_blank`

    - _Function name => `testBlank()`_

---

- ##### File Html - Verificare non ci sia "www" nel diclaimer
  Regex: `\s+[www]+\.+(.*?)(com|it|org|net|eu)\b`
  I link all'interno dei tag `<a></a>` non vengono considerati

    - _Function name => `testWww()`_

---

- ##### File Html - Verificare presenza variabili "${package_code}$ ${surrogate_key}$"
  Regex: `/\$\{package\_code\}\$\$\{surrogate_key\}\$/g`

    - _Function name => `checkBottomVariables()`_

---

- ##### File Html - Validazione dei file con il pacchetto npm `html-validator` per ricerca errori in console
   Test esclusi:
    - `no-deprecated-attr`
    - `no-conditional-comment`
    - `element-required-attributes`


   - _Function name => `testHtmlErrors()`_

---

- ##### File Html - Verificare presenza della proprietà nel tag html `lang="it"`
Regex: `/lang\=\"it\"/g`

 - _Function name => `checkHtmlLang()`_

---

- ##### File Html - Verificare presenza di spazi all'interno di ogni href di ogni link con tag `<a>`
Regex: `/href="(.*?)"/g` - `/(\s)/`

 - _Function name => `testSpacesInLink()`_

---

- ##### File Html - Verificare se esistono spazi all'inizio o alla fine del preheader

  StartRegex: `/;">+\s/gi` || EndRegex: `/\s+<\//gi`

  - _Function name => `testPreheaderSpaces()`_

---

- ##### File Html - Verificare se esistono spazi dentro gli alt nei tag `img`

  StartRegex: `/alt="+\s/gi` || EndRegex: `/\s+" /gi`

  - _Function name => `testImageAltSpaces()`_

---
## Edit Command

#### Example usage

`dem edit --rename "folder name"`
or
`dem edit -r "folder name"`

where the `"folder name"`is the target directory.

You can also use the command `dem edit -h` for more details.

This command will rename your folder in this way:

1. remove special characters - regex: `regex(/[!$%^&*()+|~={}\[\]:\/;<>?,\.@#]/g`)
2. replace accent letter with a normalized letter
3. replace `_` with `-` - regex: `regex(/_/g, "-")`
4. replace a space with `-` between two characters - regex: `regex(/\b\s\b/g, "-")`
5. replace remove all spaces - regex `regex(/\s/g, "")`
6. lowercase all the characters - `.toLocaleLowerCase()`

## Screenshot

![Example screenshot](https://i.ibb.co/6r9mm68/Screenshot-2022-11-25-at-12-11-16.png)

## Changelog

### 07/04/2023

- Added a new test `testPreheaderSpaces` to check preheader spaces
- Added a new test `testImageAltSpaces` to check alts spaces

### 23/08/2022

- Added extensions (jpeg and gif) to `testUnusedImages` test

### 29/07/2022

- Added a new test `checkHtmlLang` to check the property `lang="it"`

### 21/07/2022

- Added a new test `checkBottomVariables` to check the presence and the correct name of two variables `${package_code}$ ${surrogate_key}$`

### 29/06/2022

- Added a `throw Error()` when the command is NOT launched into the main directory.

### 07/07/2022

- Added `dem edit --rename <folder>` command to rename dem folders correctly
- Add a check for testImagesNames() if uppercase exists

### 25/11/2022

- Added a new test `testSpacesInLink` to check the presence of spaces inside a href=""

---
_Source: https://npm.io/package/dem-testing-tool · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
