@@ -22,3 +22,56 @@ describe('logging custom events', function () {
2222 _ . keys ( events ) . should . eql ( [ 'commands' , 'appiumEvent' , 'myorg:myevent' ] ) ;
2323 } ) ;
2424} ) ;
25+
26+ describe ( '#getLogEvents' , function ( ) {
27+ it ( 'should allow to get all events' , async function ( ) {
28+ const d = new BaseDriver ( ) ;
29+ d . _eventHistory . should . eql ( { commands : [ ] } ) ;
30+ d . _eventHistory . testCommand = [ '1' , '2' , '3' ] ;
31+ await d . getLogEvents ( ) . should . eql ( {
32+ commands : [ ] , testCommand : [ '1' , '2' , '3' ]
33+ } ) ;
34+ } ) ;
35+
36+ it ( 'should filter with testCommand' , async function ( ) {
37+ const d = new BaseDriver ( ) ;
38+ d . _eventHistory . should . eql ( { commands : [ ] } ) ;
39+ d . _eventHistory . testCommand = [ '1' , '2' , '3' ] ;
40+ await d . getLogEvents ( 'testCommand' ) . should . eql ( {
41+ testCommand : [ '1' , '2' , '3' ]
42+ } ) ;
43+ } ) ;
44+
45+ it ( 'should not filter with wrong but can be a part of the event name' , async function ( ) {
46+ const d = new BaseDriver ( ) ;
47+ d . _eventHistory . should . eql ( { commands : [ ] } ) ;
48+ d . _eventHistory . testCommand = [ '1' , '2' , '3' ] ;
49+ await d . getLogEvents ( 'testCommandDummy' ) . should . eql ( { } ) ;
50+ } ) ;
51+
52+ it ( 'should filter with multiple event keys' , async function ( ) {
53+ const d = new BaseDriver ( ) ;
54+ d . _eventHistory . should . eql ( { commands : [ ] } ) ;
55+ d . _eventHistory . testCommand = [ '1' , '2' , '3' ] ;
56+ d . _eventHistory . testCommand2 = [ '4' , '5' ] ;
57+ await d . getLogEvents ( [ 'testCommand' , 'testCommand2' ] ) . should . eql ( {
58+ testCommand : [ '1' , '2' , '3' ] , testCommand2 : [ '4' , '5' ]
59+ } ) ;
60+ } ) ;
61+
62+ it ( 'should filter with custom events' , async function ( ) {
63+ const d = new BaseDriver ( ) ;
64+ d . _eventHistory . should . eql ( { commands : [ ] } ) ;
65+ d . _eventHistory [ 'custom:appiumEvent' ] = [ '1' , '2' , '3' ] ;
66+ await d . getLogEvents ( [ 'custom:appiumEvent' ] ) . should . eql ( {
67+ 'custom:appiumEvent' : [ '1' , '2' , '3' ]
68+ } ) ;
69+ } ) ;
70+
71+ it ( 'should not filter with no existed event name' , async function ( ) {
72+ const d = new BaseDriver ( ) ;
73+ d . _eventHistory . should . eql ( { commands : [ ] } ) ;
74+ d . _eventHistory . testCommand = [ '1' , '2' , '3' ] ;
75+ await d . getLogEvents ( [ 'noEventName' ] ) . should . eql ( { } ) ;
76+ } ) ;
77+ } ) ;
0 commit comments