Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(image)!: rewrite module #1477

Merged
merged 34 commits into from
Dec 5, 2022
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f00826f
refactor(image)!: rewrite module
Shinigami92 Oct 22, 2022
a9cba32
feat(image): github avatars
Shinigami92 Oct 22, 2022
3408a97
refactor(image): revert deletions and deprecate them
Shinigami92 Oct 22, 2022
83b449f
chore(image): example of url with specific options
Shinigami92 Oct 22, 2022
1e8de87
refactor(image)!: only pass faker instance
Shinigami92 Oct 28, 2022
85eaea2
refactor(image)!: update JSDocs
Shinigami92 Oct 28, 2022
117dc85
refactor(image)!: update deprecation messages
Shinigami92 Oct 28, 2022
f107779
refactor(image)!: use snapshots
Shinigami92 Oct 28, 2022
d698473
refactor(image)!: support lorem specific options
Shinigami92 Oct 28, 2022
f0b35b0
refactor(image)!: add tests
Shinigami92 Oct 28, 2022
9eae691
refactor(image)!: fix JSDocs
Shinigami92 Oct 28, 2022
f3a51cd
Merge branch 'next' into 1350-rewrite-image-module
Shinigami92 Nov 11, 2022
ef5cb8d
refactor: change to new proposal
Shinigami92 Nov 11, 2022
7cf0f47
test: update test cases
Shinigami92 Nov 11, 2022
3e40eab
chore: update deprecation messages
Shinigami92 Nov 11, 2022
27f8797
feat: add urlPlaceholder
Shinigami92 Nov 11, 2022
2ff88a2
Merge branch 'next' into 1350-rewrite-image-module
Shinigami92 Nov 14, 2022
2e0aebe
refactor: rename
Shinigami92 Nov 14, 2022
78cb8b3
chore: add complex examples
Shinigami92 Nov 14, 2022
20b3414
test: add tests
Shinigami92 Nov 14, 2022
d93cd09
Merge branch 'next' into 1350-rewrite-image-module
Shinigami92 Nov 20, 2022
197a6bf
test: adjust text
Shinigami92 Nov 20, 2022
b0c8b66
refactor: generate correct links
Shinigami92 Nov 20, 2022
5110e36
Merge branch 'next' into 1350-rewrite-image-module
ST-DDT Nov 20, 2022
70f2e3d
Merge branch 'next' into 1350-rewrite-image-module
Shinigami92 Nov 21, 2022
783267a
Merge branch 'next' into 1350-rewrite-image-module
Shinigami92 Nov 22, 2022
6fbc57b
Merge branch 'next' into 1350-rewrite-image-module
Shinigami92 Nov 25, 2022
ea3a4d0
chore: use new module
Shinigami92 Nov 25, 2022
907d63f
Merge branch 'next' into 1350-rewrite-image-module
Shinigami92 Nov 25, 2022
455ec6b
chore: apply review suggestion
Shinigami92 Nov 26, 2022
7aca603
chore: apply review suggestion
Shinigami92 Nov 26, 2022
3952899
chore: format
Shinigami92 Nov 27, 2022
601ab29
Merge branch 'next' into 1350-rewrite-image-module
Shinigami92 Dec 2, 2022
ad2acb2
Merge branch 'next' into 1350-rewrite-image-module
ST-DDT Dec 3, 2022
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
Prev Previous commit
Next Next commit
refactor(image)!: add tests
Shinigami92 committed Nov 4, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit f0b35b090ef974e56e0fc5e60ef61838a55462e4
96 changes: 96 additions & 0 deletions test/__snapshots__/image.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,101 @@
// Vitest Snapshot v1

exports[`image > 42 > avatar > noArgs 1`] = `"https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/468.jpg"`;

exports[`image > 42 > avatar > with provider cloudflare-ipfs 1`] = `"https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/468.jpg"`;

exports[`image > 42 > avatar > with provider github 1`] = `"https://avatars.githubusercontent.com/u/37454"`;

exports[`image > 42 > url > noArgs 1`] = `"https://loremflickr.com/640/480?lock=37454"`;

exports[`image > 42 > url > with provider loremflickr 1`] = `"https://loremflickr.com/640/480?lock=37454"`;

exports[`image > 42 > url > with provider loremflickr and category 1`] = `"https://loremflickr.com/640/480/nature?lock=37454"`;

exports[`image > 42 > url > with provider loremflickr and custom height 1`] = `"https://loremflickr.com/640/128?lock=37454"`;

exports[`image > 42 > url > with provider loremflickr and custom width 1`] = `"https://loremflickr.com/128/480?lock=37454"`;

exports[`image > 42 > url > with provider loremflickr and custom width and custom height 1`] = `"https://loremflickr.com/128/128?lock=37454"`;

exports[`image > 42 > url > with provider picsum 1`] = `"https://picsum.photos/id/37454/640/480"`;

exports[`image > 42 > url > with provider picsum and blur=2 1`] = `"https://picsum.photos/id/37454/640/480?blur=2"`;

exports[`image > 42 > url > with provider picsum and custom height 1`] = `"https://picsum.photos/id/37454/640/128"`;

exports[`image > 42 > url > with provider picsum and custom width 1`] = `"https://picsum.photos/id/37454/128/480"`;

exports[`image > 42 > url > with provider picsum and custom width and custom height 1`] = `"https://picsum.photos/id/37454/128/128"`;

exports[`image > 42 > url > with provider picsum and grayscale 1`] = `"https://picsum.photos/id/37454/640/480?grayscale"`;

exports[`image > 42 > url > with provider picsum and grayscale and blur=2 1`] = `"https://picsum.photos/id/37454/640/480?grayscale&blur=2"`;

exports[`image > 1211 > avatar > noArgs 1`] = `"https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1160.jpg"`;

exports[`image > 1211 > avatar > with provider cloudflare-ipfs 1`] = `"https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1160.jpg"`;

exports[`image > 1211 > avatar > with provider github 1`] = `"https://avatars.githubusercontent.com/u/92852"`;

exports[`image > 1211 > url > noArgs 1`] = `"https://loremflickr.com/640/480?lock=92852"`;

exports[`image > 1211 > url > with provider loremflickr 1`] = `"https://loremflickr.com/640/480?lock=92852"`;

exports[`image > 1211 > url > with provider loremflickr and category 1`] = `"https://loremflickr.com/640/480/nature?lock=92852"`;

exports[`image > 1211 > url > with provider loremflickr and custom height 1`] = `"https://loremflickr.com/640/128?lock=92852"`;

exports[`image > 1211 > url > with provider loremflickr and custom width 1`] = `"https://loremflickr.com/128/480?lock=92852"`;

exports[`image > 1211 > url > with provider loremflickr and custom width and custom height 1`] = `"https://loremflickr.com/128/128?lock=92852"`;

exports[`image > 1211 > url > with provider picsum 1`] = `"https://picsum.photos/id/92852/640/480"`;

exports[`image > 1211 > url > with provider picsum and blur=2 1`] = `"https://picsum.photos/id/92852/640/480?blur=2"`;

exports[`image > 1211 > url > with provider picsum and custom height 1`] = `"https://picsum.photos/id/92852/640/128"`;

exports[`image > 1211 > url > with provider picsum and custom width 1`] = `"https://picsum.photos/id/92852/128/480"`;

exports[`image > 1211 > url > with provider picsum and custom width and custom height 1`] = `"https://picsum.photos/id/92852/128/128"`;

exports[`image > 1211 > url > with provider picsum and grayscale 1`] = `"https://picsum.photos/id/92852/640/480?grayscale"`;

exports[`image > 1211 > url > with provider picsum and grayscale and blur=2 1`] = `"https://picsum.photos/id/92852/640/480?grayscale&blur=2"`;

exports[`image > 1337 > avatar > noArgs 1`] = `"https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/327.jpg"`;

exports[`image > 1337 > avatar > with provider cloudflare-ipfs 1`] = `"https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/327.jpg"`;

exports[`image > 1337 > avatar > with provider github 1`] = `"https://avatars.githubusercontent.com/u/26202"`;

exports[`image > 1337 > url > noArgs 1`] = `"https://loremflickr.com/640/480?lock=26202"`;

exports[`image > 1337 > url > with provider loremflickr 1`] = `"https://loremflickr.com/640/480?lock=26202"`;

exports[`image > 1337 > url > with provider loremflickr and category 1`] = `"https://loremflickr.com/640/480/nature?lock=26202"`;

exports[`image > 1337 > url > with provider loremflickr and custom height 1`] = `"https://loremflickr.com/640/128?lock=26202"`;

exports[`image > 1337 > url > with provider loremflickr and custom width 1`] = `"https://loremflickr.com/128/480?lock=26202"`;

exports[`image > 1337 > url > with provider loremflickr and custom width and custom height 1`] = `"https://loremflickr.com/128/128?lock=26202"`;

exports[`image > 1337 > url > with provider picsum 1`] = `"https://picsum.photos/id/26202/640/480"`;

exports[`image > 1337 > url > with provider picsum and blur=2 1`] = `"https://picsum.photos/id/26202/640/480?blur=2"`;

exports[`image > 1337 > url > with provider picsum and custom height 1`] = `"https://picsum.photos/id/26202/640/128"`;

exports[`image > 1337 > url > with provider picsum and custom width 1`] = `"https://picsum.photos/id/26202/128/480"`;

exports[`image > 1337 > url > with provider picsum and custom width and custom height 1`] = `"https://picsum.photos/id/26202/128/128"`;

exports[`image > 1337 > url > with provider picsum and grayscale 1`] = `"https://picsum.photos/id/26202/640/480?grayscale"`;

exports[`image > 1337 > url > with provider picsum and grayscale and blur=2 1`] = `"https://picsum.photos/id/26202/640/480?grayscale&blur=2"`;

exports[`image > dataUri > should return a blank data 1`] = `"data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20baseProfile%3D%22full%22%20width%3D%22200%22%20height%3D%22300%22%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22grey%22%2F%3E%3Ctext%20x%3D%22100%22%20y%3D%22150%22%20font-size%3D%2220%22%20alignment-baseline%3D%22middle%22%20text-anchor%3D%22middle%22%20fill%3D%22white%22%3E200x300%3C%2Ftext%3E%3C%2Fsvg%3E"`;

exports[`image > dataUri > should return a custom background color data URI 1`] = `"data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20baseProfile%3D%22full%22%20width%3D%22200%22%20height%3D%22300%22%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22red%22%2F%3E%3Ctext%20x%3D%22100%22%20y%3D%22150%22%20font-size%3D%2220%22%20alignment-baseline%3D%22middle%22%20text-anchor%3D%22middle%22%20fill%3D%22white%22%3E200x300%3C%2Ftext%3E%3C%2Fsvg%3E"`;
83 changes: 83 additions & 0 deletions test/image.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,90 @@
import { describe, expect, it } from 'vitest';
import { faker } from '../src';
import { seededTests } from './support/seededRuns';

describe('image', () => {
seededTests(faker, 'image', (t) => {
t.describe('avatar', (t) => {
t.it('noArgs')
.it('with provider cloudflare-ipfs', {
provider: 'cloudflare-ipfs',
})
.it('with provider github', {
provider: 'github',
});
});

t.describe('url', (t) => {
t.it('noArgs')
.it('with provider loremflickr', {
provider: 'loremflickr',
})
.it('with provider loremflickr and custom width', {
provider: 'loremflickr',
width: 128,
})
.it('with provider loremflickr and custom height', {
provider: 'loremflickr',
height: 128,
})
.it('with provider loremflickr and custom width and custom height', {
provider: 'loremflickr',
width: 128,
height: 128,
})
.it('with provider loremflickr and category', {
provider: 'loremflickr',
category: 'nature',
})
.it('with provider picsum', {
provider: 'picsum',
})
.it('with provider picsum and custom width', {
provider: 'picsum',
width: 128,
})
.it('with provider picsum and custom height', {
provider: 'picsum',
height: 128,
})
.it('with provider picsum and custom width and custom height', {
provider: 'picsum',
width: 128,
height: 128,
})
.it('with provider picsum and grayscale', {
provider: 'picsum',
grayscale: true,
})
.it('with provider picsum and blur=2', {
provider: 'picsum',
blur: 2,
})
.it('with provider picsum and grayscale and blur=2', {
provider: 'picsum',
grayscale: true,
blur: 2,
});
});

t.skip('abstract');
t.skip('animals');
t.skip('business');
t.skip('cats');
t.skip('city');
t.skip('dataUri');
t.skip('fashion');
t.skip('food');
t.skip('image');
t.skip('imageUrl');
t.skip('nature');
t.skip('nightlife');
t.skip('people');
t.skip('sports');
t.skip('technics');
t.skip('transport');
});

describe('lorempicsum', () => {
describe('imageUrl()', () => {
it('should return a random image url from lorempixel', () => {