Skip to content

Commit

Permalink
update snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed Apr 5, 2024
1 parent 7412b5d commit 862b71e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 59 deletions.
58 changes: 29 additions & 29 deletions tests/babel/plugin-debug-label.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@ 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";"
`)
})

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;"
`)
})
Expand All @@ -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;"
`)
})
Expand All @@ -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;"
`)
})
Expand Down Expand Up @@ -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";"
`)
})

Expand All @@ -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";"
`)
})
24 changes: 12 additions & 12 deletions tests/babel/plugin-react-refresh.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));"
`)
})

Expand All @@ -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));"
`)
})

Expand All @@ -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));"
`)
})

Expand All @@ -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));"
`)
})

Expand All @@ -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));"
`)
})

Expand Down Expand Up @@ -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");"
`)
})

Expand All @@ -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));"
`)
})
36 changes: 18 additions & 18 deletions tests/babel/preset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";"
`)
})

Expand All @@ -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";"
`)
})

Expand All @@ -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";"
`)
})

Expand All @@ -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;"
`)
})
Expand All @@ -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;"
`)
})
Expand All @@ -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";"
`)
})

0 comments on commit 862b71e

Please sign in to comment.