dan.the.discloser
dan.the.discloser
DDeno
Created by dan.the.discloser on 5/4/2024 in #help
what's the best tool set to use for testing react components in Deno?
This is an example from jest document to test react with node Mainly i am wondering how to get the functionality of tree.props.onMouseEnter()
import renderer from 'react-test-renderer';
import Link from './Link';



it('changes the class when hovered', () => {
const component = renderer.create(
<Link page="http://www.facebook.com">Facebook</Link>,
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();

// manually trigger the callback
renderer.act(() => {
tree.props.onMouseEnter();
});
// re-rendering
tree = component.toJSON();
expect(tree).toMatchSnapshot();

// manually trigger the callback
renderer.act(() => {
tree.props.onMouseLeave();
});
// re-rendering
tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
import renderer from 'react-test-renderer';
import Link from './Link';



it('changes the class when hovered', () => {
const component = renderer.create(
<Link page="http://www.facebook.com">Facebook</Link>,
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();

// manually trigger the callback
renderer.act(() => {
tree.props.onMouseEnter();
});
// re-rendering
tree = component.toJSON();
expect(tree).toMatchSnapshot();

// manually trigger the callback
renderer.act(() => {
tree.props.onMouseLeave();
});
// re-rendering
tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
3 replies
DDeno
Created by dan.the.discloser on 3/21/2023 in #help
client side JS
thank you
11 replies
DDeno
Created by dan.the.discloser on 3/21/2023 in #help
client side JS
thank you. where can I find a good tutorial on fresh and/or ultra
11 replies
DDeno
Created by dan.the.discloser on 3/21/2023 in #help
client side JS
currently oak. I think I was using Ultra when I used to do this
11 replies
DDeno
Created by dan.the.discloser on 3/21/2023 in #help
client side JS
right now I have to have something like
<script type="module" src="/client.js"></script>
<script type="module" src="/client.js"></script>
or this
<script src="https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.14.0/Sortable.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.14.0/Sortable.min.js"></script>
in my index.html file. I don't remember needing such things a while back when I was last using deno.
11 replies
DDeno
Created by dan.the.discloser on 1/6/2023 in #help
using both nodejs & deno
I am not sure. Teacher will check out the assignment from GitHub, try to run it in their nodejs environment and insert comments or maybe other changes into the source code. I will do a checkout to see them. So, I figure I can lots of extra files that they can ignore, but I don't want to be having to change / change-back or having separate versions of files.
8 replies
DDeno
Created by dan.the.discloser on 1/6/2023 in #help
using both nodejs & deno
Thank you for the idea. It's a very different approach; not sure whether or not it is practical for my classwork. // Much appreciated
8 replies
DDeno
Created by dan.the.discloser on 11/25/2022 in #help
OR interfaces?
how would I say that I want it to be exactly one of the them (ie: to have exactly 2 elements in it)
6 replies
DDeno
Created by dan.the.discloser on 11/25/2022 in #help
deps.ts & importMap.json
thank you
4 replies
DDeno
Created by dan.the.discloser on 11/21/2022 in #help
drag and drop
❣️
5 replies
DDeno
Created by dan.the.discloser on 10/25/2022 in #help
piping for async sub process
Sorry to be stupid.
18 replies
DDeno
Created by dan.the.discloser on 10/25/2022 in #help
piping for async sub process
The problem was with my environment, the iterator works fine.
18 replies
DDeno
Created by dan.the.discloser on 10/25/2022 in #help
piping for async sub process
when I tried
async function handleAll() {
const outputStream = await proc.stdout.readable.pipeThrough(
new TextDecoderStream(),
);
for await (const firstOutput of outputStream) {
console.log(firstOutput);
}
}
async function handleAll() {
const outputStream = await proc.stdout.readable.pipeThrough(
new TextDecoderStream(),
);
for await (const firstOutput of outputStream) {
console.log(firstOutput);
}
}
it waited for the process to finish and then gives me all the reads rapidly rather tthan giving to me as they become available
18 replies
DDeno
Created by dan.the.discloser on 10/25/2022 in #help
piping for async sub process
the basics.
18 replies
DDeno
Created by dan.the.discloser on 10/25/2022 in #help
piping for async sub process
indeed there is more work to do with the results, but I am trying to understands.
18 replies
DDeno
Created by dan.the.discloser on 10/25/2022 in #help
piping for async sub process
thank you a, a "do while" was exactly what I was hoping for
18 replies
DDeno
Created by dan.the.discloser on 10/25/2022 in #help
piping for async sub process
Thank you! This is much less ugly! Is there also a way to make the control of the while loop less ugly?
async function handleAll() {
const outputStream = await proc.stdout.readable.pipeThrough(
new TextDecoderStream(),
);
const r = outputStream.getReader();
let firstOutput = { done: false };
while (!firstOutput.done) {
firstOutput = await r.read();
console.log(firstOutput);
}
return r;
}
async function handleAll() {
const outputStream = await proc.stdout.readable.pipeThrough(
new TextDecoderStream(),
);
const r = outputStream.getReader();
let firstOutput = { done: false };
while (!firstOutput.done) {
firstOutput = await r.read();
console.log(firstOutput);
}
return r;
}
18 replies
DDeno
Created by dan.the.discloser on 10/25/2022 in #help
piping for async sub process
Thank you -- i will try it
18 replies
DDeno
Created by dan.the.discloser on 10/25/2022 in #help
piping for async sub process
I read through the doc's and the sources (to the extent I can) and I just don't get it. Clearly what I am doig is not right. error: TS2339 [ERROR]: Property 'pipeThrough' does not exist on type 'Reader & Closer & { readable: ReadableStream<Uint8Array>; }'.
async function handleAll(){
const output = await proc.stdout.pipeThrough((new TextDecoderStream()))
console.dir(output)
}
async function handleAll(){
const output = await proc.stdout.pipeThrough((new TextDecoderStream()))
console.dir(output)
}
Can you point me at a simple example?
18 replies