Skip to content

Commit

Permalink
fix(controller): broken test with define changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzofox3 committed Mar 8, 2024
1 parent 6fa85ee commit 941a3a8
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions packages/controllers/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@ import { define } from '@cofn/core';
import { nextTick } from './utils.js';

const debug = document.getElementById('debug');
const withCounter = (specFn) =>
async function zora_spec_fn(assert) {
const withCounterController = withController(({ state }) => {
state.count = 42;
return {
increment() {
state.count = state.count + 1;
},
};
});

define(
'test-counting-controller',
withCounterController(function* ({ $host, controller }) {
$host.addEventListener('click', controller.increment);
$host.loopCount = 0;
const withCounterController = withController(({ state }) => {
state.count = 42;
return {
increment() {
state.count = state.count + 1;
},
};
});

try {
while (true) {
const { state } = yield;
$host.textContent = 'state:' + state.count;
$host.loopCount += 1;
}
} finally {
$host.teardown = true;
}
}),
);
define(
'test-counting-controller',
withCounterController(function* ({ $host, controller }) {
$host.addEventListener('click', controller.increment);
$host.loopCount = 0;

try {
while (true) {
const { state } = yield;
$host.textContent = 'state:' + state.count;
$host.loopCount += 1;
}
} finally {
$host.teardown = true;
}
}),
);
const withCounter = (specFn) => {
return async function zora_spec_fn(assert) {
const el = document.createElement('test-counting-controller');
debug.appendChild(el);
return await specFn({ ...assert, el });
};
};

test('controller function get passed the routine dependencies along with the state', async ({
eq,
Expand Down

0 comments on commit 941a3a8

Please sign in to comment.