forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmocks.ts
More file actions
62 lines (57 loc) · 1.38 KB
/
mocks.ts
File metadata and controls
62 lines (57 loc) · 1.38 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
import { Module, Directory, Sandbox, User } from '../types';
export function noop(): void {
// No operation performed.
}
export function createModule(index: number = 0, params?: Module & any): Module {
return {
title: `test-module${index}`,
id: `longid-module${index}`,
shortid: `shortid-module${index}`,
isNotSynced: false,
code: "import test from 'koekje'",
directoryShortid: null,
...params,
};
}
export function createDirectory(
index: number = 0,
params?: Directory & any
): Directory {
return {
title: `test-dir${index}`,
id: `longid-dir${index}`,
shortid: `shortid-dir${index}`,
directoryShortid: null,
...params,
};
}
export function createUser(index: number = 0, params?: User & any): User {
return {
id: `test-user${index}`,
sandboxCount: index + 1,
givenLikeCount: index + 1,
avatarUrl: `https://avatar.nl/${index}.png`,
name: `user-${index}`,
username: `user-username-${index}`,
...params,
};
}
export function createSandbox(
index: number = 0,
params?: Sandbox & any
): Sandbox {
const id = `sandbox-id${index}`;
return {
title: `Test Sandbox${index}`,
id,
author: undefined,
currentModule: null,
dependencyBundle: {},
modules: [createModule()],
directories: [createDirectory()],
externalResources: [],
userLiked: false,
owned: false,
...params,
};
}