Beispiel #1
0
  @Test()
  @TestCase(TheRaven)
  public claimToHexFailIfChangedAttribute(work: Work) {
    // Changing any field should change the serialized too

    Expect(
      Serialization.claimToHex(
        editAttributes(work, {
          name: 'Nevermore',
        })
      )
    ).not.toBe(TheRavenHex)

    Expect(
      Serialization.claimToHex(
        editAttributes(work, {
          author: 'E.A.P.',
        })
      )
    ).not.toBe(TheRavenHex)

    Expect(
      Serialization.claimToHex(
        editAttributes(work, {
          dateCreated: new Date().toISOString(),
        })
      )
    ).not.toBe(TheRavenHex)
  }
Beispiel #2
0
 @Test()
 public mixerReturnsCorrectLength() {
   let mixer = new Mixer({secondsPerMix: 1}, {});
   let results = mixer.mix(44100);
   Expect(results.bufferSize).toBe(44100);
   Expect(results.output[0].length).toBe(44100); /* mixing is always in stereo */
   Expect(results.output[1].length).toBe(44100); /* mixing is always in stereo */
 }
  @AsyncTest()
  @TestCase(TheRaven.publicKey)
  @TestCase(TheMurdersInTheRueMorgue.publicKey)
  @TestCase(AStudyInScarlet.publicKey)
  async getWorksByPublicKeyShouldSucceed(publicKey: string) {
    const response = await this.client.getWorksByPublicKey(publicKey)

    Expect(response.status).toBe(200)
    Expect(response.ok).toBeTruthy()
  }
Beispiel #4
0
  @AsyncTest()
  async postWorkShouldSucceedWith202() {
    const claim = createClaim(Key1.privateKey, ClaimType.Work, {
      name: 'Name',
    })

    const postResponse = await this.client.postWork(claim)

    Expect(postResponse.ok).toBeTruthy()
    Expect(postResponse.status).toBe(202)
  }
  @AsyncTest()
  @TestCase(AStudyInScarlet.publicKey)
  async getWorksByACDPublicKeyShouldReturnOneElement(publicKey: string) {
    const response = await this.client.getWorksByPublicKey(publicKey)

    Expect(response.status).toBe(200)
    Expect(response.ok).toBeTruthy()

    const claims = await response.json()

    Expect(claims.length).toBe(1)
  }
  @AsyncTest()
  @TestCase(TheRaven.publicKey)
  async getWorksByEAPPublicKeyShouldReturnTwoElements(publicKey: string) {
    const response = await this.client.getWorksByPublicKey(publicKey)

    Expect(response.status).toBe(200)
    Expect(response.ok).toBeTruthy()

    const claims = await response.json()

    Expect(claims.length).toBe(2)
  }
Beispiel #7
0
  @AsyncTest()
  @TestCase('1234')
  async getWork404(id: string) {
    const response = await this.client.getWork(id)

    Expect(response.status).toBe(404)
    Expect(response.ok).not.toBeTruthy()

    const body = await response.text()

    Expect(body).toBe('')
  }
Beispiel #8
0
  @AsyncTest()
  @TestCase(TheRaven)
  @TestCase(TheMurdersInTheRueMorgue)
  @TestCase(AStudyInScarlet)
  async getWork200(claim: Claim) {
    const response = await this.client.getWork(claim.id)

    Expect(response.status).toBe(200)
    Expect(response.ok).toBeTruthy()

    const body = await response.json()

    Expect(body.id).toBe(claim.id)
    Expect(body.attributes.name).toBe(claim.attributes.name)
  }
  @AsyncTest()
  @TestCase(TheRaven.publicKey)
  @TestCase(TheMurdersInTheRueMorgue.publicKey)
  @TestCase(AStudyInScarlet.publicKey)
  async getWorksByPublicKeyShouldReturnClaimsMatchingPublicKey(publicKey: string) {
    const response = await this.client.getWorksByPublicKey(publicKey)

    Expect(response.status).toBe(200)
    Expect(response.ok).toBeTruthy()

    const claims = await response.json()
    const allElementsMatchPublicKey = !claims.find((claim: Claim) => claim.publicKey !== publicKey)

    Expect(allElementsMatchPublicKey).toBeTruthy()
  }
  @AsyncTest()
  @TestCase(TheRaven.publicKey)
  @TestCase(TheMurdersInTheRueMorgue.publicKey)
  @TestCase(AStudyInScarlet.publicKey)
  async getWorksByPublicKeyShouldReturnAnArray(publicKey: string) {
    const response = await this.client.getWorksByPublicKey(publicKey)

    Expect(response.status).toBe(200)
    Expect(response.ok).toBeTruthy()

    const claims = await response.json()

    Expect(claims).toBeDefined()
    Expect(Array.isArray(claims)).toBeTruthy()
  }