Skip to content

Commit

Permalink
Update readme and ignorePatterns for stryker-mutator
Browse files Browse the repository at this point in the history
  • Loading branch information
GleytonLima committed Dec 25, 2021
1 parent 00d45d1 commit 5a050e3
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 1 deletion.
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,95 @@

Interpret some simples rules in json to generate notifications

# About The Project

A way for persist some configurable rules for use in some data in frontend.

## Usage

Install the package from npm:

```
npm i simple-rule-notification
```

Import the package:

```js
const srn = require("simple-rule-notification");
```

Retrieve the following rules from backend:

```js
const operacaoGrupo = {
id: 1,
acaoEnum: "CRIAR_REGISTRO_ATIVIDADE_NOTIFICACAO",
operacaoRaiz: {
id: 2,
nomeCampo: "ocorrencia",
comparadorEnum: "IGUAL",
valor: "valor_esperado",
proximaOperacao: null,
operadorProximaOperacao: null,
},
tituloPadrao: "Ocorrência no Campo",
mensagemPadrao: "O campo ocorrência foi preenchido.",
tipoMensagem: "INFO",
quantidadeDiasEntreDatasChave: null,
respostasPadrao: null,
};
```

Then build a strategy and execute it, passing the data:

```js
const data = {
respostas: {
ocorrencia: "valor_esperado",
},
};
const applicableRule = srn.buildAcaoStrategy(operacaoGrupo, data).executar();
```

In this case the return will be:

```json
{ "tipo": "CRIAR_REGISTRO_ATIVIDADE_NOTIFICACAO" }
```

If the entry has the following value:

```js
const data = {
respostas: {
ocorrencia: "valor_nao_esperado",
},
};
```

The return will be:

```js
null;
```

## Unit tests - Jest

```
npm test
```

```
--------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
functions.ts | 100 | 100 | 100 | 100 |
index.ts | 100 | 100 | 100 | 100 |
--------------|---------|----------|---------|---------|-------------------
```

## Mutation Test - Striker

```
Expand Down
3 changes: 2 additions & 1 deletion stryker.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"enableFindRelatedTests": true
},
"checkers": ["typescript"],
"tsconfigFile": "tsconfig.json"
"tsconfigFile": "tsconfig.json",
"ignorePatterns": ["lib"]
}

0 comments on commit 5a050e3

Please sign in to comment.