MCPcopy Create free account
hub / github.com/decaporg/decap-cms / TestBackend

Class TestBackend

packages/decap-cms-backend-test/src/implementation.ts:133–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133export default class TestBackend implements Implementation {
134 mediaFolder: string;
135 options: { initialWorkflowStatus?: string };
136
137 constructor(config: Config, options = {}) {
138 this.options = options;
139 this.mediaFolder = config.media_folder;
140 }
141
142 isGitBackend() {
143 return false;
144 }
145
146 status() {
147 return Promise.resolve({ auth: { status: true }, api: { status: true, statusPage: '' } });
148 }
149
150 authComponent() {
151 return AuthenticationPage;
152 }
153
154 restoreUser() {
155 return this.authenticate();
156 }
157
158 authenticate() {
159 return Promise.resolve() as unknown as Promise<User>;
160 }
161
162 logout() {
163 return null;
164 }
165
166 getToken() {
167 return Promise.resolve('');
168 }
169
170 traverseCursor(cursor: Cursor, action: string) {
171 const { folder, extension, index, pageCount, depth } = cursor.data!.toObject() as {
172 folder: string;
173 extension: string;
174 index: number;
175 pageCount: number;
176 depth: number;
177 };
178 const newIndex = (() => {
179 if (action === 'next') {
180 return (index as number) + 1;
181 }
182 if (action === 'prev') {
183 return (index as number) - 1;
184 }
185 if (action === 'first') {
186 return 0;
187 }
188 if (action === 'last') {
189 return pageCount;
190 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected