Skip to content

Instantly share code, notes, and snippets.

@yamikuronue
Last active December 10, 2015 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yamikuronue/60dcf7c366d99061536c to your computer and use it in GitHub Desktop.
Save yamikuronue/60dcf7c366d99061536c to your computer and use it in GitHub Desktop.
it('should update a board on PUT', (done) => {
dao.addBoard({
ID: '1111',
Name: 'test board',
Adult: false,
BoardMasters: null,
Tags: [],
IC: null
}).then((data) => {
const formData = {
Name: 'test board edited!',
Adult: false,
BoardMasters: null,
Tags: [],
IC: null
};
const req = http.request({
host: 'localhost',
port: '8080',
path: '/api/board/1111',
method: 'PUT',
headers: {
'Content-type': 'application/json'
}
});
req.write(`${JSON.stringify(formData)}\n`);
req.end();
req.on('response', (response) => {
assert.equal(200, response.statusCode, 'Status code should be 200 OK');
done();
});
}).catch((err) => {
assert.fail("no error", "error", "Error occurred: " + err);
done();
})
});
@AccaliaDeElementia
Copy link

try this to see if the catch fires correctly?

it('should update a board on PUT', (done) => {

    dao.addBoard({
        ID: '1111',
        Name: 'test board',
        Adult: false,
        BoardMasters: null,
        Tags: [],
        IC: null
    }).then((data) => {
        const formData = {
            Name: 'test board edited!',
            Adult: false,
            BoardMasters: null,
            Tags: [],
            IC: null
        };

        const req = http.request({
            host: 'localhost',
            port: '8080',
            path: '/api/board/1111',
            method: 'PUT',
            headers: {
                'Content-type': 'application/json'
            }
        });
        req.write(`${JSON.stringify(formData)}\n`);
        req.end();

        req.on('response', (response) => {
            assert.equal(200, response.statusCode, 'Status code should be 200 OK');
            done();
        });
    }, (err) => {
        assert.fail("no error", "error", "Error occurred: " + err);
        done();
    })

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment