File tree Expand file tree Collapse file tree 4 files changed +62
-3
lines changed
Expand file tree Collapse file tree 4 files changed +62
-3
lines changed Original file line number Diff line number Diff line change 11node_modules
2- yarn.lock
2+ yarn.lock
3+ coverage
4+ .nyc_output
Original file line number Diff line number Diff line change 1+ {
2+ "branches" : 100 ,
3+ "lines" : 100 ,
4+ "functions" : 100 ,
5+ "statements" : 100 ,
6+ "checkCoverage" : true ,
7+ "reporter" : [" html" , " text" ]
8+ }
Original file line number Diff line number Diff line change 66 "author" : " Saamu192 <samuelpr192@gmail.com>" ,
77 "license" : " MIT" ,
88 "scripts" : {
9- "dev" : " npx nodemon --ignore database.json --exec node --experimental-json-modules src/index.js"
9+ "dev" : " npx nodemon --ignore database.json --exec node --experimental-json-modules src/index.js" ,
10+ "test" : " npx mocha -w --parallel test/*.test.js" ,
11+ "test:cov" : " npx nyc npx mocha -r reify --parallel test/*.test.js"
1012 },
1113 "dependencies" : {
1214 "chalk" : " ^5.1.2" ,
1315 "chalk-table" : " ^1.0.2" ,
1416 "draftlog" : " ^1.0.13"
1517 },
1618 "devDependencies" : {
17- "nodemon" : " ^2.0.20"
19+ "chai" : " ^4.3.6" ,
20+ "mocha" : " ^10.1.0" ,
21+ "nodemon" : " ^2.0.20" ,
22+ "nyc" : " ^15.1.0" ,
23+ "reify" : " ^0.20.12" ,
24+ "sinon" : " ^14.0.1"
1825 }
1926}
Original file line number Diff line number Diff line change 1+ import mocha from "mocha" ;
2+ const { describe, it } = mocha ;
3+ import chai from "chai" ;
4+ const { expect } = chai ;
5+ import Person from "../src/persons.js" ;
6+
7+ describe ( "Person" , ( ) => {
8+ it ( "should return a person instance from a string" , ( ) => {
9+ const person = Person . generateInstanceFromString (
10+ "1 Bike,Carro 20000 2020-01-01 2020-02-01"
11+ ) ;
12+ const expected = {
13+ from : "2020-01-01" ,
14+ to : "2020-02-01" ,
15+ vehicles : [ "Bike" , "Carro" ] ,
16+ kmTraveled : "20000" ,
17+ id : "1" ,
18+ } ;
19+
20+ expect ( person ) . to . be . deep . equal ( expected ) ;
21+ } ) ;
22+
23+ it ( "should format values" , ( ) => {
24+ const person = new Person ( {
25+ from : "2020-01-01" ,
26+ to : "2020-02-01" ,
27+ vehicles : [ "Bike" , "Carro" ] ,
28+ kmTraveled : "20000" ,
29+ id : "1" ,
30+ } ) ;
31+
32+ const result = person . formatted ( "pt-BR" ) ;
33+ const expected = {
34+ id : 1 ,
35+ vehicles : "Bike e Carro" ,
36+ kmTraveled : "20.000 km" ,
37+ from : "01 de janeiro de 2020" ,
38+ to : "01 de fevereiro de 2020" ,
39+ } ;
40+ expect ( result ) . to . be . deep . equal ( expected ) ;
41+ } ) ;
42+ } ) ;
You can’t perform that action at this time.
0 commit comments