Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

Some tests need updating (Document.spec.js) #345

Open
HashEngineering opened this issue Sep 13, 2021 · 0 comments
Open

Some tests need updating (Document.spec.js) #345

HashEngineering opened this issue Sep 13, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@HashEngineering
Copy link

Expected Behavior

Tests should reflect current Document class.

This test is working with ownerId instead of dataContractId.

  describe('#getDataContractId', () => {
    it('should return $dataContractId', () => {
      expect(document.getOwnerId()).to.deep.equal(rawDocument.$ownerId);
    });
  });

This test is working with the obsolete Document.action:

  it('should create Document with undefined action and data if present', () => {
      const data = {
        test: 1,
      };

      rawDocument = {
        $type: 'test',
        ...data,
      };

      document = new Document(rawDocument, dataContract);

      expect(document.action).to.equal(undefined);
      expect(Document.prototype.setData).to.have.been.calledOnceWith(data);
    });

Current Behavior

Presumably tests pass.

Possible Solution

Use dataContractId instead of ownerId in this test.

  describe('#getDataContractId', () => {
    it('should return $dataContractId', () => {
      expect(document.getDataContractId()).to.deep.equal(rawDocument.$dataContractId);
    });
  });
 

Remove this test:
'should create Document with undefined action and data if present'

Steps to Reproduce (for bugs)

No tests were actually run. This is from static code analysis.

Context

I am looking at these unit tests to see what can be applied to the Android DPP library.

Your Environment

N/A

@HashEngineering HashEngineering added the bug Something isn't working label Sep 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant