diff --git a/internal_packages/theme-picker/lib/theme-option.jsx b/internal_packages/theme-picker/lib/theme-option.jsx index 79a776db4..f42aa8ec3 100644 --- a/internal_packages/theme-picker/lib/theme-option.jsx +++ b/internal_packages/theme-picker/lib/theme-option.jsx @@ -103,7 +103,6 @@ class ThemeOption extends React.Component { frameBorder="0" width="115px" height="70px" - flex="1" /> ); diff --git a/spec/stores/database-store-spec.coffee b/spec/stores/database-store-spec.coffee index 3bf6c1885..9c8f136a7 100644 --- a/spec/stores/database-store-spec.coffee +++ b/spec/stores/database-store-spec.coffee @@ -69,11 +69,11 @@ describe "DatabaseStore", -> # Actually returns correct sets for queries, since matchers can evaluate # themselves against models in memory spyOn(DatabaseStore, 'run').andCallFake (query) => - results = [] - for model in @models - found = _.every query._matchers, (matcher) -> + results = @models.filter((model) -> + query._matchers.every((matcher) -> matcher.evaluate(model) - results.push(model) if found + ) + ) Promise.resolve(results) describe "when given an array or input that is not an array", -> diff --git a/spec/stores/focused-perspective-store-spec.coffee b/spec/stores/focused-perspective-store-spec.coffee index f7493129e..ef1e522e5 100644 --- a/spec/stores/focused-perspective-store-spec.coffee +++ b/spec/stores/focused-perspective-store-spec.coffee @@ -8,7 +8,7 @@ CategoryStore = require '../../src/flux/stores/category-store' AccountStore = require '../../src/flux/stores/account-store' FocusedPerspectiveStore = require '../../src/flux/stores/focused-perspective-store' -fdescribe "FocusedPerspectiveStore", -> +describe "FocusedPerspectiveStore", -> beforeEach -> spyOn(FocusedPerspectiveStore, 'trigger') FocusedPerspectiveStore._perspective = null diff --git a/spec/tasks/send-draft-task-spec.es6 b/spec/tasks/send-draft-task-spec.es6 index 9cc1a8237..0f86b4c54 100644 --- a/spec/tasks/send-draft-task-spec.es6 +++ b/spec/tasks/send-draft-task-spec.es6 @@ -76,10 +76,10 @@ describe('SendDraftTask', function sendDraftTask() { from: [new Contact({email: TEST_ACCOUNT_EMAIL})], subject: 'New Draft', body: 'hello world', - to: { + to: [new Contact({ name: 'Dummy', email: 'dummythis.nylas.com', - }, + })], }; spyOn(NylasAPI, 'makeRequest').andCallFake((options) => { @@ -489,10 +489,10 @@ describe('SendDraftTask', function sendDraftTask() { subject: 'New Draft', draft: true, body: 'hello world', - to: { + to: [new Contact({ name: 'Dummy', email: 'dummythis.nylas.com', - }, + })], uploads: [], }); @@ -543,10 +543,10 @@ describe('SendDraftTask', function sendDraftTask() { subject: 'New Draft', draft: true, body: 'hello world', - to: { + to: [new Contact({ name: 'Dummy', email: 'dummythis.nylas.com', - }, + })], uploads: [], }); this.task.draft.applyPluginMetadata('open-tracking', true); diff --git a/spec/utils-spec.coffee b/spec/utils-spec.coffee index b4b9db216..1634231cb 100644 --- a/spec/utils-spec.coffee +++ b/spec/utils-spec.coffee @@ -38,9 +38,9 @@ describe 'Utils', -> expect(revived).toEqual([@testThread]) it "should re-inflate Models in places they're not explicitly declared types", -> - b = new JSONBlob({id: "local-ThreadsToProcess", json: [@testThread]}) + b = new JSONBlob({id: "ThreadsToProcess", json: [@testThread]}) jsonString = JSON.stringify(b, Utils.registeredObjectReplacer) - expectedString = '{"client_id":"local-ThreadsToProcess","server_id":"local-ThreadsToProcess","json":[{"client_id":"local-1","account_id":"1","metadata":[],"subject":"Test 1234","participants":[{"client_id":"local-a","account_id":"1","name":"Juan","email":"juan@nylas.com","thirdPartyData":{},"id":"local-a"},{"client_id":"local-b","account_id":"1","name":"Ben","email":"ben@nylas.com","thirdPartyData":{},"id":"local-b"}],"in_all_mail":true,"id":"local-1","__constructorName":"Thread"}],"id":"local-ThreadsToProcess","__constructorName":"JSONBlob"}' + expectedString = '{"client_id":"ThreadsToProcess","server_id":"ThreadsToProcess","json":[{"client_id":"local-1","account_id":"1","metadata":[],"subject":"Test 1234","participants":[{"client_id":"local-a","account_id":"1","name":"Juan","email":"juan@nylas.com","thirdPartyData":{},"id":"local-a"},{"client_id":"local-b","account_id":"1","name":"Ben","email":"ben@nylas.com","thirdPartyData":{},"id":"local-b"}],"in_all_mail":true,"id":"local-1","__constructorName":"Thread"}],"id":"ThreadsToProcess","__constructorName":"JSONBlob"}' expect(jsonString).toEqual(expectedString) revived = JSON.parse(jsonString, Utils.registeredObjectReviver) diff --git a/src/flux/attributes/attribute-collection.es6 b/src/flux/attributes/attribute-collection.es6 index e58c922fd..8a9c7decc 100644 --- a/src/flux/attributes/attribute-collection.es6 +++ b/src/flux/attributes/attribute-collection.es6 @@ -38,14 +38,20 @@ export default class AttributeCollection extends Attribute { } toJSON(vals) { - if (!vals) { return []; } + if (!vals) { + return []; + } + + if (!(vals instanceof Array)) { + throw new Error(`AttributeCollection::toJSON: ${this.modelKey} is not an array.`); + } const json = [] for (const val of vals) { if (!(val instanceof this.ItemClass)) { throw new Error(`AttributeCollection::toJSON: Value \`${val}\` in ${this.modelKey} is not an ${this.ItemClass.name}`); } - if (val.toJSON) { + if (val.toJSON !== undefined) { json.push(val.toJSON()); } else { json.push(val); @@ -58,7 +64,7 @@ export default class AttributeCollection extends Attribute { if (!json || !(json instanceof Array)) { return []; } - const objs = [] + const objs = []; for (const objJSON of json) { // Note: It's possible for a malformed API request to return an array diff --git a/src/flux/attributes/matcher.es6 b/src/flux/attributes/matcher.es6 index b4d1f36c7..a363cf45f 100644 --- a/src/flux/attributes/matcher.es6 +++ b/src/flux/attributes/matcher.es6 @@ -90,7 +90,7 @@ class Matcher { case '>=': return modelValue >= matcherValue case 'in': - return modelValue in matcherValue + return matcherValue.includes(modelValue) case 'contains': return modelArrayContainsValue(modelValue, matcherValue) case 'containsAny': @@ -98,7 +98,7 @@ class Matcher { case 'startsWith': return modelValue.startsWith(matcherValue) case 'like': - return modelValue.search(new RegExp(".*${matcherValue}.*", "gi")) >= 0 + return modelValue.search(new RegExp(`.*${matcherValue}.*`, "gi")) >= 0 default: throw new Error(`Matcher.evaulate() not sure how to evaluate ${this.attr.modelKey} with comparator ${this.comparator}`) }