Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('AnimatedValue', () => {

jest.spyOn(NativeAnimatedHelper.API, 'createAnimatedNode');
jest.spyOn(NativeAnimatedHelper.API, 'dropAnimatedNode');
jest.spyOn(NativeAnimatedHelper.API, 'startListeningToAnimatedNodeValue');
});

it('emits update events for listeners added', () => {
Expand Down Expand Up @@ -112,4 +113,52 @@ describe('AnimatedValue', () => {
expect(callbackA).toBeCalledTimes(1);
expect(callbackB).toBeCalledTimes(1);
});

describe('when NativeAnimatedHelper.API.startListeningToAnimatedNodeValue is called', () => {
it('starts listening when addListener is called after __makeNative', () => {
const node = new AnimatedValue(0, {useNativeDriver: false});

node.__makeNative();
expect(
NativeAnimatedHelper.API.startListeningToAnimatedNodeValue,
).toBeCalledTimes(0);

node.addListener(() => {});

expect(
NativeAnimatedHelper.API.startListeningToAnimatedNodeValue,
).toBeCalledTimes(1);
});

it('starts listening when __makeNative is called after addListener', () => {
const node = new AnimatedValue(0, {useNativeDriver: false});

node.addListener(() => {});

expect(
NativeAnimatedHelper.API.startListeningToAnimatedNodeValue,
).toBeCalledTimes(0);

node.__makeNative();

expect(
NativeAnimatedHelper.API.startListeningToAnimatedNodeValue,
).toBeCalledTimes(1);
});

it('does not start listening to node when not native', () => {
const node = new AnimatedValue(0, {useNativeDriver: false});

node.__attach();
expect(
NativeAnimatedHelper.API.startListeningToAnimatedNodeValue,
).toBeCalledTimes(0);

node.addListener(() => {});

expect(
NativeAnimatedHelper.API.startListeningToAnimatedNodeValue,
).toBeCalledTimes(0);
});
});
});