Skip to content

Commit

Permalink
refactor: remove hello world component
Browse files Browse the repository at this point in the history
  • Loading branch information
ZanzyTHEbar committed May 16, 2023
1 parent c2ab929 commit 4ad1649
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 34 deletions.
4 changes: 0 additions & 4 deletions dev/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
Tooltip,
Legend,
} from '../src'
import { Hello } from '../src/hello'
import styles from './App.module.css'
import logo from './logo.svg'

Expand Down Expand Up @@ -75,9 +74,6 @@ const App: Component = () => {
<div class={styles.App}>
<header class={styles.header}>
<img src={logo} class={styles.logo} alt="logo" />
<h1>
<Hello />
</h1>
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
Expand Down
20 changes: 0 additions & 20 deletions src/hello.tsx

This file was deleted.

20 changes: 10 additions & 10 deletions test/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createRoot, createSignal } from 'solid-js'
import { isServer } from 'solid-js/web'
import { describe, expect, it } from 'vitest'
import { Hello, createHello } from '../src/hello'


describe('environment', () => {
it('runs on server', () => {
Expand All @@ -13,38 +13,38 @@ describe('environment', () => {
describe('createHello', () => {
it('Returns a Hello World signal', () =>
createRoot((dispose) => {
const [hello] = createHello()
expect(hello()).toBe('Hello World!')
/* const [hello] = createHello()
expect(hello()).toBe('Hello World!') */
dispose()
}))

it('Changes the hello target', () =>
createRoot((dispose) => {
const [hello, setHello] = createHello()
/*const [hello, setHello] = createHello()
setHello('Solid')
expect(hello()).toBe('Hello Solid!')
expect(hello()).toBe('Hello Solid!') */
dispose()
}))
})

describe('Hello', () => {
it('renders a hello component', () => {
createRoot(() => {
const container = (<Hello />) as HTMLDivElement
expect(container.outerHTML).toBe('<div>Hello World!</div>')
//const container = (<Hello />) as HTMLDivElement
//expect(container.outerHTML).toBe('<div>Hello World!</div>')
})
})

it('changes the hello target', () =>
createRoot((dispose) => {
const [to, setTo] = createSignal('Solid')
const container = (<Hello to={to()} />) as HTMLDivElement
expect(container.outerHTML).toBe('<div>Hello Solid!</div>')
//const container = (<Hello to={to()} />) as HTMLDivElement
//expect(container.outerHTML).toBe('<div>Hello Solid!</div>')
setTo('Tests')

// rendering is async
queueMicrotask(() => {
expect(container.outerHTML).toBe('<div>Hello Tests!</div>')
//expect(container.outerHTML).toBe('<div>Hello Tests!</div>')
dispose()
})
}))
Expand Down

0 comments on commit 4ad1649

Please sign in to comment.