-
Notifications
You must be signed in to change notification settings - Fork 2k
/
is-authors-email-blocked.js
50 lines (45 loc) · 1.39 KB
/
is-authors-email-blocked.js
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
/**
* External dependencies
*/
import { expect } from 'chai';
/**
* Internal dependencies
*/
import isAuthorsEmailBlocked from 'state/selectors/is-authors-email-blocked';
const email = 'foo@bar.baz';
const state = {
siteSettings: {
items: {
123: {
blacklist_keys: 'mail@mail.com\ntest@example.com\nfoo@bar.baz\nyadda@yadda.yadda',
},
456: {
blacklist_keys: 'mail@mail.com\ntest@example.com\nyadda@yadda.yadda',
},
789: {
blacklist_keys: '',
},
},
},
};
const noSiteSettingsState = { siteSettings: {} };
describe( 'isAuthorsEmailBlocked()', () => {
test( 'should return true if email is blocked', () => {
expect( isAuthorsEmailBlocked( state, 123, email ) ).to.be.true;
} );
test( 'should return false if email is not blocked', () => {
expect( isAuthorsEmailBlocked( state, 456, email ) ).to.be.false;
} );
test( 'should return false if blocklist is empty', () => {
expect( isAuthorsEmailBlocked( state, 789, email ) ).to.be.false;
} );
test( 'should return false if there are no site settings in state', () => {
expect( isAuthorsEmailBlocked( noSiteSettingsState, 123, email ) ).to.be.false;
} );
test( 'should return false if no email is provided', () => {
expect( isAuthorsEmailBlocked( state, 123 ) ).to.be.false;
} );
test( 'should return false if email is empty', () => {
expect( isAuthorsEmailBlocked( state, 123, '' ) ).to.be.false;
} );
} );