@@ -1867,5 +1867,138 @@ describe('IMAP Protocol integration tests', function () {
18671867 }
18681868 ) ;
18691869 } ) ;
1870+
1871+ it ( 'should search with UID SEARCH 1:N correctly if N equals to EXISTS response' , function ( done ) {
1872+ let cmds = [ 'T1 LOGIN testuser pass' , 'T2 SELECT INBOX' , 'T3 UID SEARCH 1:6 NOT DELETED' , 'T4 LOGOUT' ] ;
1873+
1874+ testClient (
1875+ {
1876+ commands : cmds ,
1877+ secure : true ,
1878+ port
1879+ } ,
1880+ function ( resp ) {
1881+ resp = resp . toString ( ) ;
1882+ expect ( resp . match ( / ^ \* S E A R C H / gm) . length ) . to . equal ( 1 ) ;
1883+ expect ( / ^ \* S E A R C H 1 0 1 1 0 2 1 0 3 1 0 4 1 0 5 1 0 6 $ / m. test ( resp ) ) . to . be . true ;
1884+ expect ( / ^ T 3 O K / m. test ( resp ) ) . to . be . true ;
1885+ done ( ) ;
1886+ }
1887+ ) ;
1888+ } ) ;
1889+
1890+ it ( 'should search with UID SEARCH 1:N correctly if N does not equal to EXISTS response' , function ( done ) {
1891+ let cmds = [ 'T1 LOGIN testuser pass' , 'T2 SELECT INBOX' , 'T3 UID SEARCH 1:3' , 'T4 LOGOUT' ] ;
1892+
1893+ testClient (
1894+ {
1895+ commands : cmds ,
1896+ secure : true ,
1897+ port
1898+ } ,
1899+ function ( resp ) {
1900+ resp = resp . toString ( ) ;
1901+ expect ( resp . match ( / ^ \* S E A R C H / gm) . length ) . to . equal ( 1 ) ;
1902+ expect ( / ^ \* S E A R C H 1 0 1 1 0 2 1 0 3 $ / m. test ( resp ) ) . to . be . true ;
1903+ expect ( / ^ T 3 O K / m. test ( resp ) ) . to . be . true ;
1904+ done ( ) ;
1905+ }
1906+ ) ;
1907+ } ) ;
1908+
1909+ it ( 'should intersect sequence set with UID search key in UID SEARCH' , function ( done ) {
1910+ let cmds = [ 'T1 LOGIN testuser pass' , 'T2 SELECT INBOX' , 'T3 UID SEARCH 2:5 UID 103:104' , 'T4 LOGOUT' ] ;
1911+
1912+ testClient (
1913+ {
1914+ commands : cmds ,
1915+ secure : true ,
1916+ port
1917+ } ,
1918+ function ( resp ) {
1919+ resp = resp . toString ( ) ;
1920+ expect ( resp . match ( / ^ \* S E A R C H / gm) . length ) . to . equal ( 1 ) ;
1921+ expect ( / ^ \* S E A R C H 1 0 3 1 0 4 $ / m. test ( resp ) ) . to . be . true ;
1922+ expect ( / ^ T 3 O K / m. test ( resp ) ) . to . be . true ;
1923+ done ( ) ;
1924+ }
1925+ ) ;
1926+ } ) ;
1927+
1928+ it ( 'should treat 1:10 as sequence and 20:30 as UID set (empty intersection)' , function ( done ) {
1929+ let cmds = [ 'T1 LOGIN testuser pass' , 'T2 SELECT INBOX' , 'T3 UID SEARCH 1:10 UID 20:30' , 'T4 LOGOUT' ] ;
1930+
1931+ testClient (
1932+ {
1933+ commands : cmds ,
1934+ secure : true ,
1935+ port
1936+ } ,
1937+ function ( resp ) {
1938+ resp = resp . toString ( ) ;
1939+ expect ( / ^ \* S E A R C H $ / m. test ( resp ) ) . to . be . true ;
1940+ expect ( / ^ \* S E A R C H \d / m. test ( resp ) ) . to . be . false ;
1941+ expect ( / ^ T 3 O K / m. test ( resp ) ) . to . be . true ;
1942+ done ( ) ;
1943+ }
1944+ ) ;
1945+ } ) ;
1946+
1947+ it ( 'should treat UID 1:10 as UID set and 20:30 as sequence (empty intersection)' , function ( done ) {
1948+ let cmds = [ 'T1 LOGIN testuser pass' , 'T2 SELECT INBOX' , 'T3 UID SEARCH UID 1:10 20:30' , 'T4 LOGOUT' ] ;
1949+
1950+ testClient (
1951+ {
1952+ commands : cmds ,
1953+ secure : true ,
1954+ port
1955+ } ,
1956+ function ( resp ) {
1957+ resp = resp . toString ( ) ;
1958+ expect ( / ^ \* S E A R C H $ / m. test ( resp ) ) . to . be . true ;
1959+ expect ( / ^ \* S E A R C H \d / m. test ( resp ) ) . to . be . false ;
1960+ expect ( / ^ T 3 O K / m. test ( resp ) ) . to . be . true ;
1961+ done ( ) ;
1962+ }
1963+ ) ;
1964+ } ) ;
1965+
1966+ it ( 'should intersect sequence set with UID set when both match' , function ( done ) {
1967+ let cmds = [ 'T1 LOGIN testuser pass' , 'T2 SELECT INBOX' , 'T3 UID SEARCH 1:4 UID 102:104' , 'T4 LOGOUT' ] ;
1968+
1969+ testClient (
1970+ {
1971+ commands : cmds ,
1972+ secure : true ,
1973+ port
1974+ } ,
1975+ function ( resp ) {
1976+ resp = resp . toString ( ) ;
1977+ expect ( resp . match ( / ^ \* S E A R C H / gm) . length ) . to . equal ( 1 ) ;
1978+ expect ( / ^ \* S E A R C H 1 0 2 1 0 3 1 0 4 $ / m. test ( resp ) ) . to . be . true ;
1979+ expect ( / ^ T 3 O K / m. test ( resp ) ) . to . be . true ;
1980+ done ( ) ;
1981+ }
1982+ ) ;
1983+ } ) ;
1984+
1985+ it ( 'should intersect UID set first and sequence set second' , function ( done ) {
1986+ let cmds = [ 'T1 LOGIN testuser pass' , 'T2 SELECT INBOX' , 'T3 UID SEARCH UID 101:104 2:3' , 'T4 LOGOUT' ] ;
1987+
1988+ testClient (
1989+ {
1990+ commands : cmds ,
1991+ secure : true ,
1992+ port
1993+ } ,
1994+ function ( resp ) {
1995+ resp = resp . toString ( ) ;
1996+ expect ( resp . match ( / ^ \* S E A R C H / gm) . length ) . to . equal ( 1 ) ;
1997+ expect ( / ^ \* S E A R C H 1 0 2 1 0 3 $ / m. test ( resp ) ) . to . be . true ;
1998+ expect ( / ^ T 3 O K / m. test ( resp ) ) . to . be . true ;
1999+ done ( ) ;
2000+ }
2001+ ) ;
2002+ } ) ;
18702003 } ) ;
18712004} ) ;
0 commit comments