itube-specs 0.0.713 → 0.0.714

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "itube-specs",
3
3
  "type": "module",
4
- "version": "0.0.713",
4
+ "version": "0.0.714",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "./types/index.d.ts",
7
7
  "scripts": {
package/runtime/index.ts CHANGED
@@ -51,6 +51,8 @@ export * from './utils/server/server-api-helper';
51
51
  export * from './utils/converters/convert-date-to-timestamp';
52
52
  export * from './utils/get-month';
53
53
  export * from './utils/converters/convert-string';
54
+ export * from './utils/converters/convert-model-to-round-card';
55
+ export * from './utils/converters/convert-channel-to-round-card';
54
56
  export * from './utils/normalize-url';
55
57
  export * from './utils/check-device-width';
56
58
  export * from './utils/is-mobile-device';
@@ -0,0 +1,37 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { convertChannelToRoundCard } from './convert-channel-to-round-card';
3
+
4
+ describe('convertChannelToRoundCard', () => {
5
+ it('конвертирует канал в round card', () => {
6
+ const channel = {
7
+ guid: 'ch-1',
8
+ name: 'Channel Name',
9
+ url: '/channels/1',
10
+ videosCount: 50,
11
+ isNetwork: false,
12
+ updated: 0,
13
+ avatarUrl: 'https://img.com/avatar.jpg',
14
+ description: '',
15
+ };
16
+ const result = convertChannelToRoundCard(channel);
17
+ expect(result.title).toBe('Channel Name');
18
+ expect(result.primaryImageUrl).toBe('https://img.com/avatar.jpg');
19
+ expect(result.videosCount).toBe(50);
20
+ expect(result.link).toBe('/channels/channel-name');
21
+ });
22
+
23
+ it('slug с заглавными', () => {
24
+ const channel = {
25
+ guid: 'ch-2',
26
+ name: 'Big Studio',
27
+ url: '',
28
+ videosCount: 0,
29
+ isNetwork: false,
30
+ updated: 0,
31
+ avatarUrl: '',
32
+ description: '',
33
+ };
34
+ const result = convertChannelToRoundCard(channel);
35
+ expect(result.link).toBe('/channels/big-studio');
36
+ });
37
+ });
@@ -0,0 +1,11 @@
1
+ import type { IChannelCard, IRoundCard } from '../../../types';
2
+ import { convertString } from './convert-string';
3
+
4
+ export function convertChannelToRoundCard(channel: IChannelCard): IRoundCard {
5
+ return {
6
+ title: channel.name,
7
+ primaryImageUrl: channel.avatarUrl,
8
+ videosCount: channel.videosCount,
9
+ link: `/channels/${convertString().toSlug(channel.name)}`,
10
+ };
11
+ }
@@ -0,0 +1,59 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { convertModelToRoundCard } from './convert-model-to-round-card';
3
+
4
+ describe('convertModelToRoundCard', () => {
5
+ it('конвертирует модель в round card', () => {
6
+ const model = {
7
+ title: 'Model Name',
8
+ primaryImageUrl: 'https://img.com/primary.jpg',
9
+ thumbUrl: 'https://img.com/thumb.jpg',
10
+ videosCount: 10,
11
+ guid: 'm-1',
12
+ parameters: [],
13
+ };
14
+ const result = convertModelToRoundCard(model);
15
+ expect(result.title).toBe('Model Name');
16
+ expect(result.primaryImageUrl).toBe('https://img.com/primary.jpg');
17
+ expect(result.videosCount).toBe(10);
18
+ expect(result.link).toBe('/models/model-name');
19
+ });
20
+
21
+ it('без primaryImageUrl → использует thumbUrl', () => {
22
+ const model = {
23
+ title: 'Test',
24
+ primaryImageUrl: '',
25
+ thumbUrl: 'https://img.com/thumb.jpg',
26
+ videosCount: 5,
27
+ guid: 'm-2',
28
+ parameters: [],
29
+ };
30
+ const result = convertModelToRoundCard(model);
31
+ expect(result.primaryImageUrl).toBe('https://img.com/thumb.jpg');
32
+ });
33
+
34
+ it('без обоих url → пустая строка', () => {
35
+ const model = {
36
+ title: 'Test',
37
+ primaryImageUrl: '',
38
+ thumbUrl: '',
39
+ videosCount: 0,
40
+ guid: 'm-3',
41
+ parameters: [],
42
+ };
43
+ const result = convertModelToRoundCard(model);
44
+ expect(result.primaryImageUrl).toBe('');
45
+ });
46
+
47
+ it('slug с пробелами и заглавными', () => {
48
+ const model = {
49
+ title: 'Big Name Model',
50
+ primaryImageUrl: 'url',
51
+ thumbUrl: '',
52
+ videosCount: 0,
53
+ guid: 'm-4',
54
+ parameters: [],
55
+ };
56
+ const result = convertModelToRoundCard(model);
57
+ expect(result.link).toBe('/models/big-name-model');
58
+ });
59
+ });
@@ -0,0 +1,11 @@
1
+ import type { IModelCard, IRoundCard } from '../../../types';
2
+ import { convertString } from './convert-string';
3
+
4
+ export function convertModelToRoundCard(model: IModelCard): IRoundCard {
5
+ return {
6
+ title: model.title,
7
+ primaryImageUrl: model.primaryImageUrl || model.thumbUrl || '',
8
+ videosCount: model.videosCount,
9
+ link: `/models/${convertString().toSlug(model.title)}`,
10
+ };
11
+ }
package/types/index.d.ts CHANGED
@@ -66,3 +66,4 @@ export * from './playlist-short.d.ts';
66
66
  export * from './info-chips.d.ts';
67
67
  export * from './model-parameter.d.ts';
68
68
  export * from './grouped-parameter.d.ts';
69
+ export * from './round-card.d.ts';
@@ -0,0 +1,6 @@
1
+ export interface IRoundCard {
2
+ title: string
3
+ primaryImageUrl: string
4
+ videosCount: number
5
+ link: string
6
+ }