diff --git a/tests/babel/plugin-debug-label.test.ts b/tests/babel/plugin-debug-label.test.ts index b7c4dc7e11..9897007bf5 100644 --- a/tests/babel/plugin-debug-label.test.ts +++ b/tests/babel/plugin-debug-label.test.ts @@ -17,21 +17,21 @@ const transform = ( it('Should add a debugLabel to an atom', () => { expect(transform(`const countAtom = atom(0);`)).toMatchInlineSnapshot(` "const countAtom = atom(0); - countAtom.debugLabel = \\"countAtom\\";" + countAtom.debugLabel = "countAtom";" `) }) it('Should handle a atom from a default export', () => { expect(transform(`const countAtom = jotai.atom(0);`)).toMatchInlineSnapshot(` "const countAtom = jotai.atom(0); - countAtom.debugLabel = \\"countAtom\\";" + countAtom.debugLabel = "countAtom";" `) }) it('Should handle a atom being exported', () => { expect(transform(`export const countAtom = atom(0);`)).toMatchInlineSnapshot(` "export const countAtom = atom(0); - countAtom.debugLabel = \\"countAtom\\";" + countAtom.debugLabel = "countAtom";" `) }) @@ -39,7 +39,7 @@ it('Should handle a default exported atom', () => { expect(transform(`export default atom(0);`, 'countAtom.ts')) .toMatchInlineSnapshot(` "const countAtom = atom(0); - countAtom.debugLabel = \\"countAtom\\"; + countAtom.debugLabel = "countAtom"; export default countAtom;" `) }) @@ -48,7 +48,7 @@ it('Should handle a default exported atom in a barrel file', () => { expect(transform(`export default atom(0);`, 'atoms/index.ts')) .toMatchInlineSnapshot(` "const atoms = atom(0); - atoms.debugLabel = \\"atoms\\"; + atoms.debugLabel = "atoms"; export default atoms;" `) }) @@ -64,9 +64,9 @@ it('Should handle all types of exports', () => { ), ).toMatchInlineSnapshot(` "export const countAtom = atom(0); - countAtom.debugLabel = \\"countAtom\\"; + countAtom.debugLabel = "countAtom"; const atoms = atom(0); - atoms.debugLabel = \\"atoms\\"; + atoms.debugLabel = "atoms"; export default atoms;" `) }) @@ -112,52 +112,52 @@ it('Should handle all atom types', () => { ), ).toMatchInlineSnapshot(` "export const countAtom = atom(0); - countAtom.debugLabel = \\"countAtom\\"; + countAtom.debugLabel = "countAtom"; const myFamily = atomFamily(param => atom(param)); - myFamily.debugLabel = \\"myFamily\\"; + myFamily.debugLabel = "myFamily"; const countAtomWithDefault = atomWithDefault(get => get(countAtom) * 2); - countAtomWithDefault.debugLabel = \\"countAtomWithDefault\\"; + countAtomWithDefault.debugLabel = "countAtomWithDefault"; const observableAtom = atomWithObservable(() => {}); - observableAtom.debugLabel = \\"observableAtom\\"; + observableAtom.debugLabel = "observableAtom"; const reducerAtom = atomWithReducer(0, () => {}); - reducerAtom.debugLabel = \\"reducerAtom\\"; + reducerAtom.debugLabel = "reducerAtom"; const resetAtom = atomWithReset(0); - resetAtom.debugLabel = \\"resetAtom\\"; + resetAtom.debugLabel = "resetAtom"; const storageAtom = atomWithStorage('count', 1); - storageAtom.debugLabel = \\"storageAtom\\"; + storageAtom.debugLabel = "storageAtom"; const freezedAtom = freezeAtom(atom({ count: 0 })); - freezedAtom.debugLabel = \\"freezedAtom\\"; + freezedAtom.debugLabel = "freezedAtom"; const loadedAtom = loadable(countAtom); - loadedAtom.debugLabel = \\"loadedAtom\\"; + loadedAtom.debugLabel = "loadedAtom"; const selectedValueAtom = selectAtom(atom({ a: 0, b: 'othervalue' }), v => v.a); - selectedValueAtom.debugLabel = \\"selectedValueAtom\\"; + selectedValueAtom.debugLabel = "selectedValueAtom"; const splittedAtom = splitAtom(atom([])); - splittedAtom.debugLabel = \\"splittedAtom\\"; + splittedAtom.debugLabel = "splittedAtom"; const unwrappedAtom = unwrap(asyncArrayAtom, () => []); - unwrappedAtom.debugLabel = \\"unwrappedAtom\\"; + unwrappedAtom.debugLabel = "unwrappedAtom"; const someatomWithSubscription = atomWithSubscription(() => {}); - someatomWithSubscription.debugLabel = \\"someatomWithSubscription\\"; + someatomWithSubscription.debugLabel = "someatomWithSubscription"; const someAtomWithStore = atomWithStore(() => {}); - someAtomWithStore.debugLabel = \\"someAtomWithStore\\"; + someAtomWithStore.debugLabel = "someAtomWithStore"; const someAtomWithHash = atomWithHash('', ''); - someAtomWithHash.debugLabel = \\"someAtomWithHash\\"; + someAtomWithHash.debugLabel = "someAtomWithHash"; const someAtomWithLocation = atomWithLocation(); - someAtomWithLocation.debugLabel = \\"someAtomWithLocation\\"; + someAtomWithLocation.debugLabel = "someAtomWithLocation"; const someFocusAtom = focusAtom(someAtom, () => {}); - someFocusAtom.debugLabel = \\"someFocusAtom\\"; + someFocusAtom.debugLabel = "someFocusAtom"; const someAtomWithValidate = atomWithValidate('', {}); - someAtomWithValidate.debugLabel = \\"someAtomWithValidate\\"; + someAtomWithValidate.debugLabel = "someAtomWithValidate"; const someValidateAtoms = validateAtoms({}, () => {}); - someValidateAtoms.debugLabel = \\"someValidateAtoms\\"; + someValidateAtoms.debugLabel = "someValidateAtoms"; const someAtomWithCache = atomWithCache(async () => {}); - someAtomWithCache.debugLabel = \\"someAtomWithCache\\"; + someAtomWithCache.debugLabel = "someAtomWithCache"; const someAtomWithRecoilValue = atomWithRecoilValue({}); - someAtomWithRecoilValue.debugLabel = \\"someAtomWithRecoilValue\\";" + someAtomWithRecoilValue.debugLabel = "someAtomWithRecoilValue";" `) }) @@ -168,6 +168,6 @@ it('Handles custom atom names a debugLabel to an atom', () => { ]), ).toMatchInlineSnapshot(` "const mySpecialThing = myCustomAtom(0); - mySpecialThing.debugLabel = \\"mySpecialThing\\";" + mySpecialThing.debugLabel = "mySpecialThing";" `) }) diff --git a/tests/babel/plugin-react-refresh.test.ts b/tests/babel/plugin-react-refresh.test.ts index 352d547b9f..a83dbc2121 100644 --- a/tests/babel/plugin-react-refresh.test.ts +++ b/tests/babel/plugin-react-refresh.test.ts @@ -28,7 +28,7 @@ it('Should add a cache for a single atom', () => { return inst; } }; - const countAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/countAtom\\", atom(0));" + const countAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/countAtom", atom(0));" `) }) @@ -52,8 +52,8 @@ it('Should add a cache for multiple atoms', () => { return inst; } }; - const countAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/countAtom\\", atom(0)); - const doubleAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/doubleAtom\\", atom(get => get(countAtom) * 2));" + const countAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/countAtom", atom(0)); + const doubleAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/doubleAtom", atom(get => get(countAtom) * 2));" `) }) @@ -77,8 +77,8 @@ it('Should add a cache for multiple exported atoms', () => { return inst; } }; - export const countAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/countAtom\\", atom(0)); - export const doubleAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/doubleAtom\\", atom(get => get(countAtom) * 2));" + export const countAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/countAtom", atom(0)); + export const doubleAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/doubleAtom", atom(get => get(countAtom) * 2));" `) }) @@ -95,7 +95,7 @@ it('Should add a cache for a default exported atom', () => { return inst; } }; - export default globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/defaultExport\\", atom(0));" + export default globalThis.jotaiAtomCache.get("/src/atoms/index.ts/defaultExport", atom(0));" `) }) @@ -119,8 +119,8 @@ it('Should add a cache for mixed exports of atoms', () => { return inst; } }; - export const countAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/countAtom\\", atom(0)); - export default globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/defaultExport\\", atom(get => get(countAtom) * 2));" + export const countAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/countAtom", atom(0)); + export default globalThis.jotaiAtomCache.get("/src/atoms/index.ts/defaultExport", atom(get => get(countAtom) * 2));" `) }) @@ -160,9 +160,9 @@ it('Should handle atoms returned from functions (#891)', () => { anAtom.debugLabel = label; return anAtom; } - const countAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/countAtom\\", atom(0)); - const countAtom2 = createAtom(\\"countAtom2\\"); - const countAtom3 = createAtom(\\"countAtom3\\");" + const countAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/countAtom", atom(0)); + const countAtom2 = createAtom("countAtom2"); + const countAtom3 = createAtom("countAtom3");" `) }) @@ -184,6 +184,6 @@ it('Should handle custom atom names', () => { return inst; } }; - const mySpecialThing = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/mySpecialThing\\", myCustomAtom(0));" + const mySpecialThing = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/mySpecialThing", myCustomAtom(0));" `) }) diff --git a/tests/babel/preset.test.ts b/tests/babel/preset.test.ts index df02911cb1..2339b293ea 100644 --- a/tests/babel/preset.test.ts +++ b/tests/babel/preset.test.ts @@ -27,8 +27,8 @@ it('Should add a debugLabel and cache to an atom', () => { return inst; } }; - const countAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms.ts/countAtom\\", atom(0)); - countAtom.debugLabel = \\"countAtom\\";" + const countAtom = globalThis.jotaiAtomCache.get("/src/atoms.ts/countAtom", atom(0)); + countAtom.debugLabel = "countAtom";" `) }) @@ -51,10 +51,10 @@ it('Should add a debugLabel and cache to multiple atoms', () => { return inst; } }; - const countAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms.ts/countAtom\\", atom(0)); - countAtom.debugLabel = \\"countAtom\\"; - const doubleAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms.ts/doubleAtom\\", atom(get => get(countAtom) * 2)); - doubleAtom.debugLabel = \\"doubleAtom\\";" + const countAtom = globalThis.jotaiAtomCache.get("/src/atoms.ts/countAtom", atom(0)); + countAtom.debugLabel = "countAtom"; + const doubleAtom = globalThis.jotaiAtomCache.get("/src/atoms.ts/doubleAtom", atom(get => get(countAtom) * 2)); + doubleAtom.debugLabel = "doubleAtom";" `) }) @@ -78,10 +78,10 @@ it('Should add a cache and debugLabel for multiple exported atoms', () => { return inst; } }; - export const countAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/countAtom\\", atom(0)); - countAtom.debugLabel = \\"countAtom\\"; - export const doubleAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/doubleAtom\\", atom(get => get(countAtom) * 2)); - doubleAtom.debugLabel = \\"doubleAtom\\";" + export const countAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/countAtom", atom(0)); + countAtom.debugLabel = "countAtom"; + export const doubleAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/doubleAtom", atom(get => get(countAtom) * 2)); + doubleAtom.debugLabel = "doubleAtom";" `) }) @@ -98,8 +98,8 @@ it('Should add a cache and debugLabel for a default exported atom', () => { return inst; } }; - const atoms = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/atoms\\", atom(0)); - atoms.debugLabel = \\"atoms\\"; + const atoms = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/atoms", atom(0)); + atoms.debugLabel = "atoms"; export default atoms;" `) }) @@ -124,10 +124,10 @@ it('Should add a cache and debugLabel for mixed exports of atoms', () => { return inst; } }; - export const countAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/countAtom\\", atom(0)); - countAtom.debugLabel = \\"countAtom\\"; - const atoms = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/atoms\\", atom(get => get(countAtom) * 2)); - atoms.debugLabel = \\"atoms\\"; + export const countAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/countAtom", atom(0)); + countAtom.debugLabel = "countAtom"; + const atoms = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/atoms", atom(get => get(countAtom) * 2)); + atoms.debugLabel = "atoms"; export default atoms;" `) }) @@ -154,7 +154,7 @@ it('Should handle custom atom names', () => { return inst; } }; - const mySpecialThing = globalThis.jotaiAtomCache.get(\\"/src/atoms.ts/mySpecialThing\\", myCustomAtom(0)); - mySpecialThing.debugLabel = \\"mySpecialThing\\";" + const mySpecialThing = globalThis.jotaiAtomCache.get("/src/atoms.ts/mySpecialThing", myCustomAtom(0)); + mySpecialThing.debugLabel = "mySpecialThing";" `) })