How to use the supertest.put function in supertest

To help you get started, we’ve selected a few supertest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github polonel / trudesk / test / api / users.js View on Github external
it('should update user preference', function (done) {
    var data = {
      preference: 'autoRefreshTicketGrid',
      value: false
    }

    request
      .put('/api/v1/users/trudesk/updatepreferences')
      .set('accesstoken', tdapikey)
      .set('Content-Type', 'application/json')
      .send(data)
      .set('Accept', 'application/json')
      .expect(function (res) {
        if (res.body.success !== true || res.body.user.preferences.autoRefreshTicketGrid !== false)
          throw new Error('Unable to update user')
      })
      .expect(200, done)
  })
github polonel / trudesk / test / api / users.js View on Github external
function (err, u) {
        if (err) return done(err)
        request
          .put('/api/v1/users/fake.user')
          .set('accesstoken', tdapikey)
          .set('Content-Type', 'application/json')
          .send(u)
          .set('Accept', 'application/json')
          .expect(function (res) {
            if (res.body.success !== true) throw new Error('Unable to update user')
          })
          .expect(200, done)
      }
    )
github polonel / trudesk / test / api / users.js View on Github external
userSchema.getUserByUsername('trudesk', function (err, user) {
        expect(err).to.not.exist
        var u = {
          aFullname: user.fullname,
          aEmail: user.email,
          aGrps: [group._id],
          saveGroups: true
        }

        request
          .put('/api/v1/users/trudesk')
          .set('accesstoken', tdapikey)
          .set('Content-Type', 'application/json')
          .send(u)
          .set('Accept', 'application/json')
          .expect(200, function () {
            groupSchema.getGroupByName('TEST', function (err, grp) {
              expect(err).to.not.exist

              expect(grp.isMember(user._id)).to.equal(true)

              done()
            })
          })
      })
    })
github DavidAnson / PassWeb / Test / RemoteStorage.js View on Github external
it("should fail to write a missing file name", function(done) {
    request
      .put("")
      .type("text")
      .send("")
      .expect(500, done);
  });
github DavidAnson / PassWeb / Test / RemoteStorage.js View on Github external
function bypassBlockNew(name, next) {
  if (BLOCK_NEW) {
    var params = {
      name: name,
      bypass: true
    };
    request
      .put("")
      .query(params)
      .expect("Content-Type", /^text\/plain/)
      .expect(200, "", next);
  } else {
    next();
  }
}
github DavidAnson / PassWeb / Test / RemoteStorage.js View on Github external
forFiles(goodFiles, function(file, next) {
        request
          .put("")
          .query(getCreateQueryParams(file.name, ".previous"))
          .type("text")
          .send(file.data)
          .expect("Content-Type", /^text\/plain/)
          .expect(200, "", next);
      }, done);
    };

supertest

SuperAgent driven library for testing HTTP servers

MIT
Latest version published 6 months ago

Package Health Score

84 / 100
Full package analysis