Skip to content

Commit

Permalink
trial: jotai-core scope impl
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaskasky committed Sep 26, 2024
1 parent 4b14203 commit c2dffd4
Show file tree
Hide file tree
Showing 27 changed files with 2,765 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
type SetStateAction,
} from 'jotai'
import { atomWithReducer } from 'jotai/vanilla/utils'
import { ScopeProvider } from '../../src/index'
import { clickButton, getTextContents } from '../utils'
import { ScopeProvider } from 'src/ScopeProvider2/ScopeProvider'
import { clickButton, getTextContents } from './utils'

describe('Counter', () => {
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { render } from '@testing-library/react'
import type { PropsWithChildren } from 'react'
import { atom, useAtom, useAtomValue } from 'jotai'
import { atomWithReducer } from 'jotai/vanilla/utils'
import { ScopeProvider } from '../../src/index'
import { clickButton, getTextContents } from '../utils'
import { ScopeProvider } from 'src/ScopeProvider2/ScopeProvider'
import { clickButton, getTextContents } from './utils'

const baseAtom1 = atomWithReducer(0, (v) => v + 1)
const baseAtom2 = atomWithReducer(0, (v) => v + 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { render } from '@testing-library/react'
import { atom, useAtom, useAtomValue, useSetAtom } from 'jotai'
import { atomWithReducer } from 'jotai/vanilla/utils'
import { clickButton, getTextContents } from '../utils'
import { clickButton, getTextContents } from './utils'

import { ScopeProvider } from '../../src/index'
import { ScopeProvider } from 'src/ScopeProvider2/ScopeProvider'

Check failure on line 6 in __tests__/ScopeProvider2/03_nested.test.tsx

View workflow job for this annotation

GitHub Actions / test

`src/ScopeProvider2/ScopeProvider` import should occur before import of `./utils`

Check failure on line 6 in __tests__/ScopeProvider2/03_nested.test.tsx

View workflow job for this annotation

GitHub Actions / test

`src/ScopeProvider2/ScopeProvider` import should occur before import of `./utils`

const baseAtom1 = atomWithReducer(0, (v) => v + 1)
const baseAtom2 = atomWithReducer(0, (v) => v + 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from '@testing-library/react'
import { atom, useAtom } from 'jotai'
import { clickButton, getTextContents } from '../utils'
import { ScopeProvider } from '../../src/index'
import { clickButton, getTextContents } from './utils'
import { ScopeProvider } from 'src/ScopeProvider2/ScopeProvider'

Check failure on line 4 in __tests__/ScopeProvider2/04_derived.test.tsx

View workflow job for this annotation

GitHub Actions / test

`src/ScopeProvider2/ScopeProvider` import should occur before import of `./utils`

Check failure on line 4 in __tests__/ScopeProvider2/04_derived.test.tsx

View workflow job for this annotation

GitHub Actions / test

`src/ScopeProvider2/ScopeProvider` import should occur before import of `./utils`

const atomValueSelectors = [
'.case1.base',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render } from '@testing-library/react'
import { atom, useAtom } from 'jotai'
import { useHydrateAtoms } from 'jotai/utils'
import { getTextContents } from '../utils'
import { ScopeProvider } from '../../src/index'
import { getTextContents } from './utils'
import { ScopeProvider } from 'src/ScopeProvider2/ScopeProvider'

Check failure on line 5 in __tests__/ScopeProvider2/05_derived_self.test.tsx

View workflow job for this annotation

GitHub Actions / test

`src/ScopeProvider2/ScopeProvider` import should occur before import of `./utils`

Check failure on line 5 in __tests__/ScopeProvider2/05_derived_self.test.tsx

View workflow job for this annotation

GitHub Actions / test

`src/ScopeProvider2/ScopeProvider` import should occur before import of `./utils`

const baseAtom = atom(0)
const derivedAtom1 = atom(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { FC } from 'react'
import { render } from '@testing-library/react'
import { atom, useAtom, useAtomValue } from 'jotai'
import { atomWithReducer } from 'jotai/vanilla/utils'
import { clickButton, getTextContents } from '../utils'
import { ScopeProvider } from '../../src/index'
import { clickButton, getTextContents } from './utils'
import { ScopeProvider } from 'src/ScopeProvider2/ScopeProvider'

Check failure on line 6 in __tests__/ScopeProvider2/06_implicit_parent.test.tsx

View workflow job for this annotation

GitHub Actions / test

`src/ScopeProvider2/ScopeProvider` import should occur before import of `./utils`

Check failure on line 6 in __tests__/ScopeProvider2/06_implicit_parent.test.tsx

View workflow job for this annotation

GitHub Actions / test

`src/ScopeProvider2/ScopeProvider` import should occur before import of `./utils`

function renderWithOrder(level1: 'BD' | 'DB', level2: 'BD' | 'DB') {
const baseAtom = atomWithReducer(0, (v) => v + 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from '@testing-library/react'
import { type WritableAtom, type PrimitiveAtom, atom, useAtom } from 'jotai'
import { clickButton, getTextContents } from '../utils'
import { ScopeProvider } from '../../src/index'
import { clickButton, getTextContents } from './utils'
import { ScopeProvider } from 'src/ScopeProvider2/ScopeProvider'

Check failure on line 4 in __tests__/ScopeProvider2/07_writable.test.tsx

View workflow job for this annotation

GitHub Actions / test

`src/ScopeProvider2/ScopeProvider` import should occur before import of `./utils`

Check failure on line 4 in __tests__/ScopeProvider2/07_writable.test.tsx

View workflow job for this annotation

GitHub Actions / test

`src/ScopeProvider2/ScopeProvider` import should occur before import of `./utils`

let baseAtom: PrimitiveAtom<number>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render, act } from '@testing-library/react'
import { useAtom, atom, useSetAtom } from 'jotai'
import { atomFamily, atomWithReducer } from 'jotai/utils'
import { ScopeProvider } from '../../src/index'
import { clickButton, getTextContents } from '../utils'
import { ScopeProvider } from 'src/ScopeProvider2/ScopeProvider'
import { clickButton, getTextContents } from './utils'

describe('AtomFamily with ScopeProvider', () => {
/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useState } from 'react'
import { render, act } from '@testing-library/react'
import { atom, useAtomValue } from 'jotai'
import { ScopeProvider } from '../../src/index'
import { clickButton } from '../utils'
import { ScopeProvider } from 'src/ScopeProvider2/ScopeProvider'
import { clickButton } from './utils'

describe('ScopeProvider', () => {
it('mounts and unmounts successfully', () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/utils.ts → __tests__/ScopeProvider2/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fireEvent } from '@testing-library/react'
import type { Store } from 'src/ScopeProvider2/types'
import type { Store } from 'src/ScopeProvider3/types'

function getElements(container: HTMLElement, querySelectors: string[]): Element[] {
return querySelectors.map((querySelector) => {
Expand Down
Loading

0 comments on commit c2dffd4

Please sign in to comment.