Skip to content

Commit

Permalink
- Removendo o lodash como dependência deste pacote;
Browse files Browse the repository at this point in the history
- Melhorando mock do teste unitário.
  • Loading branch information
leonelsanchesdasilva committed Feb 11, 2024
1 parent 475bfb7 commit cd8cbb5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"@designliquido/visualg": "^0.0.0",
"chalk": "4.1.2",
"commander": "^9.4.1",
"json-colorizer": "^2.2.2",
"lodash.clonedeep": "^4.5.0"
"json-colorizer": "^2.2.2"
},
"devDependencies": {
"@designliquido/delegua-estatistica": "^0.0.5",
Expand Down
9 changes: 9 additions & 0 deletions testes/nucleo-execucao.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ describe('Núcleo de execução', () => {
const funcaoDeRetorno = (saida: string) => retornoSaida += saida;
const nucleoExecucao = new NucleoExecucao('0.1', funcaoDeRetorno);
nucleoExecucao.configurarDialeto();

const realProcess = process;
const exitMock = jest.fn();

// Mock de `process.exit`.
// Se não for feito, o teste falha.
global.process = { ...realProcess, exit: exitMock as any };

// Aqui vamos simular a resposta para duas variáveis de `leia()`.
const respostas = [
Expand All @@ -35,6 +42,8 @@ describe('Núcleo de execução', () => {
};
await nucleoExecucao.carregarEExecutarArquivo('./exemplos/condicionais/escolha-com-enquanto.delegua');

expect(exitMock).toHaveBeenCalledWith(0);
expect(retornoSaida.length).toBeGreaterThan(0);
global.process = realProcess;
});
});

0 comments on commit cd8cbb5

Please sign in to comment.