mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-16 06:23:03 +00:00
reinstated select multiple behavior
This commit is contained in:
@@ -8,12 +8,25 @@ class Dog extends EquatableObject<Dog> {
|
||||
@excludeFromEquals
|
||||
public ballsCaught: number;
|
||||
|
||||
@fieldsForEquals('name', 'age')
|
||||
public owner: {
|
||||
name: string;
|
||||
age: number;
|
||||
favouriteFood: string;
|
||||
public owner: Owner;
|
||||
|
||||
@fieldsForEquals('name')
|
||||
public favouriteToy: { name: string, colour: string };
|
||||
}
|
||||
|
||||
class Owner extends EquatableObject<Owner> {
|
||||
@excludeFromEquals
|
||||
favouriteFood: string;
|
||||
|
||||
constructor(
|
||||
public name: string,
|
||||
public age: number,
|
||||
favouriteFood: string
|
||||
) {
|
||||
super();
|
||||
this.favouriteFood = favouriteFood;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fdescribe('equatable', () => {
|
||||
@@ -24,12 +37,14 @@ fdescribe('equatable', () => {
|
||||
dogRoger = new Dog();
|
||||
dogRoger.name = 'Roger';
|
||||
dogRoger.ballsCaught = 6;
|
||||
dogRoger.owner = { name: 'Tommy', age: 16, favouriteFood: 'spaghetti' };
|
||||
dogRoger.owner = new Owner('Tommy', 16, 'spaghetti');
|
||||
dogRoger.favouriteToy = { name: 'Twinky', colour: 'red' };
|
||||
|
||||
dogMissy = new Dog();
|
||||
dogMissy.name = 'Missy';
|
||||
dogMissy.ballsCaught = 9;
|
||||
dogMissy.owner = { name: 'Jenny', age: 29, favouriteFood: 'pizza' };
|
||||
dogMissy.owner = new Owner('Jenny', 29, 'pizza');
|
||||
dogRoger.favouriteToy = { name: 'McSqueak', colour: 'grey' };
|
||||
});
|
||||
|
||||
it('should return false when the other object is undefined', () => {
|
||||
@@ -66,5 +81,33 @@ fdescribe('equatable', () => {
|
||||
const isEqual = dogRoger.equals(copyOfDogRoger);
|
||||
expect(isEqual).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true when the other object\'s nested object only differs in fields that are marked as excludeFromEquals, when the nested object is not marked decorated with @fieldsForEquals', () => {
|
||||
const copyOfDogRoger = cloneDeep(dogRoger);
|
||||
copyOfDogRoger.owner.favouriteFood = 'Sushi';
|
||||
const isEqual = dogRoger.equals(copyOfDogRoger);
|
||||
expect(isEqual).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false when the other object\'s nested object differs in fields that are not marked as excludeFromEquals, when the nested object is not marked decorated with @fieldsForEquals', () => {
|
||||
const copyOfDogRoger = cloneDeep(dogRoger);
|
||||
copyOfDogRoger.owner.age = 36;
|
||||
const isEqual = dogRoger.equals(copyOfDogRoger);
|
||||
expect(isEqual).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true when the other object\'s nested object does not differ in fields that are listed inside the nested @fieldsForEquals decorator', () => {
|
||||
const copyOfDogRoger = cloneDeep(dogRoger);
|
||||
copyOfDogRoger.favouriteToy.colour = 'green';
|
||||
const isEqual = dogRoger.equals(copyOfDogRoger);
|
||||
expect(isEqual).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false when the other object\'s nested object differs in fields that are listed inside the nested @fieldsForEquals decorator', () => {
|
||||
const copyOfDogRoger = cloneDeep(dogRoger);
|
||||
copyOfDogRoger.favouriteToy.name = 'Mister Bone';
|
||||
const isEqual = dogRoger.equals(copyOfDogRoger);
|
||||
expect(isEqual).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user