@@ -59,23 +59,47 @@ describe('users', () => {
5959 done ( ) ;
6060 } ) ;
6161 } ) ;
62- it ( 'should delete users by id' , done => {
62+ it ( 'should archive users by id' , done => {
63+ nock ( 'https://api.intercom.io' ) . delete ( '/users/baz' ) . reply ( 200 , { } ) ;
64+ const client = new Client ( 'foo' , 'bar' ) . usePromises ( ) ;
65+ client . users . archive ( { id : 'baz' } ) . then ( r => {
66+ assert . equal ( 200 , r . statusCode ) ;
67+ done ( ) ;
68+ } ) ;
69+ } ) ;
70+ it ( 'should archive users by user_id' , done => {
71+ nock ( 'https://api.intercom.io' ) . delete ( '/users' ) . query ( { user_id : 'foo' } ) . reply ( 200 , { } ) ;
72+ const client = new Client ( 'foo' , 'bar' ) . usePromises ( ) ;
73+ client . users . archive ( { user_id : 'foo' } ) . then ( r => {
74+ assert . equal ( 200 , r . statusCode ) ;
75+ done ( ) ;
76+ } ) ;
77+ } ) ;
78+ it ( 'should archive users by email' , done => {
79+ nock ( 'https://api.intercom.io' ) . delete ( '/users' ) . query ( { email : 'foo' } ) . reply ( 200 , { } ) ;
80+ const client = new Client ( 'foo' , 'bar' ) . usePromises ( ) ;
81+ client . users . archive ( { email : 'foo' } ) . then ( r => {
82+ assert . equal ( 200 , r . statusCode ) ;
83+ done ( ) ;
84+ } ) ;
85+ } ) ;
86+ it ( 'should archive (using old delete function) users by id' , done => {
6387 nock ( 'https://api.intercom.io' ) . delete ( '/users/baz' ) . reply ( 200 , { } ) ;
6488 const client = new Client ( 'foo' , 'bar' ) . usePromises ( ) ;
6589 client . users . delete ( { id : 'baz' } ) . then ( r => {
6690 assert . equal ( 200 , r . statusCode ) ;
6791 done ( ) ;
6892 } ) ;
6993 } ) ;
70- it ( 'should delete users by user_id' , done => {
94+ it ( 'should archive (using old delete function) users by user_id' , done => {
7195 nock ( 'https://api.intercom.io' ) . delete ( '/users' ) . query ( { user_id : 'foo' } ) . reply ( 200 , { } ) ;
7296 const client = new Client ( 'foo' , 'bar' ) . usePromises ( ) ;
7397 client . users . delete ( { user_id : 'foo' } ) . then ( r => {
7498 assert . equal ( 200 , r . statusCode ) ;
7599 done ( ) ;
76100 } ) ;
77101 } ) ;
78- it ( 'should delete users by email' , done => {
102+ it ( 'should archive (using old delete function) users by email' , done => {
79103 nock ( 'https://api.intercom.io' ) . delete ( '/users' ) . query ( { email : 'foo' } ) . reply ( 200 , { } ) ;
80104 const client = new Client ( 'foo' , 'bar' ) . usePromises ( ) ;
81105 client . users . delete ( { email : 'foo' } ) . then ( r => {
0 commit comments