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
1 change: 1 addition & 0 deletions TPSI/correndo_marco/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
3 changes: 3 additions & 0 deletions TPSI/correndo_marco/esercizi_tdd_STUDENTI/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const abbreviazione = (str) => {
let nome = str.split(" ")[0];
let cognome = str.split(" ")[1];

nome = nome.charAt(0).toUpperCase().concat(nome.slice(1,nome.length));
cognome = (" ").concat(cognome.toUpperCase().charAt(0));
return nome.concat(cognome.concat("."));
};


24 changes: 24 additions & 0 deletions TPSI/correndo_marco/esercizi_tdd_STUDENTI/esercizio_js_23/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { abbreviazione } from './es_23.js';

describe("ESERCIZIO 23", () => {
test('TEST 01', () => {
expect(abbreviazione('Antonio Mancuso')).toBe('Antonio M.');
});

test('TEST 02', () => {
expect(abbreviazione('marco rossi')).toBe('Marco R.');
});

test('TEST 03', () => {
expect(abbreviazione('giOVANNI vErDi')).toBe('GiOVANNI V.');
});

test('TEST 04', () => {
expect(abbreviazione('MileNA m.')).toBe('MileNA M.');
});

test('TEST 05', () => {
expect(abbreviazione('linux torvald')).not.toBe('Linux t.');
});
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const protect_email = (email) => {
let info = email.split("@")[0];
let ris = info.slice(0,info.length/2).concat("...");
return ris.concat("@",email.split("@")[1]);
}
24 changes: 24 additions & 0 deletions TPSI/correndo_marco/esercizi_tdd_STUDENTI/esercizio_js_24/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { protect_email } from './es_24.js';

describe("ESERCIZIO 24", () => {
test('TEST 01', () => {
expect(protect_email('antonio.mancuso@istitutoagnelli.it')).toBe('antonio...@istitutoagnelli.it');
});

test('TEST 02', () => {
expect(protect_email('marco.pai@gmail.com')).toBe('marc...@gmail.com');
});

test('TEST 03', () => {
expect(protect_email('massimoRossi@gmail.it')).toBe('massim...@gmail.it');
});

test('TEST 04', () => {
expect(protect_email('a@email.it')).toBe('...@email.it');
});

test('TEST 05', () => {
expect(protect_email('andre@email.com')).toBe('an...@email.com');
});
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const untokenize = (str) => {
return str.replaceAll(" ","-");
};
24 changes: 24 additions & 0 deletions TPSI/correndo_marco/esercizi_tdd_STUDENTI/esercizio_js_25/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { untokenize } from './es_25.js';

describe("ESERCIZIO 25", () => {
test('TEST 01', () => {
expect(untokenize('Nel mezzo del cammin di nostra vita')).toBe('Nel-mezzo-del-cammin-di-nostra-vita');
});

test('TEST 02', () => {
expect(untokenize('supercalifragilistiche')).toBe('supercalifragilistiche');
});

test('TEST 03', () => {
expect(untokenize('Nel mezzo del cammin di')).toBe('Nel-mezzo---del-cammin-------di');
});

test('TEST 04', () => {
expect(untokenize('')).toBe('');
});

test('TEST 05', () => {
expect(untokenize('Nel mezzo-del-cammin di')).toBe('Nel-mezzo-del-cammin--di');
});
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const capitalize = (str) => {
return str.charAt(0).toUpperCase() + str.substring(1,str.length)
}
24 changes: 24 additions & 0 deletions TPSI/correndo_marco/esercizi_tdd_STUDENTI/esercizio_js_26/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { capitalize } from './es_26.js';

describe("ESERCIZIO 26", () => {
test('TEST 01', () => {
expect(capitalize('ciamo mondo!!!')).toBe('Ciamo mondo!!!');
});

test('TEST 02', () => {
expect(capitalize('o0ciao-mondo!')).toBe('O0ciao-mondo!');
});

test('TEST 03', () => {
expect(capitalize('questo mondo in JS')).not.toBe('questo mondo in JS');
});

test('TEST 04', () => {
expect(capitalize('ciao Mondo')).toBe('Ciao Mondo');
});

test('TEST 05', () => {
expect(capitalize('')).toBe('');
});
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const capitalize_all = (str) => {
let parole = str.trim().split(" ");
let tot = "";
for(let i = 0;i<parole.length;i++){
tot += parole[i].charAt(0).toUpperCase() + parole[i].substring(1,(parole[i]).length) + ( i == parole.length - 1 ? "" : " ");
}
return tot;
}
24 changes: 24 additions & 0 deletions TPSI/correndo_marco/esercizi_tdd_STUDENTI/esercizio_js_27/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { capitalize_all } from './es_27.js';

describe("ESERCIZIO 27", () => {
test('TEST 01', () => {
expect(capitalize_all('ciao mondo la terra gira!!!')).toBe('Ciao Mondo La Terra Gira!!!');
});

test('TEST 02', () => {
expect(capitalize_all('ciao Mondo la terra Gira!!!')).toBe('Ciao Mondo La Terra Gira!!!');
});

test('TEST 03', () => {
expect(capitalize_all('')).toBe('');
});

test('TEST 04', () => {
expect(capitalize_all('cIAO mONDO lA tERRA GIRA!!!')).toBe('CIAO MONDO LA TERRA GIRA!!!');
});

test('TEST 05', () => {
expect(capitalize_all('cIao mOndo La Terra gira!!!')).toBe('CIao MOndo La Terra Gira!!!');
});
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const upper_case = (str) => {
let ris = "";
for(let i = 0;i<str.length;i++){
let c = str.charCodeAt(i);
ris += ( c >= 97 && c <= 122) ? String.fromCharCode(c - 32) : str.charAt(i) ;
}
return ris;
}
24 changes: 24 additions & 0 deletions TPSI/correndo_marco/esercizi_tdd_STUDENTI/esercizio_js_28/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { upper_case } from './es_28.js';

describe("ESERCIZIO 28", () => {
test('TEST 01', () => {
expect(upper_case('ciao mondo!!!')).not.toBe('ciao mondo');
});

test('TEST 02', () => {
expect(upper_case('ciao mondo!!!')).toBe('CIAO MONDO!!!');
});

test('TEST 03', () => {
expect(upper_case('ciaO Mondo!!!')).toBe('CIAO MONDO!!!');
});

test('TEST 04', () => {
expect(upper_case('')).toBe('');
});

test('TEST 05', () => {
expect(upper_case('CIAO mondo!!!')).toBe('CIAO MONDO!!!');
});
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const invert_case = (str) => {
let ris = "";
for(let i = 0;i<str.length;i++){
let c = str.charAt(i);
ris += c == c.toLowerCase() ? c.toUpperCase(): c.toLowerCase();
}
return ris;
}
23 changes: 23 additions & 0 deletions TPSI/correndo_marco/esercizi_tdd_STUDENTI/esercizio_js_29/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { invert_case } from "./es_29.js";

describe("ESERCIZIO 29", () => {
test('TEST 01', () => {
expect(invert_case('Ciao Mondo!!!')).toBe('cIAO mONDO!!!');
});

test('TEST 02', () => {
expect(invert_case('Antonio Mancuso')).toBe('aNTONIO mANCUSO');
});

test('TEST 03', () => {
expect(invert_case('giOVANNI vErDi')).toBe('GIovanni VeRdI');
});

test('TEST 04', () => {
expect(invert_case('Ciro va al mercato...\nCompra 2 mele e una pera...\nQuanto è lungo l`equatore')).toBe('cIRO VA AL MERCATO...\ncOMPRA 2 MELE E UNA PERA...\nqUANTO È LUNGO L`EQUATORE');
});

test('TEST 05', () => {
expect(invert_case('linux torvald')).toBe('LINUX TORVALD');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const tronca = (str, l) => {
return l > str.length ? str : str.substring(0,l) + "...";
}
23 changes: 23 additions & 0 deletions TPSI/correndo_marco/esercizi_tdd_STUDENTI/esercizio_js_30/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { tronca } from "./es_30.js";

describe("ESERCIZIO 30", () => {
test('TEST 01', () => {
expect(tronca('Ciao Mondo la terra gira!!!', 10)).toBe('Ciao Mondo...');
});

test('TEST 02', () => {
expect(tronca('So Nvidia FUCK YOU!!!', 12)).toBe('So Nvidia FU...');
});

test('TEST 03', () => {
expect(tronca('Ciro Esposito', 15)).toBe('Ciro Esposito');
});

test('TEST 04', () => {
expect(tronca('C`era una volta tanto tempo fa in una galassia', 27)).toBe('C`era una volta tanto tempo...');
});

test('TEST 05', () => {
expect(tronca('gahboot1aezaeMai3xouP9AhR4EiToowai5eKofaesuere9boomoh0ahCho5Utid4za6ohyoo5paeterunietievei3fee7aekai', 69)).toBe('gahboot1aezaeMai3xouP9AhR4EiToowai5eKofaesuere9boomoh0ahCho5Utid4za6o...');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const search_words = (ph) => {
const str = "parole non trovate";
if(ph.includes("coding") || ph.includes("creativo")){
return ph;
}
return str;
};
23 changes: 23 additions & 0 deletions TPSI/correndo_marco/esercizi_tdd_STUDENTI/esercizio_js_31/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { search_words } from "./es_31.js";

describe("ESERCIZIO 31", () => {
test('TEST 01', () => {
expect(search_words('C`era una volta coding che lavorava nel settore creativo')).toBe('C`era una volta coding che lavorava nel settore creativo');
});

test('TEST 02', () => {
expect(search_words('marco rossi')).toBe('parole non trovate');
});

test('TEST 03', () => {
expect(search_words('Picasso era creativo')).toBe('Picasso era creativo');
});

test('TEST 04', () => {
expect(search_words('La creatività è bella')).toBe('parole non trovate');
});

test('TEST 05', () => {
expect(search_words('Il coding conquisterà il mondo')).toBe('Il coding conquisterà il mondo');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const special_concat = (str1, str2) => {
if(!str1.length || !str2.length) return "parole non adatte";
if(str1.split(" ").length != 1 || str2.split(" ").length != 1) return "parole non adatte";
let primiDueChar = [str1.substring(0,2),str2.substring(0,2)]
return primiDueChar[1] + str1.substring(2,str1.length) + primiDueChar[0] + str2.substring(2,str2.length)
};
23 changes: 23 additions & 0 deletions TPSI/correndo_marco/esercizi_tdd_STUDENTI/esercizio_js_32/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { special_concat } from "./es_32.js";

describe("ESERCIZIO 32", () => {
test('TEST 01', () => {
expect(special_concat('Ciro', 'Esposito')).toBe('EsroCiposito');
});

test('TEST 02', () => {
expect(special_concat('Mario', 'Rossi Filippo')).toBe('parole non adatte');
});

test('TEST 03', () => {
expect(special_concat('', 'verde')).toBe('parole non adatte');
});

test('TEST 04', () => {
expect(special_concat('Mario', '')).toBe('parole non adatte');
});

test('TEST 05', () => {
expect(special_concat('', '')).toBe('parole non adatte');
});
});
Loading