Skip to content

Commit

Permalink
feat(engine): 馃弰鈥嶁檪锔廍ngine tests are passing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gervwyk committed May 28, 2022
1 parent 92182a2 commit d737e1c
Show file tree
Hide file tree
Showing 31 changed files with 433 additions and 435 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -52,7 +52,7 @@
"start:server:next-dev:docs": "yarn start:cli:build:docs && yarn && yarn workspace @lowdefy/server dev",
"start:server-dev:next-dev:app": "yarn workspace lowdefy start build --config-directory ../../app --server-directory ../server-dev --output-directory ../ && yarn workspace @lowdefy/server-dev next dev",
"test": "lerna run test",
"test:ci": "yarn test --ignore='@lowdefy/engine' --ignore='@lowdefy/format' --ignore='@lowdefy/blocks-*' --ignore='@lowdefy/plugin-aws'"
"test:ci": "yarn test --ignore='@lowdefy/format' --ignore='@lowdefy/blocks-*' --ignore='@lowdefy/plugin-aws'"
},
"devDependencies": {
"@yarnpkg/pnpify": "3.1.1-rc.13",
Expand Down
25 changes: 6 additions & 19 deletions packages/engine/src/actions/createCallMethod.test.js
Expand Up @@ -17,20 +17,7 @@ import { jest } from '@jest/globals';

import testContext from '../../test/testContext.js';

const lowdefy = {
_internal: {
actions: {
CallMethod: ({ methods: { callMethod }, params }) => {
return callMethod(params);
},
},
blockComponents: {
Button: { meta: { category: 'display' } },
List: { meta: { category: 'list' } },
TextInput: { meta: { category: 'input' } },
},
},
};
const lowdefy = {};

const RealDate = Date;
const mockDate = jest.fn(() => ({ date: 0 }));
Expand Down Expand Up @@ -91,7 +78,7 @@ test('CallMethod with no args, synchronous method', async () => {
textInput.registerMethod('blockMethod', blockMethod);
const res = await button.triggerEvent({ name: 'onClick' });
expect(res).toEqual({
id: 'button',
blockId: 'button',
bounced: false,
event: undefined,
eventName: 'onClick',
Expand Down Expand Up @@ -166,7 +153,7 @@ test('CallMethod method return a promise', async () => {
textInput.registerMethod('blockMethod', blockMethod);
const res = await button.triggerEvent({ name: 'onClick' });
expect(res).toEqual({
id: 'button',
blockId: 'button',
bounced: false,
event: undefined,
eventName: 'onClick',
Expand Down Expand Up @@ -229,7 +216,7 @@ test('CallMethod with args not an array', async () => {
textInput.registerMethod('blockMethod', blockMethod);
const res = await button.triggerEvent({ name: 'onClick' });
expect(res).toEqual({
id: 'button',
blockId: 'button',
bounced: false,
event: undefined,
eventName: 'onClick',
Expand All @@ -238,7 +225,7 @@ test('CallMethod with args not an array', async () => {
id: 'a',
params: {
args: 'arg',
blockId: 'block:root:textInput:0',
blockId: 'textInput',
method: 'blockMethod',
},
type: 'CallMethod',
Expand Down Expand Up @@ -505,7 +492,7 @@ test('CallMethod with method does not exist', async () => {
action: {
id: 'a',
params: {
blockId: 'block:root:textInput:0',
blockId: 'textInput',
method: 'no-method',
},
type: 'CallMethod',
Expand Down
3 changes: 0 additions & 3 deletions packages/engine/src/actions/createDisplayMessage.test.js
Expand Up @@ -30,9 +30,6 @@ const lowdefy = {
});
},
},
blockComponents: {
Button: { meta: { category: 'display' } },
},
displayMessage: mockMessage,
},
};
Expand Down
3 changes: 0 additions & 3 deletions packages/engine/src/actions/createGetActions.test.js
Expand Up @@ -25,9 +25,6 @@ const lowdefy = {
},
Custom: () => 'response',
},
blockComponents: {
Button: { meta: { category: 'display' } },
},
},
};

Expand Down
3 changes: 0 additions & 3 deletions packages/engine/src/actions/createGetBlockId.test.js
Expand Up @@ -24,9 +24,6 @@ const lowdefy = {
return getBlockId(params);
},
},
blockComponents: {
Button: { meta: { category: 'display' } },
},
},
};

Expand Down
3 changes: 0 additions & 3 deletions packages/engine/src/actions/createGetEvent.test.js
Expand Up @@ -24,9 +24,6 @@ const lowdefy = {
return getEvent(params);
},
},
blockComponents: {
Button: { meta: { category: 'display' } },
},
},
};

Expand Down
5 changes: 1 addition & 4 deletions packages/engine/src/actions/createGetGlobal.test.js
Expand Up @@ -24,9 +24,6 @@ const lowdefy = {
return getGlobal(params);
},
},
blockComponents: {
Button: { meta: { category: 'display' } },
},
},
lowdefyGlobal: {
some: 'data',
Expand All @@ -52,7 +49,7 @@ afterAll(() => {
test('getGlobal params is true', async () => {
const pageConfig = {
id: 'root',
tyoe: 'Box',
type: 'Box',
blocks: [
{
id: 'button',
Expand Down
5 changes: 1 addition & 4 deletions packages/engine/src/actions/createGetInput.test.js
Expand Up @@ -24,12 +24,9 @@ const lowdefy = {
return getInput(params);
},
},
blockComponents: {
Button: { meta: { category: 'display' } },
},
},
inputs: {
test: { some: 'data' },
'page:root': { some: 'data' },
},
};

Expand Down
3 changes: 0 additions & 3 deletions packages/engine/src/actions/createGetPageId.test.js
Expand Up @@ -24,9 +24,6 @@ const lowdefy = {
return getPageId(params);
},
},
blockComponents: {
Button: { meta: { category: 'display' } },
},
},
};

Expand Down
27 changes: 14 additions & 13 deletions packages/engine/src/actions/createGetRequestDetails.test.js
Expand Up @@ -43,12 +43,6 @@ const lowdefy = {
Action: ({ methods: { getRequestDetails }, params }) => {
return getRequestDetails(params);
},
Request: ({ methods: { request }, params }) => {
return request(params);
},
},
blockComponents: {
Button: { meta: { category: 'display' } },
},
callRequest: mockCallRequest,
},
Expand Down Expand Up @@ -81,7 +75,8 @@ test('getRequestDetails params is true', async () => {
type: 'Box',
requests: [
{
requestId: 'req_one',
id: 'req_one',
type: 'Fetch',
},
],
blocks: [
Expand Down Expand Up @@ -142,7 +137,8 @@ test('getRequestDetails params is req_one', async () => {
type: 'Box',
requests: [
{
requestId: 'req_one',
id: 'req_one',
type: 'Fetch',
},
],
blocks: [
Expand Down Expand Up @@ -201,7 +197,8 @@ test('getRequestDetails params is none', async () => {
type: 'Box',
requests: [
{
requestId: 'req_one',
id: 'req_one',
type: 'Fetch',
},
],
blocks: [
Expand Down Expand Up @@ -267,7 +264,8 @@ test('getRequestDetails params.key is null', async () => {
type: 'Box',
requests: [
{
requestId: 'req_one',
id: 'req_one',
type: 'Fetch',
},
],
blocks: [
Expand Down Expand Up @@ -325,7 +323,8 @@ test('getRequestDetails params.all is true', async () => {
type: 'Box',
requests: [
{
requestId: 'req_one',
id: 'req_one',
type: 'Fetch',
},
],
blocks: [
Expand Down Expand Up @@ -388,7 +387,8 @@ test('getRequestDetails params.key is not string or int', async () => {
type: 'Box',
requests: [
{
requestId: 'req_one',
id: 'req_one',
type: 'Fetch',
},
],
blocks: [
Expand Down Expand Up @@ -463,7 +463,8 @@ test('getRequestDetails params.key is req_one', async () => {
type: 'Box',
requests: [
{
requestId: 'req_one',
id: 'req_one',
type: 'Fetch',
},
],
blocks: [
Expand Down
5 changes: 1 addition & 4 deletions packages/engine/src/actions/createGetState.test.js
Expand Up @@ -24,9 +24,6 @@ const lowdefy = {
return getState(params);
},
},
blockComponents: {
Button: { meta: { category: 'display' } },
},
},
};

Expand Down Expand Up @@ -55,7 +52,7 @@ test('getState params is true', async () => {
{
id: 'initState',
type: 'SetState',
params: { textInput: 'init' },
params: { some: 'data' },
},
],
},
Expand Down
3 changes: 0 additions & 3 deletions packages/engine/src/actions/createGetUrlQuery.test.js
Expand Up @@ -24,9 +24,6 @@ const lowdefy = {
return getUrlQuery(params);
},
},
blockComponents: {
Button: { meta: { category: 'display' } },
},
},
urlQuery: {
some: 'data',
Expand Down
3 changes: 0 additions & 3 deletions packages/engine/src/actions/createGetUser.test.js
Expand Up @@ -24,9 +24,6 @@ const lowdefy = {
return getUser(params);
},
},
blockComponents: {
Button: { meta: { category: 'display' } },
},
},
user: {
some: 'data',
Expand Down
5 changes: 0 additions & 5 deletions packages/engine/src/actions/createLink.test.js
Expand Up @@ -34,11 +34,6 @@ const lowdefy = {
}
},
},
blockComponents: {
Button: { meta: { category: 'display' } },
List: { meta: { category: 'list' } },
TextInput: { meta: { category: 'input' } },
},
link: jest.fn(),
},
};
Expand Down
3 changes: 0 additions & 3 deletions packages/engine/src/actions/createLogin.test.js
Expand Up @@ -24,9 +24,6 @@ const lowdefy = {
return login(params);
},
},
blockComponents: {
Button: { meta: { category: 'display' } },
},
auth: {
login: jest.fn(),
},
Expand Down
3 changes: 0 additions & 3 deletions packages/engine/src/actions/createLogout.test.js
Expand Up @@ -24,9 +24,6 @@ const lowdefy = {
return logout();
},
},
blockComponents: {
Button: { meta: { category: 'display' } },
},
auth: {
logout: jest.fn(),
},
Expand Down
27 changes: 16 additions & 11 deletions packages/engine/src/actions/createRequest.test.js
Expand Up @@ -50,9 +50,6 @@ const lowdefy = {
return request(params);
},
},
blockComponents: {
Button: { meta: { category: 'display' } },
},
callRequest: mockCallRequest,
},
};
Expand Down Expand Up @@ -84,7 +81,8 @@ test('Request call one request', async () => {
type: 'Box',
requests: [
{
requestId: 'req_one',
id: 'req_one',
type: 'Fetch',
},
],
blocks: [
Expand Down Expand Up @@ -133,10 +131,12 @@ test('Request call all requests', async () => {
type: 'Box',
requests: [
{
requestId: 'req_one',
id: 'req_one',
type: 'Fetch',
},
{
requestId: 'req_two',
id: 'req_two',
type: 'Fetch',
},
],
blocks: [
Expand Down Expand Up @@ -204,10 +204,12 @@ test('Request call array of requests', async () => {
type: 'Box',
requests: [
{
requestId: 'req_one',
id: 'req_one',
type: 'Fetch',
},
{
requestId: 'req_two',
id: 'req_two',
type: 'Fetch',
},
],
blocks: [
Expand Down Expand Up @@ -275,10 +277,12 @@ test('Request pass if params are none', async () => {
type: 'Box',
requests: [
{
requestId: 'req_one',
id: 'req_one',
type: 'Fetch',
},
{
requestId: 'req_two',
id: 'req_two',
type: 'Fetch',
},
],
blocks: [
Expand Down Expand Up @@ -306,7 +310,8 @@ test('Request call request error', async () => {
type: 'Box',
requests: [
{
requestId: 'req_error',
id: 'req_error',
type: 'Fetch',
},
],
blocks: [
Expand Down
1 change: 0 additions & 1 deletion packages/engine/src/actions/createReset.js
Expand Up @@ -22,7 +22,6 @@ function createReset({ context }) {
context._internal.RootBlocks.reset(
serializer.deserializeFromString(context._internal.State.frozenState)
);
context._internal.update();
};
}

Expand Down

0 comments on commit d737e1c

Please sign in to comment.