git.delta.rocks / unique-network / refs/commits / 8dce69d737f6

difftreelog

fix eslint errors

Daniel Shiposha2022-07-04parent: #0a7dd51.patch.diff
in: master

2 files changed

modifiedtests/src/rmrk/addTheme.test.tsdiffbeforeafterboth
before · tests/src/rmrk/addTheme.test.ts
1import {expect} from 'chai';2import {getApiConnection} from '../substrate/substrate-api';3import {createBase, addTheme} from './util/tx';4import {expectTxFailure} from './util/helpers';5import {getThemeNames} from './util/fetch';67describe('integration test: add Theme to Base', () => {8  let api: any;9  before(async () => { api = await getApiConnection(); });1011  const alice = '//Alice';12  const bob = '//Bob';1314  it('add default theme', async () => {15    const baseId = await createBase(api, alice, 'default-themed-base', 'DTBase', []);16    await addTheme(api, alice, baseId, {17      name: 'default',18      properties: [19        {20          key: 'some-key',21          value: 'some-key-value',22        },23        {24          key: 'another-key',25          value: 'another-key-value',26        },27      ],28    });29  });3031  it('add default theme and a custom one', async () => {32    const baseId = await createBase(api, alice, '2-themed-base', '2TBase', []);33    await addTheme(api, alice, baseId, {34      name: 'default',35      properties: [36        {37          key: 'default-key',38          value: 'default-key-value',39        },40      ],41    });42    await addTheme(api, alice, baseId, {43      name: 'custom-theme',44      properties: [45        {46          key: 'custom-key-0',47          value: 'custom-key-value-0',48        },49        {50          key: 'custom-key-1',51          value: 'custom-key-value-1',52        },53      ],54    });55  });5657  it('fetch filtered theme keys', async () => {58    const baseId = await createBase(api, alice, '2-themed-base', '2TBase', []);59    await addTheme(api, alice, baseId, {60      name: 'default',61      properties: [62        {63          key: 'first-key',64          value: 'first-key-value',65        },66        {67          key: 'second-key',68          value: 'second-key-value',69        },70      ],71    }, ['second-key']);72  });7374  it('fetch theme names', async() => {75    const baseId = await createBase(api, alice, '3-themed-base', '3TBase', []);76    const names = [77      'default',78      'first-theme',79      'second-theme',80    ];8182    for (var i = 0; i < names.length; i++) {83      await addTheme(api, alice, baseId, {name: names[i], properties: [{key: 'dummy', value: 'dummy'}]});84    }8586    const fetchedNames = await getThemeNames(api, baseId);8788    for (var i = 0; i < names.length; i++) {89      const isFound = fetchedNames.find((name) => name === names[i]) !== undefined;9091      expect(isFound, 'Error: invalid theme names').to.be.true;92    }93  });9495  it('[negative] unable to add theme to non-existing base', async () => {96    const maxBaseId = 0xFFFFFFFF;97    const tx = addTheme(api, alice, maxBaseId, {98      name: 'default',99      properties: [],100    });101102    await expectTxFailure(/rmrkEquip\.BaseDoesntExist/, tx);103  });104105  it('[negative] unable to add custom theme if no default theme', async () => {106    const baseId = await createBase(api, alice, 'no-default-themed-base', 'NDTBase', []);107    const tx = addTheme(api, alice, baseId, {108      name: 'custom-theme',109      properties: [],110    });111112    await expectTxFailure(/rmrkEquip\.NeedsDefaultThemeFirst/, tx);113  });114115  it('[negative] unable to add theme by a not-an-owner', async () => {116    const baseId = await createBase(api, alice, 'no-default-themed-base', 'NDTBase', []);117    const tx = addTheme(api, bob, baseId, {118      name: 'default',119      properties: [],120    });121122    await expectTxFailure(/rmrkEquip\.PermissionError/, tx);123  });124125  after(() => { api.disconnect(); });126});
after · tests/src/rmrk/addTheme.test.ts
1import {expect} from 'chai';2import {getApiConnection} from '../substrate/substrate-api';3import {createBase, addTheme} from './util/tx';4import {expectTxFailure} from './util/helpers';5import {getThemeNames} from './util/fetch';67describe('integration test: add Theme to Base', () => {8  let api: any;9  before(async () => { api = await getApiConnection(); });1011  const alice = '//Alice';12  const bob = '//Bob';1314  it('add default theme', async () => {15    const baseId = await createBase(api, alice, 'default-themed-base', 'DTBase', []);16    await addTheme(api, alice, baseId, {17      name: 'default',18      properties: [19        {20          key: 'some-key',21          value: 'some-key-value',22        },23        {24          key: 'another-key',25          value: 'another-key-value',26        },27      ],28    });29  });3031  it('add default theme and a custom one', async () => {32    const baseId = await createBase(api, alice, '2-themed-base', '2TBase', []);33    await addTheme(api, alice, baseId, {34      name: 'default',35      properties: [36        {37          key: 'default-key',38          value: 'default-key-value',39        },40      ],41    });42    await addTheme(api, alice, baseId, {43      name: 'custom-theme',44      properties: [45        {46          key: 'custom-key-0',47          value: 'custom-key-value-0',48        },49        {50          key: 'custom-key-1',51          value: 'custom-key-value-1',52        },53      ],54    });55  });5657  it('fetch filtered theme keys', async () => {58    const baseId = await createBase(api, alice, '2-themed-base', '2TBase', []);59    await addTheme(api, alice, baseId, {60      name: 'default',61      properties: [62        {63          key: 'first-key',64          value: 'first-key-value',65        },66        {67          key: 'second-key',68          value: 'second-key-value',69        },70      ],71    }, ['second-key']);72  });7374  it('fetch theme names', async() => {75    const baseId = await createBase(api, alice, '3-themed-base', '3TBase', []);76    const names = [77      'default',78      'first-theme',79      'second-theme',80    ];8182    for (let i = 0; i < names.length; i++) {83      await addTheme(api, alice, baseId, {name: names[i], properties: [{key: 'dummy', value: 'dummy'}]});84    }8586    const fetchedNames = await getThemeNames(api, baseId);8788    for (let i = 0; i < names.length; i++) {89      const isFound = fetchedNames.find((name) => name === names[i]) !== undefined;9091      expect(isFound, 'Error: invalid theme names').to.be.true;92    }93  });9495  it('[negative] unable to add theme to non-existing base', async () => {96    const maxBaseId = 0xFFFFFFFF;97    const tx = addTheme(api, alice, maxBaseId, {98      name: 'default',99      properties: [],100    });101102    await expectTxFailure(/rmrkEquip\.BaseDoesntExist/, tx);103  });104105  it('[negative] unable to add custom theme if no default theme', async () => {106    const baseId = await createBase(api, alice, 'no-default-themed-base', 'NDTBase', []);107    const tx = addTheme(api, alice, baseId, {108      name: 'custom-theme',109      properties: [],110    });111112    await expectTxFailure(/rmrkEquip\.NeedsDefaultThemeFirst/, tx);113  });114115  it('[negative] unable to add theme by a not-an-owner', async () => {116    const baseId = await createBase(api, alice, 'no-default-themed-base', 'NDTBase', []);117    const tx = addTheme(api, bob, baseId, {118      name: 'default',119      properties: [],120    });121122    await expectTxFailure(/rmrkEquip\.PermissionError/, tx);123  });124125  after(() => { api.disconnect(); });126});
modifiedtests/src/rmrk/util/tx.tsdiffbeforeafterboth
--- a/tests/src/rmrk/util/tx.ts
+++ b/tests/src/rmrk/util/tx.ts
@@ -296,24 +296,27 @@
       // try to find the matching resource from the query
       for (let j = 0; j < nftResources.length && !successFindingResource; j++) {
         const nftResourceData = nftResources[j].toHuman();
-        expect(nftResourceData.hasOwnProperty('resource'), `Error: Corrupted resource data on resource #${i}`);
+        expect(
+          Object.prototype.hasOwnProperty.call(nftResourceData, 'resource'),
+          `Error: Corrupted resource data on resource #${i}`,
+        ).to.be.true;
         const nftResource = nftResourceData.resource!;
                 type NftResourceKey = keyof typeof nftResource;
 
                 let typedResource = null;
                 let typedNftResource = null;
 
-                if (resource.basic && nftResource.hasOwnProperty('Basic')) {
+                if (resource.basic && Object.prototype.hasOwnProperty.call(nftResource, 'Basic')) {
                   typedResource = resource.basic!;
                   typedNftResource = nftResource['Basic' as NftResourceKey]!;
-                } else if (resource.composable && nftResource.hasOwnProperty('Composable')) {
+                } else if (resource.composable && Object.prototype.hasOwnProperty.call(nftResource, 'Composable')) {
                   typedResource = resource.composable!;
                   typedNftResource = nftResource['Composable' as NftResourceKey]! as any;
                   if (typedResource.parts != undefined && typedResource.parts.toString() != typedNftResource.parts.toString()
                         || typedResource.base != typedNftResource.base && typedResource.base != undefined) {
                     continue;
                   }
-                } else if (resource.slot && nftResource.hasOwnProperty('Slot')) {
+                } else if (resource.slot && Object.prototype.hasOwnProperty.call(nftResource, 'Slot')) {
                   typedResource = resource.slot!;
                   typedNftResource = nftResource['Slot' as NftResourceKey]! as any;
                   if (typedResource.slot != typedNftResource.slot && typedResource.slot != undefined 
@@ -854,7 +857,7 @@
   // console.log('>>> slot:', resource.resource.isSlot);
   const resourceJson = resource.resource.toHuman() as any;
 
-  expect(resourceJson.hasOwnProperty('Basic'), 'Error: Expected basic resource type')
+  expect(Object.prototype.hasOwnProperty.call(resourceJson, 'Basic'), 'Error: Expected basic resource type')
     .to.be.true;
 
   const recvBasicRes = resourceJson['Basic'];
@@ -912,7 +915,7 @@
   // console.log('>>> slot:', resource.resource.isSlot);
   const resourceJson = resource.resource.toHuman() as any;
 
-  expect(resourceJson.hasOwnProperty('Composable'), 'Error: Expected composable resource type')
+  expect(Object.prototype.hasOwnProperty.call(resourceJson, 'Composable'), 'Error: Expected composable resource type')
     .to.be.true;
 
   const recvComposableRes = resourceJson['Composable'];
@@ -974,7 +977,7 @@
   // console.log('>>> slot:', resource.resource.isSlot);
   const resourceJson = resource.resource.toHuman() as any;
 
-  expect(resourceJson.hasOwnProperty('Slot'), 'Error: Expected slot resource type')
+  expect(Object.prototype.hasOwnProperty.call(resourceJson, 'Slot'), 'Error: Expected slot resource type')
     .to.be.true;
 
   const recvSlotRes = resourceJson['Slot'];