@@ -215,6 +215,68 @@ test('Add global contexts', (t) => {
215215 t . is ( globalContexts . getConditionalProviders ( ) . length , 2 , 'Correct number of conditional providers added' ) ;
216216} ) ;
217217
218+ test ( 'Remove one of two global context primitives' , ( t ) => {
219+ const geolocationContext = {
220+ schema : 'iglu:com.snowplowanalytics.snowplow/geolocation_context/jsonschema/1-1-0' ,
221+ data : {
222+ latitude : 40.0 ,
223+ longitude : 55.1 ,
224+ } ,
225+ } ;
226+
227+ const webPageContext = {
228+ schema : 'iglu:org.schema/WebPage/jsonschema/1-0-0' ,
229+ data : {
230+ genre : 'test' ,
231+ } ,
232+ } ;
233+
234+ const globalContexts = contexts . globalContexts ( ) ;
235+ globalContexts . addGlobalContexts ( [ geolocationContext , webPageContext ] ) ;
236+ globalContexts . removeGlobalContexts ( [ geolocationContext ] ) ;
237+ t . deepEqual ( globalContexts . getGlobalPrimitives ( ) , [ webPageContext ] ) ;
238+ } ) ;
239+
240+ test ( 'Remove one of two global context conditional providers' , ( t ) => {
241+ const geolocationContext = {
242+ schema : 'iglu:com.snowplowanalytics.snowplow/geolocation_context/jsonschema/1-1-0' ,
243+ data : {
244+ latitude : 40.0 ,
245+ longitude : 55.1 ,
246+ } ,
247+ } ;
248+
249+ function eventTypeContextGenerator ( args ?: contexts . ContextEvent ) {
250+ const context : SelfDescribingJson = {
251+ schema : 'iglu:com.snowplowanalytics.snowplow/mobile_context/jsonschema/1-0-1' ,
252+ data : {
253+ osType : 'ubuntu' ,
254+ osVersion : '2018.04' ,
255+ deviceManufacturer : 'ASUS' ,
256+ deviceModel : args ? String ( args [ 'eventType' ] ) : '' ,
257+ } ,
258+ } ;
259+ return context ;
260+ }
261+
262+ const bothRuleSet = {
263+ accept : [ 'iglu:com.snowplowanalytics.snowplow/*/jsonschema/*-*-*' ] ,
264+ reject : [ 'iglu:com.snowplowanalytics.snowplow/*/jsonschema/*-*-*' ] ,
265+ } ;
266+
267+ const filterFunction = function ( args ?: contexts . ContextEvent ) {
268+ return args ?. eventType === 'ue' ;
269+ } ;
270+
271+ const filterProvider : contexts . FilterProvider = [ filterFunction , [ geolocationContext , eventTypeContextGenerator ] ] ;
272+ const ruleSetProvider : contexts . RuleSetProvider = [ bothRuleSet , [ geolocationContext , eventTypeContextGenerator ] ] ;
273+ const globalContexts = contexts . globalContexts ( ) ;
274+
275+ globalContexts . addGlobalContexts ( [ filterProvider , ruleSetProvider ] ) ;
276+ globalContexts . removeGlobalContexts ( [ filterProvider ] ) ;
277+ t . deepEqual ( globalContexts . getConditionalProviders ( ) , [ ruleSetProvider ] ) ;
278+ } ) ;
279+
218280test ( 'Remove global contexts' , ( t ) => {
219281 const geolocationContext = {
220282 schema : 'iglu:com.snowplowanalytics.snowplow/geolocation_context/jsonschema/1-1-0' ,
0 commit comments