Adding jsbeautifier grunt task

This commit is contained in:
Jacob Marttinen 2015-05-07 20:13:17 -04:00
parent 82cd4e5118
commit 9312aca8a1
5 changed files with 389 additions and 385 deletions

View file

@ -1,31 +1,28 @@
var validWebResponse = {
"d": {
"results": [
{
"__metadata": {
"uri": "https://api.datamarket.azure.com/Data.ashx/Bing/Search/Web?Query='xbox'&$skip=0&$top=1",
"type": "WebResult"
},
"ID": "26888c2a-d245-47dc-87de-dc3551249de7",
"Title": "Xbox | Games and Entertainment on All Your Devices",
"Description": "Experience the new generation of games and entertainment with Xbox. Play Xbox games and stream video on all your devices.",
"DisplayUrl": "www.xbox.com",
"Url": "http://www.xbox.com/"
},
{
"__metadata": {
"uri": "https://api.datamarket.azure.com/Data.ashx/Bing/Search/Web?Query='xbox'&$skip=1&$top=1",
"type": "WebResult"
},
"ID": "ff23e110-31c2-44f9-be21-f213bcd4c654",
"Title": "Amazon.com: Xbox - More Systems: Video Games: Games ...",
"Description": "Online shopping for Video Games from a great selection of Games, Hardware, Computer And Console Video Game Products & more at everyday low prices.",
"DisplayUrl": "www.amazon.com/Xbox-Games/b?ie=UTF8&node=537504",
"Url": "http://www.amazon.com/Xbox-Games/b?ie=UTF8&node=537504"
}
],
"__next": "https://api.datamarket.azure.com/Data.ashx/Bing/Search/Web?Query='xbox'&$skip=2"
}
"d": {
"results": [{
"__metadata": {
"uri": "https://api.datamarket.azure.com/Data.ashx/Bing/Search/Web?Query='xbox'&$skip=0&$top=1",
"type": "WebResult"
},
"ID": "26888c2a-d245-47dc-87de-dc3551249de7",
"Title": "Xbox | Games and Entertainment on All Your Devices",
"Description": "Experience the new generation of games and entertainment with Xbox. Play Xbox games and stream video on all your devices.",
"DisplayUrl": "www.xbox.com",
"Url": "http://www.xbox.com/"
}, {
"__metadata": {
"uri": "https://api.datamarket.azure.com/Data.ashx/Bing/Search/Web?Query='xbox'&$skip=1&$top=1",
"type": "WebResult"
},
"ID": "ff23e110-31c2-44f9-be21-f213bcd4c654",
"Title": "Amazon.com: Xbox - More Systems: Video Games: Games ...",
"Description": "Online shopping for Video Games from a great selection of Games, Hardware, Computer And Console Video Game Products & more at everyday low prices.",
"DisplayUrl": "www.amazon.com/Xbox-Games/b?ie=UTF8&node=537504",
"Url": "http://www.amazon.com/Xbox-Games/b?ie=UTF8&node=537504"
}],
"__next": "https://api.datamarket.azure.com/Data.ashx/Bing/Search/Web?Query='xbox'&$skip=2"
}
};
var should = require('should'),
@ -34,7 +31,7 @@ var should = require('should'),
request = require('request'),
bing = require('../lib/bing');
describe('Bing', function() {
describe('Bing', function () {
var server;
var app;
var port = 4321;
@ -43,13 +40,14 @@ describe('Bing', function() {
app = express();
server = http.createServer(app);
server.listen.apply(server, [port,
function(err, result) {
function (err, result) {
if (err) {
done(err);
} else {
done();
}
}]);
}
]);
});
after(function (done) {
@ -59,11 +57,14 @@ describe('Bing', function() {
done();
});
it('should cope with valid responses', function(done) {
it('should cope with valid responses', function (done) {
app.get('/hello/Web', function (req, res) {
res.status(200).send(JSON.stringify(validWebResponse));
});
var bingClient = bing({ rootUri: 'http://localhost:'+port+'/hello/', accKey: '123' });
var bingClient = bing({
rootUri: 'http://localhost:' + port + '/hello/',
accKey: '123'
});
bingClient.search('xbox', function (error, response, body) {
response.statusCode.should.eql(200);
body.should.eql(validWebResponse);
@ -71,13 +72,18 @@ describe('Bing', function() {
});
});
it('should cope with errors', function(done) {
it('should cope with errors', function (done) {
// No actual data on what the failure looks like.
var failure = { message: 'Failed request' };
var failure = {
message: 'Failed request'
};
app.get('/hello/Image', function (req, res) {
res.status(500).send(failure);
res.status(500).send(failure);
});
var bingClient = bing({
rootUri: 'http://localhost:' + port + '/hello/',
accKey: '123'
});
var bingClient = bing({ rootUri: 'http://localhost:'+port+'/hello/', accKey: '123' });
bingClient.images('xbox', function (error, response, body) {
response.statusCode.should.eql(500);
body.should.eql(JSON.stringify(failure));