-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
77 additions
and
24 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import useMovies from "@/composables/useMovie"; | ||
import { test, expect } from "vitest"; | ||
|
||
test("Composable should return all movies", async () => { | ||
const { movies, error, getAllMovies } = useMovies(); | ||
|
||
try{ | ||
await getAllMovies(); | ||
|
||
expect(movies.length).toBe(122); | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import axios from "axios"; | ||
|
||
export default class HttpService { | ||
static client = axios.create({ | ||
baseURL: "https://tame-erin-pike-toga.cyclic.app/", | ||
}); | ||
|
||
static async request(method: string, url: string) { | ||
const response = await this.client.request({ | ||
method, | ||
url, | ||
}); | ||
return response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import HttpService from "./httpService"; | ||
import type { Movie } from "@/types/MovieTypes"; | ||
|
||
export default class MovieService extends HttpService { | ||
static async getAll() { | ||
const response = await this.request("GET", "/movies"); | ||
return response.data; | ||
} | ||
|
||
static async getSingle(id: number) { | ||
const movies: Movie[] = await this.getAll(); | ||
|
||
return movies.find((movie: Movie) => movie.id == id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { formatGenres } from "../../formatGenres"; | ||
import { test, expect } from "vitest"; | ||
|
||
test("Function should return empty string", () => { | ||
expect(formatGenres([])).toBe(""); | ||
}); | ||
|
||
test("Function should return 'Action'", () => { | ||
expect(formatGenres(["Action"])).toBe("Action"); | ||
}); | ||
|
||
test("Function should return 'Action, Drama'", () => { | ||
expect(formatGenres(["Action", "Drama"])).toBe("Action, Drama"); | ||
}); | ||
|
||
test("Function should return 'Action, Drama, Comedy'", () => { | ||
expect(formatGenres(["Action", "Drama", "Comedy"])).toBe("Action, Drama, Comedy"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters