@@ -821,6 +821,90 @@ module.exports.tests.priority = function(test, common) {
821821 } ) ;
822822 } ) ;
823823
824+ test ( 'real-world test New Zealand: empire vs country' , function ( t ) {
825+ var req = {
826+ clean : {
827+ text : 'New Zealand' ,
828+ size : 100
829+ }
830+ } ;
831+ var res = {
832+ data : [
833+ {
834+ 'name' : {
835+ 'default' : 'New Zealand'
836+ } ,
837+ 'source' : 'whosonfirst' ,
838+ 'source_id' : '136253053' ,
839+ 'layer' : 'empire' ,
840+ 'parent' : {
841+ 'empire_id' : 136253053
842+ } ,
843+ } ,
844+ {
845+ 'name' : {
846+ 'default' : [ 'New Zealand' , 'Aotearoa' ] ,
847+ } ,
848+ 'source' : 'whosonfirst' ,
849+ 'source_id' : '85633345' ,
850+ 'layer' : 'country' ,
851+ 'parent' : {
852+ 'continent_id' : 102191583 ,
853+ 'country_id' : 85633345
854+ } ,
855+ }
856+ ]
857+ } ;
858+
859+ dedupe ( req , res , function ( ) {
860+ t . equal ( res . data . length , 1 , 'results have fewer items than before' ) ;
861+ t . equal ( res . data [ 0 ] . layer , 'country' , 'empire result removed' ) ;
862+ t . end ( ) ;
863+ } ) ;
864+ } ) ;
865+
866+ test ( 'real-world test New Zealand: empire vs country - inverted order' , function ( t ) {
867+ var req = {
868+ clean : {
869+ text : 'New Zealand' ,
870+ size : 100
871+ }
872+ } ;
873+ var res = {
874+ data : [
875+ {
876+ 'name' : {
877+ 'default' : [ 'New Zealand' , 'Aotearoa' ] ,
878+ } ,
879+ 'source' : 'whosonfirst' ,
880+ 'source_id' : '85633345' ,
881+ 'layer' : 'country' ,
882+ 'parent' : {
883+ 'continent_id' : 102191583 ,
884+ 'country_id' : 85633345
885+ } ,
886+ } ,
887+ {
888+ 'name' : {
889+ 'default' : 'New Zealand'
890+ } ,
891+ 'source' : 'whosonfirst' ,
892+ 'source_id' : '136253053' ,
893+ 'layer' : 'empire' ,
894+ 'parent' : {
895+ 'empire_id' : 136253053
896+ } ,
897+ }
898+ ]
899+ } ;
900+
901+ dedupe ( req , res , function ( ) {
902+ t . equal ( res . data . length , 1 , 'results have fewer items than before' ) ;
903+ t . equal ( res . data [ 0 ] . layer , 'country' , 'empire result removed' ) ;
904+ t . end ( ) ;
905+ } ) ;
906+ } ) ;
907+
824908 test ( 'A->B B->C dependency graph' , function ( t ) {
825909 var req = {
826910 clean : {
0 commit comments