Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
subclases is false by default and true if property datatype = wikibas…
Browse files Browse the repository at this point in the history
…e-item
  • Loading branch information
guergana committed Jan 13, 2021
1 parent 0be32fd commit 506e9b4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/QueryCondition.vue
Expand Up @@ -92,8 +92,12 @@ export default Vue.extend( {
this.$store.dispatch( 'unsetProperty', this.conditionIndex );
return;
}
this.$store.dispatch(
'updateProperty',
if ( selectedProperty.datatype === 'wikibase-item' ) {
this.$store.dispatch( 'setSubclasses', { conditionIndex: this.conditionIndex, subclasses: true } );
} else {
this.$store.dispatch( 'setSubclasses', { conditionIndex: this.conditionIndex, subclasses: false } );
}
this.$store.dispatch( 'updateProperty',
{ property: selectedProperty, conditionIndex: this.conditionIndex },
);
},
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/components/QueryCondition.spec.ts
Expand Up @@ -102,6 +102,26 @@ describe( 'QueryCondition.vue', () => {
expect( store.dispatch ).toHaveBeenCalledWith( 'updateValue', { value: userInput, conditionIndex } );
} );

it( 'set subclasses to true when property type is wikibase-item', async () => {

const property = { label: 'postal code', id: 'P123', datatype: 'wikibase-item' };
const propertyGetter = () => () => ( property );
const store = newStore( propertyGetter );
const conditionIndex = 0;
store.dispatch = jest.fn();
const wrapper = shallowMount( QueryCondition, {
store,
localVue,
propsData: {
'condition-index': 0,
},
} );

wrapper.findAllComponents( PropertyLookup ).at( conditionIndex ).vm.$emit( 'input', property );

expect( store.dispatch ).toHaveBeenCalledWith( 'setSubclasses', { subclasses: true, conditionIndex } );
} );

it( 'removes current row when the removeCondition button is clicked', async () => {
const store = newStore();
const conditionIndex = 0;
Expand Down

0 comments on commit 506e9b4

Please sign in to comment.