Coder Social home page Coder Social logo

Comments (7)

thetutlage avatar thetutlage commented on July 23, 2024

Please share the code you have a written and there is no version 4.0 for @japa/runner.

from core.

Arteneko avatar Arteneko commented on July 23, 2024
test.group('computeMovementSummary()', async () => {
  const counterparties = await Promise.all([
    'input',
    'pool',
    'output',
  ].map((type: CounterpartyType) => CounterpartiesFactory.merge({ type }).create()))
  const [input$$, pool$$, output$$] = counterparties;

  const movements: { origin: string; destination: string; amount: number; }[] = [
    { origin: pool$$.id, destination: output$$.id, amount: 1000 },
    { origin: input$$.id, destination: pool$$.id, amount: 1000 },
  ]

  test.group('with only one movement', () => {
    const summary = computeMovementSummary([movements[0]], counterparties)

    test('it should return the destination as pivot', (assert) => {
      assert.equal(summary.pivot.id, pool$$.id)
    })

    test('it should return the base amount', (assert) => {
      assert.equal(summary.amount, movements[0].amount)
    })
  })

  test.group('with multiple movements (case: a reimbursement)', () => {
    const summary = computeMovementSummary(movements, counterparties)

    test('it should return the first destination as pivot', (assert) => {
      assert.equal(summary.pivot.id, pool$$.id)
    })

    test('it should return a nil amount', (assert) => {
      assert.equal(summary.amount, 0)
    })
  })
})

This is the code "in natural implementation way", for the two examples, here's what I tried.

// Property 'with' does not exist on type 'RunnerTest'.ts(2339)
test('it should return the first destination as pivot', (assert, c) => {
  assert.equal(summary.pivot.id, c[1].id)
}).with(async () => await Promise.all([
    'input',
    'pool',
    'output',
  ].map((type: CounterpartyType) => CounterpartiesFactory.merge({ type }).create())))
// Expected 2 arguments, but got 1.ts(2554)
test('it should return the first destination as pivot')
.with(async () => await Promise.all([
    'input',
    'pool',
    'output',
  ].map((type: CounterpartyType) => CounterpartiesFactory.merge({ type }).create())))

from core.

thetutlage avatar thetutlage commented on July 23, 2024

What version of @japa/runner are you using?

from core.

Arteneko avatar Arteneko commented on July 23, 2024

I didn't have @japa/runner installed (since it wasn't mentioned in adonis' testing recipe), but after installing it, it's using the latest, so @japa/[email protected]

from core.

thetutlage avatar thetutlage commented on July 23, 2024

Then please follow the upgrade docs first. https://japa.dev/releases/version-5

from core.

Arteneko avatar Arteneko commented on July 23, 2024

That... could be useful to mention it on Adonis, at least as a content warning for an obsolete guide...

from core.

thetutlage avatar thetutlage commented on July 23, 2024

Agree. The cookbooks needs an updated. I will look into it :). Closing this issue for now

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.