File size: 1,926 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
import { isCurrentUserUploadingGravatar, getUserTempGravatar } from '../selectors';
describe( 'selectors', () => {
describe( '#isCurrentUserUploadingGravatar', () => {
test( 'returns state when defined', () => {
const uploadingState = {
gravatarStatus: {
isUploading: true,
},
};
expect( isCurrentUserUploadingGravatar( uploadingState ) ).toBe( true );
const notUploadingState = {
gravatarStatus: {
isUploading: false,
},
};
expect( isCurrentUserUploadingGravatar( notUploadingState ) ).toBe( false );
} );
} );
describe( '#getUserTempGravatar', () => {
const tempImage = 'image';
const currentUserId = 1;
const anotherUserId = 2;
test( 'returns false if user ID is not passed in, or is false', () => {
const state = {
currentUser: {
id: currentUserId,
},
gravatarStatus: {
tempImage,
},
};
expect( getUserTempGravatar( state ) ).toBe( false );
expect( getUserTempGravatar( state, false ) ).toBe( false );
} );
test( 'returns false if the user ID passed is not the current user ID', () => {
const state = {
currentUser: {
id: currentUserId,
},
gravatarStatus: {
tempImage,
},
};
expect( getUserTempGravatar( state, anotherUserId ) ).toBe( false );
} );
test( 'returns false if the current user does not have temp image set', () => {
const emptyTempImage = {
currentUser: {
id: currentUserId,
},
gravatarStatus: {
tempImage: null,
},
};
expect( getUserTempGravatar( emptyTempImage, currentUserId ) ).toBe( false );
} );
test( 'returns image src if given the current user ID, and the current user has a temp image set', () => {
const state = {
currentUser: {
id: currentUserId,
},
gravatarStatus: {
tempImage,
},
};
expect( getUserTempGravatar( state, currentUserId ) ).toBe( tempImage );
} );
} );
} );
|