Skip to content

Commit

Permalink
fix: refactor test
Browse files Browse the repository at this point in the history
  • Loading branch information
sahar-fehri committed Jun 28, 2024
1 parent 36522e0 commit f1822c9
Showing 1 changed file with 21 additions and 92 deletions.
113 changes: 21 additions & 92 deletions packages/assets-controllers/src/assetsUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,11 @@ describe('assetsUtil', () => {
});

describe('hasNewCollectionFields', () => {
it('should return false if both objects do not have collection', () => {
const nftMetadata: NftMetadata = {
let baseNftMetadata: NftMetadata;
let baseNft: Nft;

beforeEach(() => {
baseNftMetadata = {
name: 'name',
image: 'image',
description: 'description',
Expand All @@ -176,94 +179,42 @@ describe('assetsUtil', () => {
animationOriginal: 'animationOriginal',
externalLink: 'externalLink',
};
const nft: Nft = {

baseNft = {
...baseNftMetadata,
address: 'address',
tokenId: '123',
name: 'name',
image: 'image',
description: 'description',
standard: 'standard',
backgroundColor: 'backgroundColor',
imagePreview: 'imagePreview',
imageThumbnail: 'imageThumbnail',
imageOriginal: 'imageOriginal',
animation: 'animation',
animationOriginal: 'animationOriginal',
externalLink: 'externalLink',
};
const different = assetsUtil.hasNewCollectionFields(nftMetadata, nft);
});
it('should return false if both objects do not have collection', () => {
const different = assetsUtil.hasNewCollectionFields(
baseNftMetadata,
baseNft,
);
expect(different).toBe(false);
});

it('should return false if existing object has collection and new nft metadata object does not', () => {
const nftMetadata: NftMetadata = {
name: 'name',
image: 'image',
description: 'description',
standard: 'standard',
backgroundColor: 'backgroundColor',
imagePreview: 'imagePreview',
imageThumbnail: 'imageThumbnail',
imageOriginal: 'imageOriginal',
animation: 'animation',
animationOriginal: 'animationOriginal',
externalLink: 'externalLink',
};
const nft: Nft = {
address: 'address',
tokenId: '123',
name: 'name',
image: 'image',
description: 'description',
standard: 'standard',
backgroundColor: 'backgroundColor',
imagePreview: 'imagePreview',
imageThumbnail: 'imageThumbnail',
imageOriginal: 'imageOriginal',
animation: 'animation',
animationOriginal: 'animationOriginal',
externalLink: 'externalLink',
const different = assetsUtil.hasNewCollectionFields(baseNftMetadata, {
...baseNft,
collection: {
id: 'address',
openseaVerificationStatus: 'verified',
},
};
const different = assetsUtil.hasNewCollectionFields(nftMetadata, nft);
});
expect(different).toBe(false);
});

it('should return false if both objects has the same keys', () => {
const nftMetadata: NftMetadata = {
name: 'name',
image: 'image',
description: 'description',
standard: 'standard',
backgroundColor: 'backgroundColor',
imagePreview: 'imagePreview',
imageThumbnail: 'imageThumbnail',
imageOriginal: 'imageOriginal',
animation: 'animation',
animationOriginal: 'animationOriginal',
externalLink: 'externalLink',
...baseNftMetadata,
collection: {
id: 'address',
openseaVerificationStatus: 'verified',
},
};
const nft: Nft = {
address: 'address',
tokenId: '123',
name: 'name',
image: 'image',
description: 'description',
standard: 'standard',
backgroundColor: 'backgroundColor',
imagePreview: 'imagePreview',
imageThumbnail: 'imageThumbnail',
imageOriginal: 'imageOriginal',
animation: 'animation',
animationOriginal: 'animationOriginal',
externalLink: 'externalLink',
...baseNft,
collection: {
id: 'address',
openseaVerificationStatus: 'verified',
Expand All @@ -275,17 +226,7 @@ describe('assetsUtil', () => {

it('should return true if new nft metadata object has keys that do not exist in the existing NFT', () => {
const nftMetadata: NftMetadata = {
name: 'name',
image: 'image',
description: 'description',
standard: 'standard',
backgroundColor: 'backgroundColor',
imagePreview: 'imagePreview',
imageThumbnail: 'imageThumbnail',
imageOriginal: 'imageOriginal',
animation: 'animation',
animationOriginal: 'animationOriginal',
externalLink: 'externalLink',
...baseNftMetadata,
collection: {
id: 'address',
openseaVerificationStatus: 'verified',
Expand All @@ -295,19 +236,7 @@ describe('assetsUtil', () => {
},
};
const nft: Nft = {
address: 'address',
tokenId: '123',
name: 'name',
image: 'image',
description: 'description',
standard: 'standard',
backgroundColor: 'backgroundColor',
imagePreview: 'imagePreview',
imageThumbnail: 'imageThumbnail',
imageOriginal: 'imageOriginal',
animation: 'animation',
animationOriginal: 'animationOriginal',
externalLink: 'externalLink',
...baseNft,
collection: {
id: 'address',
openseaVerificationStatus: 'verified',
Expand Down

0 comments on commit f1822c9

Please sign in to comment.