Repository navigation
Expand file tree
/
Copy pathcsv-loader.test.ts
More file actions
119 lines (114 loc) · 3.83 KB
/
Copy pathcsv-loader.test.ts
File metadata and controls
119 lines (114 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import { resolve } from "path";
import { CsvLoader } from "../../src/data/csv-loader";
describe("csv loader", () => {
it("should load movies", async done => {
const filePath = resolve(__dirname, "./movies.csv");
const movies = await CsvLoader.loadMovies(filePath);
expect(movies).toEqual([
{
imdbId: "tt0369610",
popularity: 32.985763,
budget: 150000000,
revenue: 1513528810,
originalTitle: "Jurassic World",
cast: [
"Chris Pratt",
"Bryce Dallas Howard",
"Irrfan Khan",
"Vincent D'Onofrio",
"Nick Robinson"
],
homepage: "http://www.jurassicworld.com/",
directors: ["Colin Trevorrow"],
tagline: "The park is open.",
keywords: [
"monster",
"dna",
"tyrannosaurus rex",
"velociraptor",
"island"
],
overview:
"Twenty-two years after the events of Jurassic Park, Isla Nublar now features a fully functioning dinosaur theme park, Jurassic World, as originally envisioned by John Hammond.",
runtime: 124,
genres: ["Action", "Adventure", "Science Fiction", "Thriller"],
productionCompanies: [
"Universal Studios",
"Amblin Entertainment",
"Legendary Pictures",
"Fuji Television Network",
"Dentsu"
],
releaseDate: "2015-06-09",
budgetAdjusted: 137999939.3,
revenueAdjusted: 1392445893
},
{
imdbId: "tt1392190",
popularity: 28.419936,
budget: 150000000,
revenue: 378436354,
originalTitle: "Mad Max: Fury Road",
cast: [
"Tom Hardy",
"Charlize Theron",
"Hugh Keays-Byrne",
"Nicholas Hoult",
"Josh Helman"
],
homepage: "http://www.madmaxmovie.com/",
directors: ["George Miller"],
tagline: "What a Lovely Day.",
keywords: [
"future",
"chase",
"post-apocalyptic",
"dystopia",
"australia"
],
overview:
"An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order. There's Max, a man of action and a man of few words, who seeks peace of mind following the loss of his wife and child in the aftermath of the chaos. And Furiosa, a woman of action and a woman who believes her path to survival may be achieved if she can make it across the desert back to her childhood homeland.",
runtime: 120,
genres: ["Action", "Adventure", "Science Fiction", "Thriller"],
productionCompanies: [
"Village Roadshow Pictures",
"Kennedy Miller Productions"
],
releaseDate: "2015-05-13",
budgetAdjusted: 137999939.3,
revenueAdjusted: 348161292.5
}
]);
done();
});
it("should load ratings", async done => {
const filePath = resolve(__dirname, "./ratings.csv");
const ratings = await CsvLoader.loadRatings(filePath);
expect(ratings).toEqual([
{
userId: 742,
imdbId: "tt0479143",
rating: 5,
time_created: "2015-03-09 22:52:36"
},
{
userId: 876,
imdbId: "tt0762114",
rating: 4.5,
time_created: "2015-03-09 22:53:21"
}
]);
done();
});
it("should filter out duplicated actors", async done => {
const filePath = resolve(__dirname, "./movies-duplicated-actors.csv");
const movie = (await CsvLoader.loadMovies(filePath))[0];
expect(movie.cast).toEqual([
"Matthew Lillard",
"Grey Griffin",
"Frank Welker",
"Mindy Cohn"
]);
done();
});
});