Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`adds a link when links object is empty 1`] = `
"
import { i } from '@instantdb/core';

const _schema = i.schema({
entities: {
todos: i.entity({
title: i.string(),
}),
users: i.entity({
email: i.string(),
}),
},
links: {
todoOwner: {
forward: {
on: 'todos',
has: 'one',
label: 'owner',
},
reverse: {
on: 'users',
has: 'many',
label: 'todos',
},
},
},
rooms: {},
});

export default _schema;
"
`;

exports[`drops constraints removed by server 1`] = `
"
import { i } from '@instantdb/core';

const _schema = i.schema({
entities: {
todos: i.entity({
title: i.string(),
done: i.boolean().optional(),
}),
},
links: {},
rooms: {},
});

export default _schema;
"
`;

exports[`handles quoted keys for entities, attrs, and links 1`] = `
"
import { i } from '@instantdb/core';

const _schema = i.schema({
entities: {
todos: i.entity({
title: i.string(),
}),
users: i.entity({
email: i.string(),
}),
'user-profiles': i.entity({
'display-name': i.string(),
'avatar-url': i.string(),
}),
},
links: {
'todo-owner': {
forward: {
on: 'todos',
has: 'one',
label: 'owner',
},
reverse: {
on: 'users',
has: 'many',
label: 'todos',
},
},
},
rooms: {},
});

export default _schema;
"
`;

exports[`inserts attrs into multi-line entities with indentation 1`] = `
"
import { i } from '@instantdb/core';

const _schema = i.schema({
entities: {
todos: i.entity({
title: i.string(),
done: i.boolean().optional(),
priority: i.number(),
}),
},
links: {},
rooms: {},
});

export default _schema;
"
`;

exports[`preserves type params across chained calls 1`] = `
"
import { i } from '@instantdb/core';
import { Label } from './types';

const _schema = i.schema({
entities: {
todos: i.entity({
title: i.string(),
status: i.string<'todo' | 'done'>().unique().indexed(),
labels: i.json<Label[]>(),
metadata: i.json(),
}),
users: i.entity({
email: i.string().unique(),
}),
},
links: {},
rooms: {},
});

export default _schema;
"
`;

exports[`removes a link with surrounding comments and commas 1`] = `
"
import { i } from '@instantdb/core';

const _schema = i.schema({
entities: {
todos: i.entity({
title: i.string(),
}),
users: i.entity({
email: i.string(),
}),
projects: i.entity({
name: i.string(),
}),
},
links: {
// owner link
/* project link */
projectTodos: {
forward: { on: 'projects', has: 'many', label: 'todos' },
reverse: { on: 'todos', has: 'one', label: 'project' },
},
},
rooms: {},
});

export default _schema;
"
`;

exports[`removes the last link cleanly 1`] = `
"
import { i } from '@instantdb/core';

const _schema = i.schema({
entities: {
todos: i.entity({
title: i.string(),
}),
users: i.entity({
email: i.string(),
}),
},
links: {},
rooms: {},
});

export default _schema;
"
`;

exports[`updates link details 1`] = `
"
import { i } from '@instantdb/core';

const _schema = i.schema({
entities: {
todos: i.entity({
title: i.string(),
}),
users: i.entity({
email: i.string(),
}),
},
links: {
todoOwner: {
forward: {
on: 'todos',
has: 'one',
label: 'owner',
required: true,
onDelete: 'cascade',
},
reverse: {
on: 'users',
has: 'many',
label: 'todos',
onDelete: 'cascade',
},
},
},
rooms: {},
});

export default _schema;
"
`;

exports[`updates single-line entity in place 1`] = `
"
import { i } from '@instantdb/core';

const _schema = i.schema({
entities: {
projects: i.entity({
name: i.string(),
status: i.string(),
}),
todos: i.entity({
title: i.string(),
}),
},
links: {},
rooms: {},
});

export default _schema;
"
`;
Loading
Loading