You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

todomvc-api

Package Overview
Dependencies
Maintainers
5
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

todomvc-api - npm Package Compare versions

Comparing version
0.1.0
to
0.1.1
+3
-1
.editorconfig

@@ -5,3 +5,2 @@ # editorconfig.org

[*]
indent_style = tab
end_of_line = lf

@@ -12,3 +11,6 @@ charset = utf-8

[*.js]
indent_style = tab
[*.md]
trim_trailing_whitespace = false
+55
-13
'use strict';
var async = require('async');
var request = require('request');

@@ -8,8 +9,8 @@ // imports the hooks module _injected_ by dredd.

var BASE_URL;
// DELETE /todos
// after: check that there is no more completed todos.
hooks.after('Todos > Todos Collection > Archive completed Todos', function (t, done) {
request.get({
uri: uri(t, 'todos')
}, function (err, res, body) {
request.get(uri(t, '/todos'), function (err, res, body) {
JSON.parse(body).forEach(function (todo) {

@@ -26,5 +27,5 @@ console.assert(!todo.complete);

request.post({
uri: uri(t, 'todos'),
uri: uri(t, '/todos'),
json: {
title: 'do that'
title: 'dredd'
}

@@ -37,2 +38,18 @@ }, function (err, res, todo) {

// PUT /todos/:id
// before: create a new todo.
// after: check that the todo is marked complete.
hooks.before('Todos > Todo > Update a Todo', function (t, done) {
request.post({
uri: uri(t, '/todos'),
json: {
title: 'dredd',
completed: false
}
}, function (err, res, todo) {
t.fullPath = '/todos/' + todo.id;
return done();
});
});
// DELETE /todos/:id

@@ -43,5 +60,5 @@ // before: create a new todo.

request.post({
uri: uri(t, 'todos'),
uri: uri(t, '/todos'),
json: {
title: 'delete me'
title: 'dredd'
}

@@ -55,5 +72,3 @@ }, function (err, res, todo) {

hooks.after('Todos > Todo > Delete a Todo', function (t, done) {
request.get({
uri: uri(t, t.fullPath)
}, function (err, res, body) {
request.get(uri(t, t.fullPath), function (err, res) {
console.assert(res.statusCode === 404);

@@ -64,9 +79,36 @@ return done();

// Remove all todos that were created by the tests.
hooks.afterAll(function (done) {
request.get(uri('/todos'), function (err, res, todos) {
if (!Array.isArray(todos)) {
try {
todos = JSON.parse(todos);
} catch (e) {
done(e);
}
}
var todosToDelete = todos.filter(function (todo) {
return todo.title === 'dredd';
});
async.parallel(todosToDelete.map(function (todo) {
return function (next) {
request.del(uri('/todos/' + todo.id), next);
};
}), done);
});
});
function uri(t, path) {
path = path || t;
if (!BASE_URL) {
BASE_URL = t;
}
return url.format({
protocol: 'http',
hostname: t.host,
port: t.port,
protocol: BASE_URL.protocol,
hostname: BASE_URL.host,
port: BASE_URL.port,
pathname: path
});
}
{
"name": "todomvc-api",
"description": "Validate your TodoMVC backend.",
"version": "0.1.0",
"version": "0.1.1",
"license": "Apache 2.0",
"dependencies": {
"async": "^0.9.0",
"dredd": "^0.3.9",

@@ -8,0 +9,0 @@ "request": "^2.45.0"

Sorry, the diff of this file is not supported yet