Skip to content

Commit

Permalink
test(schema): fix pt. 1
Browse files Browse the repository at this point in the history
  • Loading branch information
RealShadowNova committed Apr 27, 2024
1 parent 53e1210 commit aa3594a
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions packages/schema/tests/lib/SchemaMiddleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,42 +323,42 @@ describe('SchemaMiddleware', () => {
path: [],
value: { str: 'test', num: 1, arr: [] }
});
});

test('GIVEN valid data THEN passes', async () => {
await store.provider[Method.Set]({ method: Method.Set, errors: [], key: 'key', path: [], value: { str: 'test', num: 1, arr: [] } });
test('GIVEN valid data THEN passes', async () => {
await store.provider[Method.Set]({ method: Method.Set, errors: [], key: 'key', path: [], value: { str: 'test', num: 1, arr: [] } });

await expect(schema[Method.Set]({ method: Method.Set, errors: [], key: 'key', path: ['str'], value: 'test' })).resolves.toStrictEqual({
method: Method.Set,
errors: [],
key: 'key',
path: ['str'],
value: 'test'
});
await expect(schema[Method.Set]({ method: Method.Set, errors: [], key: 'key', path: ['str'], value: 'test' })).resolves.toStrictEqual({
method: Method.Set,
errors: [],
key: 'key',
path: ['str'],
value: 'test'
});
});

test('GIVEN invalid data THEN throws', async () => {
await store.provider[Method.Set]({ method: Method.Set, errors: [], key: 'key', path: [], value: { str: 1, num: 'test', arr: [] } });
test('GIVEN invalid data THEN throws', async () => {
await store.provider[Method.Set]({ method: Method.Set, errors: [], key: 'key', path: [], value: { str: 1, num: 'test', arr: [] } });

const payload = await schema[Method.Set]({ method: Method.Set, errors: [], key: 'key', path: ['str'], value: 'test' });
const { method, key, path, errors } = payload;
const { context } = errors[0];
const payload = await schema[Method.Set]({ method: Method.Set, errors: [], key: 'key', path: ['str'], value: 'test' });
const { method, key, path, errors } = payload;
const { context } = errors[0];

expect(method).toBe(Method.Set);
expect(key).toBe('key');
expect(path).toStrictEqual(['str']);
expect(context.shapeshiftError).toBeInstanceOf(CombinedPropertyError);
});
expect(method).toBe(Method.Set);
expect(key).toBe('key');
expect(path).toStrictEqual(['str']);
expect(context.shapeshiftError).toBeInstanceOf(CombinedPropertyError);
});

test('GIVEN invalid value THEN throws', async () => {
const payload = await schema[Method.Set]({ method: Method.Set, errors: [], key: 'key', path: [], value: { str: 1, num: 'test', arr: [] } });
const { method, key, path, errors } = payload;
const { context } = errors[0];
test('GIVEN invalid value THEN throws', async () => {
const payload = await schema[Method.Set]({ method: Method.Set, errors: [], key: 'key', path: [], value: { str: 1, num: 'test', arr: [] } });
const { method, key, path, errors } = payload;
const { context } = errors[0];

Check failure on line 356 in packages/schema/tests/lib/SchemaMiddleware.test.ts

View workflow job for this annotation

GitHub Actions / Unit Tests

packages/schema/tests/lib/SchemaMiddleware.test.ts > SchemaMiddleware > can manipulate provider data > set > GIVEN invalid value THEN throws

TypeError: Cannot destructure property 'context' of 'errors[0]' as it is undefined. ❯ packages/schema/tests/lib/SchemaMiddleware.test.ts:356:17

expect(method).toBe(Method.Set);
expect(key).toBe('key');
expect(path).toStrictEqual([]);
expect(context.shapeshiftError).toBeInstanceOf(CombinedPropertyError);
});
expect(method).toBe(Method.Set);
expect(key).toBe('key');
expect(path).toStrictEqual([]);
expect(context.shapeshiftError).toBeInstanceOf(CombinedPropertyError);
});

describe(Method.SetMany, () => {
Expand Down

0 comments on commit aa3594a

Please sign in to comment.