@@ -1441,6 +1441,7 @@ describe('MatrixClient', () => {
1441
1441
type : "m.room.member" ,
1442
1442
state_key : userId ,
1443
1443
unsigned : { age : 0 } ,
1444
+ content : { membership : "leave" } ,
1444
1445
} ,
1445
1446
] ;
1446
1447
@@ -1498,16 +1499,19 @@ describe('MatrixClient', () => {
1498
1499
type : "m.room.member" ,
1499
1500
state_key : userId ,
1500
1501
unsigned : { age : 2 } ,
1502
+ content : { membership : "leave" } ,
1501
1503
} ,
1502
1504
{
1503
1505
type : "m.room.member" ,
1504
1506
state_key : userId ,
1505
1507
unsigned : { age : 1 } ,
1508
+ content : { membership : "leave" } ,
1506
1509
} ,
1507
1510
{
1508
1511
type : "m.room.member" ,
1509
1512
state_key : userId ,
1510
1513
unsigned : { age : 3 } ,
1514
+ content : { membership : "leave" } ,
1511
1515
} ,
1512
1516
] ;
1513
1517
@@ -1536,16 +1540,19 @@ describe('MatrixClient', () => {
1536
1540
type : "m.room.not_member" ,
1537
1541
state_key : userId ,
1538
1542
unsigned : { age : 1 } ,
1543
+ content : { membership : "leave" } ,
1539
1544
} ,
1540
1545
{
1541
1546
type : "m.room.member" ,
1542
1547
state_key : userId ,
1543
1548
unsigned : { age : 1 } ,
1549
+ content : { membership : "leave" } ,
1544
1550
} ,
1545
1551
{
1546
1552
type : "m.room.member" ,
1547
1553
state_key : userId + "_wrong_member" ,
1548
1554
unsigned : { age : 1 } ,
1555
+ content : { membership : "leave" } ,
1549
1556
} ,
1550
1557
] ;
1551
1558
@@ -1580,6 +1587,7 @@ describe('MatrixClient', () => {
1580
1587
// type: "m.room.member",
1581
1588
// state_key: userId,
1582
1589
// unsigned: {age: 1},
1590
+ // content: { membership: "leave" },
1583
1591
// },
1584
1592
{
1585
1593
type : "m.room.member" ,
@@ -1612,6 +1620,7 @@ describe('MatrixClient', () => {
1612
1620
{
1613
1621
type : "m.room.member" ,
1614
1622
state_key : userId ,
1623
+ content : { membership : "leave" } ,
1615
1624
} ,
1616
1625
] ;
1617
1626
@@ -1793,7 +1802,6 @@ describe('MatrixClient', () => {
1793
1802
const userId = "@syncing:example.org" ;
1794
1803
const roomId = "!testing:example.org" ;
1795
1804
const events = [
1796
- // TODO: Surely the 'invite' membership should be in some sort of content field?
1797
1805
{
1798
1806
type : "m.room.member" ,
1799
1807
state_key : userId ,
@@ -1822,16 +1830,25 @@ describe('MatrixClient', () => {
1822
1830
1823
1831
const userId = "@syncing:example.org" ;
1824
1832
const roomId = "!testing:example.org" ;
1833
+ const events = [
1834
+ {
1835
+ type : "m.room.member" ,
1836
+ state_key : userId ,
1837
+ unsigned : { age : 0 } ,
1838
+ content : { membership : "join" } ,
1839
+ } ,
1840
+ ] ;
1825
1841
1826
1842
client . userId = userId ;
1827
1843
1828
- const spy = simple . stub ( ) . callFn ( ( rid ) => {
1844
+ const spy = simple . stub ( ) . callFn ( ( rid , ev ) => {
1845
+ expect ( ev ) . toMatchObject ( events [ 0 ] ) ;
1829
1846
expect ( rid ) . toEqual ( roomId ) ;
1830
1847
} ) ;
1831
1848
realClient . on ( "room.join" , spy ) ;
1832
1849
1833
1850
const roomsObj = { } ;
1834
- roomsObj [ roomId ] = { } ;
1851
+ roomsObj [ roomId ] = { timeline : { events : events } } ;
1835
1852
await client . processSync ( { rooms : { join : roomsObj } } ) ;
1836
1853
expect ( spy . callCount ) . toBe ( 1 ) ;
1837
1854
} ) ;
@@ -1871,16 +1888,25 @@ describe('MatrixClient', () => {
1871
1888
1872
1889
const userId = "@syncing:example.org" ;
1873
1890
const roomId = "!testing:example.org" ;
1891
+ const events = [
1892
+ {
1893
+ type : "m.room.member" ,
1894
+ state_key : userId ,
1895
+ unsigned : { age : 0 } ,
1896
+ content : { membership : "join" } ,
1897
+ } ,
1898
+ ] ;
1874
1899
1875
1900
client . userId = userId ;
1876
1901
1877
- const spy = simple . stub ( ) . callFn ( ( rid ) => {
1902
+ const spy = simple . stub ( ) . callFn ( ( rid , ev ) => {
1903
+ expect ( ev ) . toMatchObject ( events [ 0 ] ) ;
1878
1904
expect ( rid ) . toEqual ( roomId ) ;
1879
1905
} ) ;
1880
1906
realClient . on ( "room.join" , spy ) ;
1881
1907
1882
1908
const roomsObj = { } ;
1883
- roomsObj [ roomId ] = { } ;
1909
+ roomsObj [ roomId ] = { timeline : { events : events } } ;
1884
1910
await client . processSync ( { rooms : { join : roomsObj } } ) ;
1885
1911
expect ( spy . callCount ) . toBe ( 1 ) ;
1886
1912
await client . processSync ( { rooms : { join : roomsObj } } ) ;
@@ -1926,6 +1952,12 @@ describe('MatrixClient', () => {
1926
1952
const userId = "@syncing:example.org" ;
1927
1953
const roomId = "!testing:example.org" ;
1928
1954
const events = [
1955
+ {
1956
+ type : "m.room.member" ,
1957
+ state_key : userId ,
1958
+ unsigned : { age : 0 } ,
1959
+ content : { membership : "join" } ,
1960
+ } ,
1929
1961
{
1930
1962
type : "m.room.not_message" ,
1931
1963
content : { body : "hello world 1" } ,
@@ -1971,7 +2003,7 @@ describe('MatrixClient', () => {
1971
2003
expect ( inviteSpy . callCount ) . toBe ( 0 ) ;
1972
2004
expect ( leaveSpy . callCount ) . toBe ( 0 ) ;
1973
2005
expect ( messageSpy . callCount ) . toBe ( 2 ) ;
1974
- expect ( eventSpy . callCount ) . toBe ( 4 ) ;
2006
+ expect ( eventSpy . callCount ) . toBe ( 5 ) ;
1975
2007
} ) ;
1976
2008
1977
2009
it ( 'should process tombstone events' , async ( ) => {
@@ -1981,6 +2013,12 @@ describe('MatrixClient', () => {
1981
2013
const userId = "@syncing:example.org" ;
1982
2014
const roomId = "!testing:example.org" ;
1983
2015
const events = [
2016
+ {
2017
+ type : "m.room.member" ,
2018
+ state_key : userId ,
2019
+ unsigned : { age : 0 } ,
2020
+ content : { membership : "join" } ,
2021
+ } ,
1984
2022
{
1985
2023
type : "m.room.tombstone" ,
1986
2024
content : { body : "hello world 1" } ,
@@ -2020,7 +2058,7 @@ describe('MatrixClient', () => {
2020
2058
expect ( inviteSpy . callCount ) . toBe ( 0 ) ;
2021
2059
expect ( leaveSpy . callCount ) . toBe ( 0 ) ;
2022
2060
expect ( archiveSpy . callCount ) . toBe ( 1 ) ;
2023
- expect ( eventSpy . callCount ) . toBe ( 2 ) ;
2061
+ expect ( eventSpy . callCount ) . toBe ( 3 ) ;
2024
2062
} ) ;
2025
2063
2026
2064
it ( 'should process create events with a predecessor' , async ( ) => {
@@ -2030,6 +2068,12 @@ describe('MatrixClient', () => {
2030
2068
const userId = "@syncing:example.org" ;
2031
2069
const roomId = "!testing:example.org" ;
2032
2070
const events = [
2071
+ {
2072
+ type : "m.room.member" ,
2073
+ state_key : userId ,
2074
+ unsigned : { age : 0 } ,
2075
+ content : { membership : "join" } ,
2076
+ } ,
2033
2077
{
2034
2078
type : "m.room.tombstone" ,
2035
2079
content : { body : "hello world 1" } ,
@@ -2069,7 +2113,7 @@ describe('MatrixClient', () => {
2069
2113
expect ( inviteSpy . callCount ) . toBe ( 0 ) ;
2070
2114
expect ( leaveSpy . callCount ) . toBe ( 0 ) ;
2071
2115
expect ( upgradedSpy . callCount ) . toBe ( 1 ) ;
2072
- expect ( eventSpy . callCount ) . toBe ( 2 ) ;
2116
+ expect ( eventSpy . callCount ) . toBe ( 3 ) ;
2073
2117
} ) ;
2074
2118
2075
2119
it ( 'should send events through a processor' , async ( ) => {
0 commit comments