Skip to content

Commit cd44aec

Browse files
Add a test to verify response from non-async callback function
1 parent be02235 commit cd44aec

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

test/domain.test.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,23 @@ describe('store: [adapter=DOMAIN]', () => {
840840
});
841841
});
842842

843+
it('should return the response from callback function.', (done) => {
844+
const callback = () => {
845+
globalStore.set({ foo: 'foo' });
846+
847+
return functionAccessingStore();
848+
};
849+
850+
const functionAccessingStore = () => {
851+
return globalStore.get('foo');
852+
};
853+
854+
const response = globalStore.initialize(adapter)(callback);
855+
expect(response).to.equal('foo');
856+
857+
done();
858+
});
859+
843860
it('should return the response from async callback function.', async () => {
844861
const callback = async () => {
845862
globalStore.set({ foo: 'foo' });
@@ -872,9 +889,9 @@ describe('store: [adapter=DOMAIN]', () => {
872889
const callback = () => {
873890
globalStore.set({ foo: 'foo' });
874891

875-
return new Promise((resolve, rejects) => {
892+
return new Promise((resolve, reject) => {
876893
setTimeout(() => {
877-
rejects('Hello world');
894+
reject('Hello world');
878895
}, 1);
879896
});
880897
};

0 commit comments

Comments
 (0)