Skip to content

Commit 3399e36

Browse files
committed
chore: 🤖 update test and add todo
1 parent 37fa5a0 commit 3399e36

File tree

3 files changed

+36
-75
lines changed

3 files changed

+36
-75
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@
115115
"upgrade:interactive": "npx npm-check-updates@16.14 --interactive"
116116
},
117117
"peerDependencies": {
118-
"rxjs": "7",
119-
"tslib": "2",
120118
"@jsonjoy.com/base64": "^1.1.2",
121119
"@jsonjoy.com/json-pack": "^1.0.4",
122-
"@jsonjoy.com/util": "^1.3.0"
120+
"@jsonjoy.com/util": "^1.3.0",
121+
"rxjs": "7",
122+
"tslib": "2"
123123
},
124124
"peerDependenciesMeta": {
125125
"rxjs": {

src/json-crdt/log/codec/LogDecoder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export class LogDecoder {
107107
const start = (): Model => {
108108
if (!history || !startSerialized) {
109109
// TODO: Handle case where new model should be started with server clock: `return Model.withServerClock()`.
110+
// TODO: Handle case where model has to be started with extensions...
110111
return Model.withLogicalClock(SESSION.GLOBAL);
111112
}
112113
return this.deserializeModel(startSerialized);

src/json-type/type/__tests__/TypeBuilder.spec.ts

Lines changed: 32 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -114,36 +114,18 @@ describe('validateSchema()', () => {
114114
format: 'i32',
115115
};
116116
expect(t.import(schema as any).validateSchema()).toBeUndefined();
117-
expect(() => t.import({...schema, description: 123} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
118-
`"INVALID_DESCRIPTION"`,
119-
);
120-
expect(() => t.import({...schema, title: 123} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
121-
`"INVALID_TITLE"`,
122-
);
123-
expect(() => t.import({...schema, intro: null} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
124-
`"INVALID_INTRO"`,
125-
);
126-
expect(() => t.import({...schema, gt: null} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
127-
`"GT_TYPE"`,
128-
);
129-
expect(() => t.import({...schema, lt: null} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
130-
`"LT_TYPE"`,
131-
);
132-
expect(() => t.import({...schema, gte: '334'} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
133-
`"GTE_TYPE"`,
134-
);
135-
expect(() => t.import({...schema, lte: '334'} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
136-
`"LTE_TYPE"`,
137-
);
138-
expect(() => t.import({...schema, lt: 1, gt: 2} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
139-
`"GT_LT"`,
140-
);
141-
expect(() => t.import({...schema, format: 'int'} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
142-
`"FORMAT_INVALID"`,
143-
);
144-
expect(() => t.import({...schema, validator: 123} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
145-
`"INVALID_VALIDATOR"`,
117+
expect(() => t.import({...schema, description: 123} as any).validateSchema()).toThrow(
118+
new Error('INVALID_DESCRIPTION'),
146119
);
120+
expect(() => t.import({...schema, title: 123} as any).validateSchema()).toThrow(new Error('INVALID_TITLE'));
121+
expect(() => t.import({...schema, intro: null} as any).validateSchema()).toThrow(new Error('INVALID_INTRO'));
122+
expect(() => t.import({...schema, gt: null} as any).validateSchema()).toThrow(new Error('GT_TYPE'));
123+
expect(() => t.import({...schema, lt: null} as any).validateSchema()).toThrow(new Error('LT_TYPE'));
124+
expect(() => t.import({...schema, gte: '334'} as any).validateSchema()).toThrow(new Error('GTE_TYPE'));
125+
expect(() => t.import({...schema, lte: '334'} as any).validateSchema()).toThrow(new Error('LTE_TYPE'));
126+
expect(() => t.import({...schema, lt: 1, gt: 2} as any).validateSchema()).toThrow(new Error('GT_LT'));
127+
expect(() => t.import({...schema, format: 'int'} as any).validateSchema()).toThrow(new Error('FORMAT_INVALID'));
128+
expect(() => t.import({...schema, validator: 123} as any).validateSchema()).toThrow(new Error('INVALID_VALIDATOR'));
147129
});
148130

149131
test('can validate a string schema', () => {
@@ -152,42 +134,20 @@ describe('validateSchema()', () => {
152134
description: 'A string',
153135
};
154136
expect(t.import(schema as any).validateSchema()).toBeUndefined();
155-
expect(() => t.import({...schema, description: 123} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
156-
`"INVALID_DESCRIPTION"`,
157-
);
158-
expect(() => t.import({...schema, title: 123} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
159-
`"INVALID_TITLE"`,
160-
);
161-
expect(() => t.import({...schema, intro: null} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
162-
`"INVALID_INTRO"`,
163-
);
164-
expect(() => t.import({...schema, min: null} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
165-
`"MIN_TYPE"`,
166-
);
167-
expect(() => t.import({...schema, max: 'asdf'} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
168-
`"MAX_TYPE"`,
169-
);
170-
expect(() => t.import({...schema, min: -1} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
171-
`"MIN_NEGATIVE"`,
172-
);
173-
expect(() => t.import({...schema, max: -1} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
174-
`"MAX_NEGATIVE"`,
175-
);
176-
expect(() => t.import({...schema, max: 0.5} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
177-
`"MAX_DECIMAL"`,
178-
);
179-
expect(() => t.import({...schema, min: 1.2} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
180-
`"MIN_DECIMAL"`,
181-
);
182-
expect(() => t.import({...schema, min: 5, max: 3} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
183-
`"MIN_MAX"`,
184-
);
185-
expect(() => t.import({...schema, ascii: 123} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
186-
`"ASCII"`,
187-
);
188-
expect(() => t.import({...schema, ascii: 'bytes'} as any).validateSchema()).toThrowErrorMatchingInlineSnapshot(
189-
`"ASCII"`,
190-
);
137+
expect(() => t.import({...schema, description: 123} as any).validateSchema()).toThrow(
138+
new Error('INVALID_DESCRIPTION'),
139+
);
140+
expect(() => t.import({...schema, title: 123} as any).validateSchema()).toThrow(new Error('INVALID_TITLE'));
141+
expect(() => t.import({...schema, intro: null} as any).validateSchema()).toThrow(new Error('INVALID_INTRO'));
142+
expect(() => t.import({...schema, min: null} as any).validateSchema()).toThrow(new Error('MIN_TYPE'));
143+
expect(() => t.import({...schema, max: 'asdf'} as any).validateSchema()).toThrow(new Error('MAX_TYPE'));
144+
expect(() => t.import({...schema, min: -1} as any).validateSchema()).toThrow(new Error('MIN_NEGATIVE'));
145+
expect(() => t.import({...schema, max: -1} as any).validateSchema()).toThrow(new Error('MAX_NEGATIVE'));
146+
expect(() => t.import({...schema, max: 0.5} as any).validateSchema()).toThrow(new Error('MAX_DECIMAL'));
147+
expect(() => t.import({...schema, min: 1.2} as any).validateSchema()).toThrow(new Error('MIN_DECIMAL'));
148+
expect(() => t.import({...schema, min: 5, max: 3} as any).validateSchema()).toThrow(new Error('MIN_MAX'));
149+
expect(() => t.import({...schema, ascii: 123} as any).validateSchema()).toThrow(new Error('ASCII'));
150+
expect(() => t.import({...schema, ascii: 'bytes'} as any).validateSchema()).toThrow(new Error('ASCII'));
191151
});
192152

193153
test('validates an arbitrary self-constructed object', () => {
@@ -205,7 +165,7 @@ describe('validateSchema()', () => {
205165
description: 'An array',
206166
type: {kind: 'str', ascii: 'bytes'},
207167
});
208-
expect(() => type.validateSchema()).toThrowErrorMatchingInlineSnapshot(`"ASCII"`);
168+
expect(() => type.validateSchema()).toThrow(new Error('ASCII'));
209169
});
210170

211171
test('validates array elements', () => {
@@ -214,7 +174,7 @@ describe('validateSchema()', () => {
214174
description: 'An array',
215175
type: {kind: 'str', ascii: 'bytes'},
216176
});
217-
expect(() => type.validateSchema()).toThrowErrorMatchingInlineSnapshot(`"ASCII"`);
177+
expect(() => type.validateSchema()).toThrow(new Error('ASCII'));
218178
});
219179

220180
test('validates object', () => {
@@ -224,7 +184,7 @@ describe('validateSchema()', () => {
224184
fields: [],
225185
unknownFields: 123 as any,
226186
});
227-
expect(() => type.validateSchema()).toThrowErrorMatchingInlineSnapshot(`"UNKNOWN_FIELDS_TYPE"`);
187+
expect(() => type.validateSchema()).toThrow(new Error('UNKNOWN_FIELDS_TYPE'));
228188
});
229189

230190
test('validates object fields', () => {
@@ -233,7 +193,7 @@ describe('validateSchema()', () => {
233193
description: 'An object',
234194
fields: [{kind: 'field', key: 'id', type: {kind: 'str', ascii: 'bytes'} as any}],
235195
});
236-
expect(() => type.validateSchema()).toThrowErrorMatchingInlineSnapshot(`"ASCII"`);
196+
expect(() => type.validateSchema()).toThrow(new Error('ASCII'));
237197
});
238198

239199
test('validates object fields - 2', () => {
@@ -242,14 +202,14 @@ describe('validateSchema()', () => {
242202
description: 'An object',
243203
fields: [{kind: 'field', key: 'id', optional: 123, type: {kind: 'str'}} as any],
244204
});
245-
expect(() => type.validateSchema()).toThrowErrorMatchingInlineSnapshot(`"OPTIONAL_TYPE"`);
205+
expect(() => type.validateSchema()).toThrow(new Error('OPTIONAL_TYPE'));
246206
});
247207

248208
test('validates ref', () => {
249209
const type = t.import({
250210
kind: 'ref',
251211
} as any);
252-
expect(() => type.validateSchema()).toThrowErrorMatchingInlineSnapshot(`"REF_TYPE"`);
212+
expect(() => type.validateSchema()).toThrow(new Error('REF_TYPE'));
253213
});
254214

255215
test('validates or', () => {
@@ -258,6 +218,6 @@ describe('validateSchema()', () => {
258218
types: [{kind: 'str', ascii: '123'} as any],
259219
discriminator: ['!', 0],
260220
});
261-
expect(() => type.validateSchema()).toThrowErrorMatchingInlineSnapshot(`"ASCII"`);
221+
expect(() => type.validateSchema()).toThrow(new Error('ASCII'));
262222
});
263223
});

0 commit comments

Comments
 (0)