Giter Club home page Giter Club logo

Comments (4)

kashav avatar kashav commented on June 15, 2024

Started working on this, kashav@77c218a. Coverage is up to 81%.

screen shot 2016-04-10 at 3 54 34 am

Running into some problems with courses/filter when filtering for matched sections with that added matched_meeting_sections list. Any idea how to deal with that?

from cobalt.

qasim avatar qasim commented on June 15, 2024

You might be able to use a .expect()call like this:

.expect(res => {
  let expected = testData.filter(doc => {
    return /* doc filter here */
  })
  expected.matched_meeting_sections = []
  for (let i = 0; i < expected.meeting_sections.length, i++) {
    let expectedSections = expected.meeting_sections[i].filter(m => {
        return /* meeting section filter here */
    })
    if (expectedSections.length > 0) {
      expected.matched_meeting_sections.push(expectedSections)
    }
  }
  res.body = expected;
})

Haven't tested that though, so may need some tweaking. If it doesn't work at all because of ordering / some other obscure issue, you can hardcode the answer too since the test data will remain static.

from cobalt.

kashav avatar kashav commented on June 15, 2024

So it turns out the problem was that each meeting_sections and matched_meeting_sections object had a unique _id key. Neither your solution nor hardcoding worked cause of that.

I tried removing all _id keys when formatting the response:

for(let doc of docs) {
  for (let section of ['meeting_sections', 'matched_meeting_sections']) {
    if (doc.value.hasOwnProperty(section)) {
      for (let i = 0; i < doc.value[section].length; i++) {
        delete doc.value[section][i]._id
        for (let j = 0; j < doc.value[section][i].times.length; j++) {
          delete doc.value[section][i].times[j]._id
        }
      }
    }
  }
  if (doc.value.hasOwnProperty('__v')) {
    delete doc.value.__v
  }
  delete doc.value._id
  formattedDocs.push(doc.value)
}

Tests are running fine now, but coverage seems to be failing for every case that checks for a meeting_section.

Test:

test.cb('/filter?q=size:15', t => {
  request(cobalt.Server)
    .get('/1.0/courses/filter?q=size:15')
    .expect('Content-Type', /json/)
    .expect(200)
    .end((err, res) => {
      if (err) t.fail(err.message)
      t.pass()
      t.end()
    })
})

Response:

courses › test › /filter?q=size:15
  expected 200 "OK", got 500 "Internal Server Error"

from cobalt.

qasim avatar qasim commented on June 15, 2024

Hmm, that's not good. We shouldn't have _id at all. I'll look into this and get back to you.

from cobalt.

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.