@@ -1816,33 +1816,38 @@ describe('Integration | Identity Access Management | Infrastructure | Repository
1816
1816
} ) ;
1817
1817
1818
1818
describe ( '#isUserExistingByEmail' , function ( ) {
1819
- const email = '[email protected] ' ;
1819
+ const email = '[email protected] ' ;
1820
1820
1821
1821
beforeEach ( function ( ) {
1822
1822
databaseBuilder . factory . buildUser ( { email } ) ;
1823
1823
databaseBuilder . factory . buildUser ( ) ;
1824
1824
return databaseBuilder . commit ( ) ;
1825
1825
} ) ;
1826
1826
1827
- it ( 'returns true when the user exists by email' , async function ( ) {
1827
+ it ( 'finds a user with the exact email' , async function ( ) {
1828
1828
const userExists = await userRepository . isUserExistingByEmail ( email ) ;
1829
1829
expect ( userExists ) . to . be . true ;
1830
1830
} ) ;
1831
1831
1832
- it ( 'returns true when the user exists by email (case insensitive)' , async function ( ) {
1833
- // given
1834
- const uppercaseEmailAlreadyInDb = email . toUpperCase ( ) ;
1832
+ context ( 'when a user exists but with an email differing by case (case insensitive search)' , function ( ) {
1833
+ it ( 'finds the user' , async function ( ) {
1834
+ // given
1835
+ const uppercaseEmailAlreadyInDb = email . toUpperCase ( ) ;
1835
1836
1836
- // when
1837
- const userExists = await userRepository . isUserExistingByEmail ( uppercaseEmailAlreadyInDb ) ;
1837
+ // when
1838
+ const userExists = await userRepository . isUserExistingByEmail ( uppercaseEmailAlreadyInDb ) ;
1838
1839
1839
- // then
1840
- expect ( userExists ) . to . be . true ;
1840
+ // then
1841
+ expect ( userExists ) . to . be . true ;
1842
+ } ) ;
1841
1843
} ) ;
1842
1844
1843
- it ( 'throws an error when the user does not exist by email' , async function ( ) {
1844
- const err = await catchErr ( userRepository . isUserExistingByEmail ) ( 'none' ) ;
1845
- expect ( err ) . to . be . instanceOf ( UserNotFoundError ) ;
1845
+ context ( 'when no user account with a matching email exist' , function ( ) {
1846
+ it ( 'throws an error' , async function ( ) {
1847
+ const searchedEmail = '[email protected] ' ;
1848
+ const err = await catchErr ( userRepository . isUserExistingByEmail ) ( searchedEmail ) ;
1849
+ expect ( err ) . to . be . instanceOf ( UserNotFoundError ) ;
1850
+ } ) ;
1846
1851
} ) ;
1847
1852
} ) ;
1848
1853
0 commit comments