This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { useSearchParams } from "next/navigation"; | |
import type { PropsWithChildren } from "react"; | |
import { z } from "zod"; | |
const MAIN_PAGE = "main"; | |
const VIDEOS_PAGE = "videos"; | |
const pageDefinitions = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { z } from 'zod' | |
const MAIN_PAGE = 'main' | |
const VIDEOS_PAGE = 'videos' | |
const pages = [MAIN_PAGE, VIDEOS_PAGE] as const | |
type Page = typeof pages[number] | |
const pageDefinitions = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { defineComponent, ref, watchEffect } from 'vue'; | |
export const Counter = defineComponent({ | |
props: ['limit', 'onLimit'], | |
setup(props) { | |
const count = ref(0); | |
const handler = () => count.value++; | |
watchEffect( | |
() => (count.value >= props.limit) ? props.onLimit() : null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect } from 'react'; | |
export const Counter = ({ limit, onLimit }) => { | |
const [count, setCount] = useState(0); | |
const handler = () => setCount(count + 1); | |
useEffect( | |
() => (count >= limit) ? onLimit() : null, | |
[count] | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('New todo', () => { | |
it('it should change info', () => { | |
cy.visit('/'); | |
cy.contains('.info', 'Click to modify'); | |
cy.get('button').click(); | |
cy.contains('.info', 'Modified by click'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('should set info coming from endpoint', async () => { | |
const commit = jest.fn(); | |
jest.spyOn(axios, 'post').mockImplementation(() => ({ | |
body: 'Modified by post' | |
})); | |
const { store, onModify } = createStore(); | |
let info; | |
store.subscribe(value => info = value); | |
await onModify('Modified by click'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return { | |
store, | |
async onModify(info) { | |
const response = await axios.post('https://example.com/api', { info }); | |
store.update(() => response.body); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
transform: { | |
'^.+\\.js$': 'babel-jest', | |
'^.+\\.svelte$': 'svelte-jester' | |
}, | |
transformIgnorePatterns: [ | |
"node_modules/(?!(svelte-routing|svelte-spa-router)/)" | |
] | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { render } from '@testing-library/svelte'; | |
import Routing from './routing.svelte'; | |
describe('Routing', () => { | |
it('should render routing', () => { | |
const { getByTestId } = render(Routing); | |
const element = getByTestId('info'); | |
expect(element).toHaveTextContent('Click to modify'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { Router, Route } from 'svelte-routing'; | |
import Footer from './component-display.svelte'; | |
</script> | |
<Router> | |
<Route path="/"><Footer /></Route> | |
</Router> |
NewerOlder