Skip to content

Instantly share code, notes, and snippets.

@camshaft
Last active December 15, 2015 18:29
Show Gist options
  • Save camshaft/5304252 to your computer and use it in GitHub Desktop.
Save camshaft/5304252 to your computer and use it in GitHub Desktop.
hyperbridge design
describe("client", function(){
it("should get the root resource", function(done) {
client()
.end(function(err, root) {
if(err) return done(err);
should.exist(root.links);
done();
});
});
it("should follow a link", function(done) {
client()
.end(function(err, root) {
if(err) return done(err);
root
.follow("profile")
.end(function(err, profile) {
if(err) return done(err);
should.exist(profile.body);
done();
});
});
});
it("should submit a form", function(done){
client()
.end(function(err, root) {
if(err) return done(err);
root
.follow("profile")
.end(function(err, profile) {
if(err) return done(err);
profile
.submit("update")
.set({name: "Cameron"})
.end(function(err, profile) {
if(err) return done(err);
profile.body.name.should.eql("Cameron");
done();
});
});
});
});
it("should get the root with an access token", function(done){
var accessToken = "testing123";
client(accessToken)
.end(function(err, root) {
if(err) return done(err);
should.exist(root.links);
done();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment