-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
138 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,79 @@ | ||
module.exports = { | ||
parser: 'babel-eslint', | ||
root: true, | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
sourceType: 'module' | ||
}, | ||
plugins: [ | ||
'ember' | ||
], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:ember/recommended' | ||
], | ||
env: { | ||
browser: true | ||
ecmaVersion: 2017, | ||
sourceType: 'module', | ||
}, | ||
plugins: ['prettier', 'qunit', 'mocha'], | ||
extends: ['eslint:recommended', 'prettier'], | ||
rules: { | ||
'mocha/no-exclusive-tests': 'error', | ||
'prettier/prettier': 'error', | ||
|
||
'no-unused-vars': [ | ||
'error', | ||
{ | ||
args: 'none', | ||
}, | ||
], | ||
|
||
'no-cond-assign': ['error', 'except-parens'], | ||
eqeqeq: 'error', | ||
'no-eval': 'error', | ||
'new-cap': [ | ||
'error', | ||
{ | ||
capIsNew: false, | ||
}, | ||
], | ||
'no-caller': 'error', | ||
'no-irregular-whitespace': 'error', | ||
'no-undef': 'error', | ||
'no-eq-null': 'error', | ||
'no-console': 'error', // no longer recommended in eslint v6, this restores it | ||
|
||
// probably want to fix these new rules later in separate PR | ||
// Tracked in issue https://github.com/emberjs/data/issues/6405 | ||
'no-prototype-builtins': 'off', | ||
'require-atomic-updates': 'off', | ||
}, | ||
globals: { | ||
heimdall: true, | ||
Map: false, | ||
WeakMap: true, | ||
Set: true, | ||
}, | ||
env: { | ||
browser: true, | ||
node: false, | ||
}, | ||
overrides: [ | ||
// node files | ||
{ | ||
files: [ | ||
'.mocharc.js', | ||
'.eslintrc.js', | ||
'.prettierrc.js', | ||
'.template-lintrc.js', | ||
'ember-cli-build.js', | ||
'testem.js', | ||
'blueprints/*/index.js', | ||
'config/**/*.js', | ||
'lib/*/index.js', | ||
'server/**/*.js' | ||
'server/**/*.js', | ||
], | ||
parserOptions: { | ||
sourceType: 'script' | ||
sourceType: 'script', | ||
ecmaVersion: 2015, | ||
}, | ||
env: { | ||
browser: false, | ||
node: true | ||
node: true, | ||
es6: true, | ||
}, | ||
plugins: ['node'], | ||
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, { | ||
// add your custom rules and overrides for node files here | ||
|
||
// this can be removed once the following is fixed | ||
// https://github.com/mysticatea/eslint-plugin-node/issues/77 | ||
'node/no-unpublished-require': 'off' | ||
}) | ||
} | ||
] | ||
extends: 'plugin:node/recommended', | ||
}, | ||
], | ||
}; |
2 changes: 1 addition & 1 deletion
2
packages/-serializer-encapsulation-test-app/.template-lintrc.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
extends: 'recommended' | ||
extends: 'recommended', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/-serializer-encapsulation-test-app/ember-cli-build.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
packages/-serializer-encapsulation-test-app/tests/integration/requests-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import Model, { attr } from '@ember-data/model'; | ||
import Store from '@ember-data/store'; | ||
import JSONAPIAdapter from '@ember-data/adapter/json-api'; | ||
import EmberObject from '@ember/object'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
import { resolve } from 'rsvp'; | ||
|
||
module('integration/requests - running requests with minimum serializer', function(hooks) { | ||
setupTest(hooks); | ||
|
||
hooks.beforeEach(function(assert) { | ||
this.owner.register('service:store', Store); | ||
this.owner.register( | ||
'model:person', | ||
class Person extends Model { | ||
@attr name; | ||
} | ||
); | ||
}); | ||
|
||
test('findAll calls normalizeResponse', async function(assert) { | ||
let normalizeResponseCalled = 0; | ||
|
||
class TestMinimumSerializer extends EmberObject { | ||
normalizeResponse(store, schema, rawPayload, id, requestType) { | ||
normalizeResponseCalled++; | ||
assert.equal(requestType, 'findAll', 'expected method name is correct'); | ||
assert.deepEqual(rawPayload, { data: [] }); | ||
return { | ||
data: [ | ||
{ | ||
type: 'person', | ||
id: 'urn:person:1', | ||
attributes: { | ||
name: 'Chris', | ||
}, | ||
}, | ||
], | ||
}; | ||
} | ||
} | ||
this.owner.register('serializer:application', TestMinimumSerializer); | ||
|
||
class TestAdapter extends JSONAPIAdapter { | ||
defaultSerializer = 'application'; | ||
|
||
ajax(url, type) { | ||
return resolve({ data: [] }); | ||
} | ||
} | ||
this.owner.register('adapter:application', TestAdapter); | ||
|
||
const store = this.owner.lookup('service:store'); | ||
|
||
let response = await store.findAll('person'); | ||
|
||
assert.equal(normalizeResponseCalled, 1, 'normalizeResponse is called once'); | ||
assert.deepEqual(response.mapBy('id'), ['urn:person:1'], 'response is expected response'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.