Skip to content

Commit

Permalink
chore: update to latest eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Kirkpatrick authored and Tom Kirkpatrick committed May 4, 2017
1 parent af7be1a commit 518692f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lib/computed.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict'

const debug = require('debug')('loopback:mixin:computed')
const _ = require('lodash')
const Promise = require('bluebird')

module.exports = (Model, options) => {
'use strict'

// Trigger a warning and remove the property from the watchlist when one of
// the property is not found on the model or the defined callback is not found
_.mapKeys(options.properties, (callback, property) => {
Expand Down
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use strict'

const deprecate = require('depd')('loopback-ds-computed-mixin')
const computed = require('./computed')

module.exports = function mixin(app) {
'use strict'
app.loopback.modelBuilder.mixins.define = deprecate.function(app.loopback.modelBuilder.mixins.define,
'app.modelBuilder.mixins.define: Use mixinSources instead')
app.loopback.modelBuilder.mixins.define('Computed', computed)
Expand Down
24 changes: 12 additions & 12 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const loopback = require('loopback')
const lt = require('loopback-testing')
const chai = require('chai')
const expect = chai.expect
const { expect } = chai

global.Promise = require('bluebird')

Expand Down Expand Up @@ -51,33 +51,33 @@ describe('loopback computed property', function() {

before(function(done) {
new lt.TestDataBuilder()
.define('item1', Item, {
.define('itemOne', Item, {
name: 'Item 1',
status: 'archived',
})
.define('item2', Item, {
.define('itemTwo', Item, {
name: 'Item 2',
status: 'new',
})
.buildTo(this, done)
})

before(function() {
return Promise.join(Item.findById(this.item1.id), Item.findById(this.item2.id), (item1, item2) => {
this.item1 = item1
this.item2 = item2
return Promise.join(Item.findById(this.itemOne.id), Item.findById(this.itemTwo.id), (itemOne, itemTwo) => {
this.itemOne = itemOne
this.itemTwo = itemTwo
})
})

it('should set the model property to the value returned by the defined callback', function() {
expect(this.item1.requestedAt.toString()).to.equal(now.toString())
expect(this.item1.readonly).to.equal(true)
expect(this.item2.requestedAt.toString()).to.equal(now.toString())
expect(this.item2.readonly).to.equal(false)
expect(this.itemOne.requestedAt.toString()).to.equal(now.toString())
expect(this.itemOne.readonly).to.equal(true)
expect(this.itemTwo.requestedAt.toString()).to.equal(now.toString())
expect(this.itemTwo.readonly).to.equal(false)
})

it('should set the model property to the value resolved by the defined callback\'s promise', function() {
expect(this.item1.promised).to.equal('Item 1: As promised I get back to you!')
expect(this.item2.promised).to.equal('Item 2: As promised I get back to you!')
expect(this.itemOne.promised).to.equal('Item 1: As promised I get back to you!')
expect(this.itemTwo.promised).to.equal('Item 2: As promised I get back to you!')
})
})

0 comments on commit 518692f

Please sign in to comment.