Skip to content

Commit 1425c47

Browse files
committed
test adapter, serializer
1 parent cbc8b7f commit 1425c47

5 files changed

Lines changed: 78 additions & 2 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { expect } from 'chai';
2+
import { describe, it } from 'mocha';
3+
import { setupTest } from 'ember-mocha';
4+
5+
describe('Unit | Adapter | rental', function() {
6+
setupTest('adapter:rental', {
7+
needs: ['service:store']
8+
});
9+
10+
// Replace this with your real tests.
11+
it('exists', function() {
12+
let adapter = this.subject();
13+
expect(adapter).to.be.ok;
14+
});
15+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { expect } from 'chai';
2+
import { describe, it } from 'mocha';
3+
import { setupTest } from 'ember-mocha';
4+
5+
describe('Unit | Adapter | rental', function() {
6+
setupTest();
7+
8+
// Replace this with your real tests.
9+
it('exists', function() {
10+
let adapter = this.owner.lookup('adapter:rental');
11+
expect(adapter).to.be.ok;
12+
});
13+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { expect } from 'chai';
2+
import { describe, it } from 'mocha';
3+
import { setupTest } from 'ember-mocha';
4+
5+
describe('Unit | Serializer | rental', function() {
6+
setupTest('serializer:rental', {
7+
needs: ['service:store']
8+
});
9+
10+
// Replace this with your real tests.
11+
it('exists', function() {
12+
let serializer = this.subject();
13+
14+
expect(serializer).to.be.ok;
15+
});
16+
17+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { expect } from 'chai';
2+
import { describe, it } from 'mocha';
3+
import { setupTest } from 'ember-mocha';
4+
5+
describe('Unit | Serializer | rental', function() {
6+
setupTest();
7+
8+
// Replace this with your real tests.
9+
it('exists', function() {
10+
let serializer = this.owner.lookup('service:store').serializerFor('rental');
11+
12+
expect(serializer).to.be.ok;
13+
});
14+
15+
});

fourteen-testing-api.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = function(file, api) {
5454
&& nodePath.expression.arguments.length === 2
5555
&& j.Literal.check(nodePath.expression.arguments[0])
5656
&& (
57-
/^(adapter|route|controller|service|serializer):/.test(nodePath.expression.arguments[0].value)
57+
/^(adapter|controller|route|service|serializer|transform):/.test(nodePath.expression.arguments[0].value)
5858
)
5959
return isSetupNeeds ;
6060
}
@@ -471,7 +471,7 @@ module.exports = function(file, api) {
471471
subjectType = split[0];
472472
subjectName = split[1];
473473
}
474-
let isSingletonSubject = ['model', 'component'].indexOf(subjectType) === -1;
474+
let isSingletonSubject = !['model', 'component', 'serializer'].includes(subjectType);
475475

476476
// if we don't have `options` and the type is a singleton type
477477
// use `this.owner.lookup(subject)`
@@ -485,6 +485,22 @@ module.exports = function(file, api) {
485485
[subject]
486486
)
487487
);
488+
} else if (subjectType === 'serializer') {
489+
p.replace(
490+
j.callExpression(
491+
j.memberExpression(
492+
j.callExpression(
493+
j.memberExpression(
494+
j.memberExpression(j.thisExpression(), j.identifier('owner')),
495+
j.identifier('lookup')
496+
),
497+
[j.literal('service:store')]
498+
),
499+
j.identifier('serializerFor')
500+
),
501+
[j.literal(subjectName)].filter(Boolean)
502+
)
503+
);
488504
} else if (subjectType === 'model') {
489505
p.replace(
490506
j.callExpression(

0 commit comments

Comments
 (0)