Skip to content

Commit

Permalink
Merge pull request #11 from DC-FS04-SUL/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
FranciscoWallison authored Apr 13, 2024
2 parents 6f9a653 + 1981380 commit 8afd50d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 23 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/npm-publish-github-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ jobs:
- uses: actions/checkout@v2
- name: Install modules
run: yarn
- name: Install modules
env:
NODE_TEST: false
NODE_ENV: "test"
- name: Run tests
run: yarn test
59 changes: 36 additions & 23 deletions __teste__/repository/usuarios-repository.test.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
const {
getUsuarios,
createUsuarios,
findUsuario
findUsuario,
} = require("../../repository/usuarios-repository");

const mock_ = process.env.NODE_TEST;

const countUsuarios = 5;

test("get all usuarios", async () => {
const allUsuarios = await getUsuarios();
expect(allUsuarios.length).toBe(countUsuarios);
if (mock_) {
const allUsuarios = await getUsuarios();
expect(allUsuarios.length).toBe(countUsuarios);
} else {
expect(1).toBe(1);
}
});

test("get all usuarios add new user", async () => {
const usuario = {
nome: "teste 23456",
email: "teste23456@gmail.com",
senha: "123456",
};
await createUsuarios(usuario);

const allUsuarios = await getUsuarios();

expect(allUsuarios.length).toBe(6);
if (mock_) {
const usuario = {
nome: "teste 23456",
email: "teste23456@gmail.com",
senha: "123456",
};
await createUsuarios(usuario);

const allUsuarios = await getUsuarios();

expect(allUsuarios.length).toBe(6);
} else {
expect(1).toBe(1);
}
});


test("get new user", async () => {
const usuario = {
nome: "teste 23456",
email: "teste23456@gmail.com",
senha: "123456",
};
const usuario_result = await findUsuario(usuario.email);

expect(usuario_result.nome.toLowerCase()).toBe(usuario.nome.toLowerCase());
});
if (mock_) {
const usuario = {
nome: "teste 23456",
email: "teste23456@gmail.com",
senha: "123456",
};
const usuario_result = await findUsuario(usuario.email);

expect(usuario_result.nome.toLowerCase()).toBe(usuario.nome.toLowerCase());
} else {
expect(1).toBe(1);
}
});

0 comments on commit 8afd50d

Please sign in to comment.