Files
pybricks-code/src/mpy/sagas.test.ts
T
9994e8f4b4 build(deps): bump jest and @types/jest (#1131)
* build(deps): bump jest and @types/jest

Bumps [jest](https://github.com/facebook/jest/tree/HEAD/packages/jest) and [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest). These dependencies needed to be updated together.

Updates `jest` from 28.1.3 to 29.0.3
- [Release notes](https://github.com/facebook/jest/releases)
- [Changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/jest/commits/v29.0.3/packages/jest)

Updates `@types/jest` from 28.1.8 to 29.0.1
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest)

---
updated-dependencies:
- dependency-name: jest
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: "@types/jest"
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* [dependabot skip] Fix yarn.lock

* update test snapshots for jest 29

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot-fix <dependabot-fix@example.com>
Co-authored-by: David Lechner <david@pybricks.com>
2022-09-13 17:06:24 +00:00

40 lines
1.2 KiB
TypeScript

// SPDX-License-Identifier: MIT
// Copyright (c) 2020-2022 The Pybricks Authors
import { AsyncSaga } from '../../test';
import { compile, didCompile, didFailToCompile } from './actions';
import mpy from './sagas';
test('compiler works', async () => {
const saga = new AsyncSaga(mpy);
saga.put(compile('print("hello!")', 6, []));
const action = await saga.take();
expect(didCompile.matches(action)).toBeTruthy();
const { data } = action as ReturnType<typeof didCompile>;
expect(data[0]).toBe('M'.charCodeAt(0));
expect(data[1]).toBe(6); // ABI version
expect(data[2]).toBe(0); // flags
expect(data[3]).toBe(31); // small int bits
});
test('compiler error works', async () => {
const saga = new AsyncSaga(mpy);
saga.put(compile('syntax error!', 6, []));
const action = await saga.take();
expect(didFailToCompile.matches(action)).toBeTruthy();
const { err } = action as ReturnType<typeof didFailToCompile>;
expect(err).toMatchInlineSnapshot(`
[
"Traceback (most recent call last):",
" File "main.py", line 1",
"SyntaxError: invalid syntax",
]
`);
await saga.end();
});