Skip to content

Instantly share code, notes, and snippets.

@haltcase
Created August 10, 2017 03:47
Show Gist options
  • Save haltcase/23280b08fbd2171c2072cdd50bfae262 to your computer and use it in GitHub Desktop.
Save haltcase/23280b08fbd2171c2072cdd50bfae262 to your computer and use it in GitHub Desktop.
// https://travis-ci.org/citycide/trilogy/jobs/262847143
// https://github.com/citycide/trilogy/blob/92bfe9e2c0767ab1f489b2cb66446d979e0c6726/tests/getter-setter.js
// results in: SyntaxError { 'Unexpected token (' }
test.before(async () => {
await db.model('people', {
name: {
type: String,
// renaming this to `get` prevents the error
getter: name => name.toUpperCase()
},
age: {
type: Number,
// renaming this to `set` prevents the error
setter: age => age + 1
}
})
return db.create('people', {
name: 'Joey Smith',
age: 20
})
})
@haltcase
Copy link
Author

haltcase commented Aug 10, 2017

Here's the compiled version of that piece that AVA caches and runs:

_ava2.default.before(_asyncToGenerator(function* () {
  yield db.model('people', {
    name: {
      type: String,
      getter: function (name) {
        return name.toUpperCase();
      }
    },
    age: {
      type: Number,
      setter: function (age) {
        return age + 1;
      }
    }
  });

  return db.create('people', {
    name: 'Joey Smith',
    age: 20
  });
}));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment