Skip to content

Commit

Permalink
[recents] Add recents view preference to user schema (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
wentsul authored Jan 2, 2024
1 parent 4262dab commit bee2485
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zeit/schemas",
"version": "2.34.0",
"version": "2.35.0",
"description": "All schemas used for validation that are shared between our projects",
"scripts": {
"test": "yarn run lint && best --verbose",
Expand Down
26 changes: 26 additions & 0 deletions test/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,32 @@ exports.test_favoritesViewPreference_number_invalid = () => {
assert.equal(isValid, false);
};

exports.test_recentsViewPreference_open_valid = () => {
assert(ajv.validate(User, { recentsViewPreference: 'open' }));
};

exports.test_recentsViewPreference_closed_valid = () => {
assert(ajv.validate(User, { recentsViewPreference: 'closed' }));
};

exports.test_recentsViewPreference_null_valid = () => {
assert(ajv.validate(User, { recentsViewPreference: null }));
};

exports.test_recentsViewPreference_invalid_value = () => {
const isValid = ajv.validate(User, {
recentsViewPreference: 'test'
});
assert.equal(isValid, false);
};

exports.test_recentsViewPreference_number_invalid = () => {
const isValid = ajv.validate(User, {
recentsViewPreference: 10
});
assert.equal(isValid, false);
};

exports.test_remoteCaching_valid = () => {
assert(ajv.validate(User, { remoteCaching: { enabled: true } }));
};
Expand Down
7 changes: 4 additions & 3 deletions user/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const ViewPreference = {
]
};

const FavoritesViewPreference = {
const ToggleViewPreference = {
oneOf: [
{
'enum': ['open', 'closed']
Expand Down Expand Up @@ -268,7 +268,8 @@ const User = {
scopeId: ScopeId,
gitNamespaceId: GitNamespaceId,
viewPreference: ViewPreference,
favoritesViewPreference: FavoritesViewPreference,
favoritesViewPreference: ToggleViewPreference,
recentsViewPreference: ToggleViewPreference,
remoteCaching: RemoteCaching,
dismissedToasts: DismissedToasts,
enablePreviewFeedback: EnablePreviewFeedback,
Expand All @@ -290,6 +291,6 @@ module.exports = {
ScopeId,
GitNamespaceId,
ViewPreference,
FavoritesViewPreference,
ToggleViewPreference,
DismissedToasts
};

0 comments on commit bee2485

Please sign in to comment.