Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #20 from clarkbw/babel-plugins
Browse files Browse the repository at this point in the history
Merging babel plugin updates
  • Loading branch information
clarkbw committed Mar 9, 2016
2 parents e74d91d + 573930a commit 86de76a
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 38 deletions.
14 changes: 6 additions & 8 deletions debug.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion debug.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions es6/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ import timestamp from './time-stamp';
export default deprecate((app) => {
app.loopback.modelBuilder.mixins.define('TimeStamp', timestamp);
}, 'DEPRECATED: Use mixinSources, see https://github.com/clarkbw/loopback-ds-timestamp-mixin#mixinsources');

module.exports = exports.default;
2 changes: 2 additions & 0 deletions es6/time-stamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ export default (Model, options = {}) => {
});

};

module.exports = exports.default;
16 changes: 9 additions & 7 deletions index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
"type": "git",
"url": "https://github.com/clarkbw/loopback-ds-timestamp-mixin.git"
},
"babel": {
"presets": [
"es2015"
],
"plugins": [
"transform-object-assign",
"transform-es2015-modules-commonjs"
]
},
"dependencies": {
"debug": "2.x"
},
Expand All @@ -31,7 +40,9 @@
},
"devDependencies": {
"babel-core": "latest",
"babel-plugin-transform-es2015-modules-commonjs": "^6.3.16",
"babel-plugin-transform-object-assign": "latest",
"babel-preset-es2015": "latest",
"coveralls": "latest",
"gulp": "latest",
"gulp-babel": "latest",
Expand Down
21 changes: 8 additions & 13 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ test('loopback datasource timestamps', function(tap) {
Widget.destroyAll(function() {
Widget.create({name: 'book 1', type: 'fiction'}, function(err, book) {
tt.error(err);
tt.ok(book.createdAt);
tt.type(book.createdAt, Date);
tt.end();
});
Expand All @@ -26,7 +25,7 @@ test('loopback datasource timestamps', function(tap) {
Widget.destroyAll(function() {
Widget.create({name:'book 1', type:'fiction'}, function(err, book) {
tt.error(err);
tt.ok(book.createdAt);
tt.type(book.createdAt, Date);
book.name = 'book inf';
book.save(function(err, b) {
tt.equal(book.createdAt, b.createdAt);
Expand All @@ -40,7 +39,7 @@ test('loopback datasource timestamps', function(tap) {
Widget.destroyAll(function() {
Widget.create({name:'book 1', type:'fiction'}, function(err, book) {
tt.error(err);
tt.ok(book.createdAt);
tt.type(book.createdAt, Date);
book.updateAttributes({ name:'book inf' }, function(err, b) {
tt.error(err);
tt.equal(book.createdAt, b.createdAt);
Expand All @@ -54,7 +53,7 @@ test('loopback datasource timestamps', function(tap) {
Widget.destroyAll(function() {
Widget.create({name:'book 1', type:'fiction'}, function(err, book) {
tt.error(err);
tt.ok(book.createdAt);
tt.type(book.createdAt, Date);
Widget.upsert({id: book.id, name:'book inf'}, function(err, b) {
tt.error(err);
tt.equal(book.createdAt.getTime(), b.createdAt.getTime());
Expand All @@ -69,7 +68,7 @@ test('loopback datasource timestamps', function(tap) {
Widget.destroyAll(function() {
Widget.create({name:'book 1', type:'fiction'}, function(err, book) {
tt.error(err);
tt.ok(book.createdAt);
tt.type(book.createdAt, Date);
Widget.updateAll({ type:'fiction' }, { type:'non-fiction' }, function(err) {
tt.error(err);
Widget.findById(book.id, function(err, b) {
Expand All @@ -92,7 +91,6 @@ test('loopback datasource timestamps', function(tap) {
Widget.destroyAll(function() {
Widget.create({name:'book 1', type:'fiction'}, function(err, book) {
tt.error(err);
tt.ok(book.updatedAt);
tt.type(book.updatedAt, Date);
tt.end();
});
Expand All @@ -104,14 +102,14 @@ test('loopback datasource timestamps', function(tap) {
Widget.destroyAll(function() {
Widget.create({name:'book 1', type:'fiction'}, function(err, book) {
tt.error(err);
tt.ok(book.updatedAt);
tt.type(book.createdAt, Date);
updatedAt = book.updatedAt;

// ensure we give enough time for the updatedAt value to be different
setTimeout(function pause() {
book.updateAttributes({ type:'historical-fiction' }, function(err, b) {
tt.error(err);
tt.ok(b.updatedAt);
tt.type(b.createdAt, Date);
tt.ok(b.updatedAt.getTime() > updatedAt.getTime());
tt.end();
});
Expand Down Expand Up @@ -178,10 +176,7 @@ test('loopback datasource timestamps', function(tap) {
tt.type(book.createdAt, 'undefined');
tt.type(book.updatedAt, 'undefined');

tt.ok(book.createdOn);
tt.type(book.createdOn, Date);

tt.ok(book.updatedOn);
tt.type(book.updatedOn, Date);

tt.end();
Expand Down Expand Up @@ -220,14 +215,14 @@ test('loopback datasource timestamps', function(tap) {
Widget.create({name:'book 1', type:'fiction'}, function(err, book1) {
tt.error(err);

tt.ok(book1.updatedAt);
tt.type(book1.updatedAt, Date);

var book = {id: book1.id, name:'book 2'};

Widget.updateOrCreate(book, {skipUpdatedAt: true}, function(err, book2) {
tt.error(err);

tt.ok(book2.updatedAt);
tt.type(book2.updatedAt, Date);
tt.equal(book1.updatedAt.getTime(), book2.updatedAt.getTime());
tt.end();
});
Expand Down
15 changes: 8 additions & 7 deletions time-stamp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion time-stamp.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 86de76a

Please sign in to comment.