Skip to content

Commit

Permalink
test: move fakers to new test folder
Browse files Browse the repository at this point in the history
  • Loading branch information
treipatru committed Jul 15, 2024
1 parent 64f0532 commit 9bbda18
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/actions/movie/get-best-movie.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getBestMovieByDate } from '@/actions/movie/get-best-movie.js';
import { generateMovie } from '@/fakers/moviedb.js';
import { generateMovie } from '@/test/fakers/moviedb.js';

/**
* Get a new date with a random year but same month and day.
Expand Down
2 changes: 1 addition & 1 deletion src/actions/movie/get-movie-info.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
getMovieInfo,
getMovieOverview,
} from '@/actions/movie/get-movie-info.js';
import { generateMovie } from '@/fakers/moviedb.js';
import { generateMovie } from '@/test/fakers/moviedb.js';

describe('getMovieOverview', () => {
test('should return the overview if it is less than 350 characters', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/actions/post/has-posted-today.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { hasPostedToday } from '@/actions/post/has-posted-today.js';
import { generateStatus } from '@/fakers/mastodon.js';
import { generateStatus } from '@/test/fakers/mastodon.js';
import { sub } from 'date-fns';

test('should return true if last post is from less than 24h ago', () => {
Expand Down
13 changes: 12 additions & 1 deletion src/fakers/mastodon.ts → src/test/fakers/mastodon.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Status } from '@/types/mastodon.js';
import { MediaAttachment, Status } from '@/types/mastodon.js';
import { faker } from '@faker-js/faker';

function generateAccount(): Status['account'] {
Expand Down Expand Up @@ -59,3 +59,14 @@ export function generateStatus({
.arrayElement(['public', 'unlisted', 'private', 'direct']),
};
}

export function generateMediaAttachment(): MediaAttachment {
return {
description: faker.lorem.sentence(),
id: faker.number.int().toString(),
previewUrl: faker.image.url(),
textUrl: faker.internet.url(),
type: faker.helpers.arrayElement(['image', 'video']),
url: faker.image.url(),
};
}
File renamed without changes.

0 comments on commit 9bbda18

Please sign in to comment.