Skip to content

Commit

Permalink
Update dependencies, implement test coverate, reorganise repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Kirkpatrick committed Nov 22, 2015
1 parent e868a4e commit 090d531
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 49 deletions.
4 changes: 3 additions & 1 deletion .gitignore
@@ -1 +1,3 @@
node_modules/
node_modules
coverage
.nyc_output
5 changes: 2 additions & 3 deletions .jscsrc
Expand Up @@ -16,9 +16,8 @@
"allowComments": true,
"allowRegex": true
},
"validateJSDoc": {
"checkParamNames": false,
"checkRedundantParams": false,
"jsDoc": {
"checkParamNames": true,
"requireParamTypes": true
}
}
26 changes: 26 additions & 0 deletions .jshintrc
@@ -0,0 +1,26 @@
{
"node": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"eqeqeq": true,
"eqnull": true,
"immed": true,
"indent": 2,
"latedef": "nofunc",
"newcap": true,
"nonew": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": false,
"trailing": true,
"sub": true,
"maxlen": 120,
"predef": ["-prompt"],
"browser": true,
"devel": true,
"mocha": true,
"expr": true
}
3 changes: 3 additions & 0 deletions README.md
@@ -1,6 +1,9 @@
READONLY
=============

[![Circle CI](https://circleci.com/gh/fullcube/loopback-ds-readonly-mixin.svg?style=svg)](https://circleci.com/gh/fullcube/loopback-ds-readonly-mixin) [![Coverage Status](https://coveralls.io/repos/fullcube/loopback-ds-readonly-mixin/badge.svg?branch=master&service=github)](https://coveralls.io/github/fullcube/loopback-ds-readonly-mixin?branch=master) [![Dependencies](http://img.shields.io/david/fullcube/loopback-ds-readonly-mixin.svg?style=flat)](https://david-dm.org/fullcube/loopback-ds-readonly-mixin)


This module is designed for the [Strongloop Loopback](https://github.com/strongloop/loopback) framework.
It provides a mixin that makes it possible to mark models or model properties as
Readonly. A Readonly property may not be written to directly when creating or
Expand Down
6 changes: 3 additions & 3 deletions circle.yml
@@ -1,3 +1,3 @@
machine:
node:
version: 0.10.22
test:
post:
- npm run coverage
File renamed without changes.
2 changes: 1 addition & 1 deletion read-only.js → lib/read-only.js
Expand Up @@ -39,4 +39,4 @@ module.exports = function(Model, options) {
Model.beforeRemote('updateAll', function(ctx, modelInstance, next) {
Model.stripReadOnlyProperties(ctx, modelInstance, next);
});
}
};
51 changes: 36 additions & 15 deletions package.json
@@ -1,21 +1,38 @@
{
"name": "loopback-ds-readonly-mixin",
"version": "1.0.0",
"description": "A mixin to enable loopback Model properties to be marked as readonly.",
"main": "index.js",
"scripts": {
"pretest": "jscs index.js && jshint index.js",
"test": "mocha --reporter spec test.js"
"version": "1.0.0",
"main": "./lib/index.js",
"author": "Tom Kirkpatrick @mrfelton",
"contributors": [
"Bram Borggreve @beeman",
"Matteo Padovano @mrbatista"
],
"repository": {
"type": "git",
"url": "https://github.com/fullcube/loopback-ds-readonly-mixin.git"
},
"keywords": [
"loopback",
"strongloop"
"strongloop",
"mixin"
],
"author": "Tom Kirkpatrick",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/fullcube/loopback-ds-readonly-mixin.git"
"bugs": {
"url": "https://github.com/fullcube/loopback-ds-readonly-mixin/issues"
},
"homepage": "https://github.com/fullcube/loopback-ds-readonly-mixin",
"files": [
"lib",
"test"
],
"scripts": {
"lint": "jscs lib && jshint lib",
"test": "nyc mocha -R spec --timeout 10000 test/test.js",
"test:watch": "npm run test -- -w",
"pretest": "npm run lint",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"outdated": "npm outdated --depth=0"
},
"dependencies": {
"debug": "2.x",
Expand All @@ -25,10 +42,14 @@
"loopback-datasource-juggler": ">=2.18.1"
},
"devDependencies": {
"loopback": "2.x",
"loopback-testing": "1.x",
"mocha": "2.x",
"jscs": "1.13.x",
"jshint": "2.7.x"
"bluebird": "latest",
"chai": "latest",
"coveralls": "^2.11.4",
"jscs": "latest",
"jshint": "latest",
"loopback": ">=2.22.0",
"loopback-testing": "1.2.0",
"mocha": "latest",
"nyc": "latest"
}
}
51 changes: 25 additions & 26 deletions test.js → test/test.js
@@ -1,14 +1,13 @@
/* jshint mocha: true */

var assert = require('assert');
var loopback = require('loopback');
var lt = require('loopback-testing');
var chai = require('chai');
var expect = chai.expect;

// Create a new loopback app.
var app = loopback();

// import our Readonly mixin.
require('./')(app);
require('../lib')(app);

describe('loopback datasource readonly property', function() {

Expand Down Expand Up @@ -48,9 +47,9 @@ describe('loopback datasource readonly property', function() {
lt.beforeEach.givenModel('product', {name:'some book', type:'book', status: 'pending'});

it('should save readonly properties on create.', function(done) {
assert.equal(this.product.name, 'some book');
assert.equal(this.product.type, 'book');
assert.equal(this.product.status, 'pending');
expect(this.product.name).to.equal('some book');
expect(this.product.type).to.equal('book');
expect(this.product.status).to.equal('pending');
done();
});

Expand All @@ -59,10 +58,10 @@ describe('loopback datasource readonly property', function() {
self.product.name = 'some other book';
self.product.status = 'disabled';
self.product.save(function(err, p) {
assert.ifError(err);
assert.equal(p.name, self.product.name);
assert.equal(p.type, self.product.type);
assert.equal(p.status, self.product.status);
expect(err).to.not.exist;
expect(p.name).to.equal(self.product.name);
expect(p.type).to.equal(self.product.type);
expect(p.status).to.equal(self.product.status);
done();
});
});
Expand All @@ -79,9 +78,9 @@ describe('loopback datasource readonly property', function() {
})
.expect(200)
.end(function(err, res) {
assert.ifError(err);
assert.equal(res.body.name, 'test product');
assert(!res.body.status);
expect(err).to.not.exist;
expect(res.body.name).to.equal('test product');
expect(res.body.status).to.not.exist;
done();
});
});
Expand All @@ -96,9 +95,9 @@ describe('loopback datasource readonly property', function() {
})
.expect(200)
.end(function(err, res) {
assert.ifError(err);
assert.equal(res.body.name, 'updated name');
assert.equal(res.body.status, 'pending');
expect(err).to.not.exist;
expect(res.body.name).to.equal('updated name');
expect(res.body.status).to.equal('pending');
done();
});
});
Expand All @@ -114,10 +113,10 @@ describe('loopback datasource readonly property', function() {
})
.expect(200)
.end(function(err, res) {
assert.ifError(err);
assert.equal(res.body.name, 'Tom (edited)');
assert.equal(res.body.status, 'disabled');
assert.equal(res.body.role, 'user');
expect(err).to.not.exist;
expect(res.body.name).to.equal('Tom (edited)');
expect(res.body.status).to.equal('disabled');
expect(res.body.role).to.equal('user');
done();
});
});
Expand Down Expand Up @@ -146,13 +145,13 @@ describe('loopback datasource readonly property', function() {
.set('Accept', 'application/json')
.expect(200)
.end(function(err, res) {
assert.ifError(err);
expect(err).to.not.exist;
self.Product.findById(self.book1.id, function(err, b1) {
assert.ifError(err);
assert.equal(b1.status, self.book1.status);
expect(err).to.not.exist;
expect(b1.status).to.equal(self.book1.status);
self.Product.findById(self.book2.id, function(err, b2) {
assert.ifError(err);
assert.equal(b2.status, self.book2.status);
expect(err).to.not.exist;
expect(b2.status).to.equal(self.book2.status);
done();
});
});
Expand Down

0 comments on commit 090d531

Please sign in to comment.