Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions logic-exercises/anagrama/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_module
build
package-lock.json
8 changes: 8 additions & 0 deletions logic-exercises/anagrama/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
roots: ["<rootDir>/tests"],
transform: {
"^.+\\.tsx?$": "ts-jest",
},
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
};
24 changes: 24 additions & 0 deletions logic-exercises/anagrama/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "anagrama",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "ts-node-dev --transpile-only --ignore-watch node_modules ./src/index.ts",
"test": "clear && jest",
"start": "tsc && node ./build/src/index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"jest": "^27.5.1",
"ts-jest": "^27.1.3",
"ts-node-dev": "^1.1.8"
},
"devDependencies": {
"@types/jest": "^27.4.0",
"@types/node": "^17.0.16",
"typescript": "^4.5.5"
}
}
5 changes: 5 additions & 0 deletions logic-exercises/anagrama/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const palavra2EhAnagramaDe1 =(palavra1: string, palavra2: string) => {
return palavra1.split("").sort().join("") === palavra2.split("").sort().join("")
}

console.log(palavra2EhAnagramaDe1("anagrama", "nagarama"))
31 changes: 31 additions & 0 deletions logic-exercises/anagrama/tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { palavra2EhAnagramaDe1 } from "../src";

test("Palavra2 é um anagrama da Palavra1", ()=>{

const palavra1 = "anagrama"
const palavra2 = "nagarama"

const result =palavra2EhAnagramaDe1(palavra1,palavra2)

expect(result).toBe(true);
})

test("Palavra2 é um anagrama da Palavra1", ()=>{

const palavra1 = "gato"
const palavra2 = "toga"

const result =palavra2EhAnagramaDe1(palavra1,palavra2)

expect(result).toBe(true);
})

test("Palavra2 é um anagrama da Palavra1", ()=>{

const palavra1 = "gato"
const palavra2 = "rato"

const result =palavra2EhAnagramaDe1(palavra1,palavra2)

expect(result).toBe(false);
})
13 changes: 13 additions & 0 deletions logic-exercises/anagrama/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "es6" ,
"module": "commonjs",
"outDir": "./build" ,
"rootDir": "./" ,
"strict": true ,
"sourceMap": true,
"removeComments": true,
"esModuleInterop": true ,
"forceConsistentCasingInFileNames": true
}
}