This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
81 changed files
with
4,520 additions
and
4,878 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,67 +1,62 @@ | ||
/* jshint expr:true */ | ||
import {expect} from 'chai'; | ||
import { | ||
describeModule, | ||
it | ||
} from 'ember-mocha'; | ||
import {describe, it} from 'mocha'; | ||
import {setupTest} from 'ember-mocha'; | ||
import Pretender from 'pretender'; | ||
|
||
describeModule( | ||
'adapter:tag', | ||
'Integration: Adapter: tag', | ||
{ | ||
describe('Integration: Adapter: tag', function () { | ||
setupTest('adapter:tag', { | ||
integration: true | ||
}, | ||
function () { | ||
let server, store; | ||
}); | ||
|
||
beforeEach(function () { | ||
store = this.container.lookup('service:store'); | ||
server = new Pretender(); | ||
}); | ||
let server, store; | ||
|
||
afterEach(function () { | ||
server.shutdown(); | ||
}); | ||
beforeEach(function () { | ||
store = this.container.lookup('service:store'); | ||
server = new Pretender(); | ||
}); | ||
|
||
it('loads tags from regular endpoint when all are fetched', function (done) { | ||
server.get('/ghost/api/v0.1/tags/', function () { | ||
return [200, {'Content-Type': 'application/json'}, JSON.stringify({tags: [ | ||
{ | ||
id: 1, | ||
name: 'Tag 1', | ||
slug: 'tag-1' | ||
}, { | ||
id: 2, | ||
name: 'Tag 2', | ||
slug: 'tag-2' | ||
} | ||
]})]; | ||
}); | ||
afterEach(function () { | ||
server.shutdown(); | ||
}); | ||
|
||
store.findAll('tag', {reload: true}).then((tags) => { | ||
expect(tags).to.be.ok; | ||
expect(tags.objectAtContent(0).get('name')).to.equal('Tag 1'); | ||
done(); | ||
}); | ||
it('loads tags from regular endpoint when all are fetched', function (done) { | ||
server.get('/ghost/api/v0.1/tags/', function () { | ||
return [200, {'Content-Type': 'application/json'}, JSON.stringify({tags: [ | ||
{ | ||
id: 1, | ||
name: 'Tag 1', | ||
slug: 'tag-1' | ||
}, { | ||
id: 2, | ||
name: 'Tag 2', | ||
slug: 'tag-2' | ||
} | ||
]})]; | ||
}); | ||
|
||
it('loads tag from slug endpoint when single tag is queried and slug is passed in', function (done) { | ||
server.get('/ghost/api/v0.1/tags/slug/tag-1/', function () { | ||
return [200, {'Content-Type': 'application/json'}, JSON.stringify({tags: [ | ||
{ | ||
id: 1, | ||
slug: 'tag-1', | ||
name: 'Tag 1' | ||
} | ||
]})]; | ||
}); | ||
store.findAll('tag', {reload: true}).then((tags) => { | ||
expect(tags).to.be.ok; | ||
expect(tags.objectAtContent(0).get('name')).to.equal('Tag 1'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('loads tag from slug endpoint when single tag is queried and slug is passed in', function (done) { | ||
server.get('/ghost/api/v0.1/tags/slug/tag-1/', function () { | ||
return [200, {'Content-Type': 'application/json'}, JSON.stringify({tags: [ | ||
{ | ||
id: 1, | ||
slug: 'tag-1', | ||
name: 'Tag 1' | ||
} | ||
]})]; | ||
}); | ||
|
||
store.queryRecord('tag', {slug: 'tag-1'}).then((tag) => { | ||
expect(tag).to.be.ok; | ||
expect(tag.get('name')).to.equal('Tag 1'); | ||
done(); | ||
}); | ||
store.queryRecord('tag', {slug: 'tag-1'}).then((tag) => { | ||
expect(tag).to.be.ok; | ||
expect(tag.get('name')).to.equal('Tag 1'); | ||
done(); | ||
}); | ||
} | ||
); | ||
}); | ||
}); |
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,92 +1,87 @@ | ||
/* jshint expr:true */ | ||
import {expect} from 'chai'; | ||
import { | ||
describeModule, | ||
it | ||
} from 'ember-mocha'; | ||
import {describe, it} from 'mocha'; | ||
import {setupTest} from 'ember-mocha'; | ||
import Pretender from 'pretender'; | ||
|
||
describeModule( | ||
'adapter:user', | ||
'Integration: Adapter: user', | ||
{ | ||
describe('Integration: Adapter: user', function () { | ||
setupTest('adapter:user', { | ||
integration: true | ||
}, | ||
function () { | ||
let server, store; | ||
}); | ||
|
||
beforeEach(function () { | ||
store = this.container.lookup('service:store'); | ||
server = new Pretender(); | ||
}); | ||
let server, store; | ||
|
||
afterEach(function () { | ||
server.shutdown(); | ||
}); | ||
beforeEach(function () { | ||
store = this.container.lookup('service:store'); | ||
server = new Pretender(); | ||
}); | ||
|
||
it('loads users from regular endpoint when all are fetched', function (done) { | ||
server.get('/ghost/api/v0.1/users/', function () { | ||
return [200, {'Content-Type': 'application/json'}, JSON.stringify({users: [ | ||
{ | ||
id: 1, | ||
name: 'User 1', | ||
slug: 'user-1' | ||
}, { | ||
id: 2, | ||
name: 'User 2', | ||
slug: 'user-2' | ||
} | ||
]})]; | ||
}); | ||
afterEach(function () { | ||
server.shutdown(); | ||
}); | ||
|
||
store.findAll('user', {reload: true}).then((users) => { | ||
expect(users).to.be.ok; | ||
expect(users.objectAtContent(0).get('name')).to.equal('User 1'); | ||
done(); | ||
}); | ||
it('loads users from regular endpoint when all are fetched', function (done) { | ||
server.get('/ghost/api/v0.1/users/', function () { | ||
return [200, {'Content-Type': 'application/json'}, JSON.stringify({users: [ | ||
{ | ||
id: 1, | ||
name: 'User 1', | ||
slug: 'user-1' | ||
}, { | ||
id: 2, | ||
name: 'User 2', | ||
slug: 'user-2' | ||
} | ||
]})]; | ||
}); | ||
|
||
it('loads user from slug endpoint when single user is queried and slug is passed in', function (done) { | ||
server.get('/ghost/api/v0.1/users/slug/user-1/', function () { | ||
return [200, {'Content-Type': 'application/json'}, JSON.stringify({users: [ | ||
{ | ||
id: 1, | ||
slug: 'user-1', | ||
name: 'User 1' | ||
} | ||
]})]; | ||
}); | ||
store.findAll('user', {reload: true}).then((users) => { | ||
expect(users).to.be.ok; | ||
expect(users.objectAtContent(0).get('name')).to.equal('User 1'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('loads user from slug endpoint when single user is queried and slug is passed in', function (done) { | ||
server.get('/ghost/api/v0.1/users/slug/user-1/', function () { | ||
return [200, {'Content-Type': 'application/json'}, JSON.stringify({users: [ | ||
{ | ||
id: 1, | ||
slug: 'user-1', | ||
name: 'User 1' | ||
} | ||
]})]; | ||
}); | ||
|
||
store.queryRecord('user', {slug: 'user-1'}).then((user) => { | ||
expect(user).to.be.ok; | ||
expect(user.get('name')).to.equal('User 1'); | ||
done(); | ||
}); | ||
store.queryRecord('user', {slug: 'user-1'}).then((user) => { | ||
expect(user).to.be.ok; | ||
expect(user.get('name')).to.equal('User 1'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('handles "include" parameter when querying single user via slug', function (done) { | ||
server.get('/ghost/api/v0.1/users/slug/user-1/', (request) => { | ||
let params = request.queryParams; | ||
expect(params.include, 'include query').to.equal('roles,count.posts'); | ||
it('handles "include" parameter when querying single user via slug', function (done) { | ||
server.get('/ghost/api/v0.1/users/slug/user-1/', (request) => { | ||
let params = request.queryParams; | ||
expect(params.include, 'include query').to.equal('roles,count.posts'); | ||
|
||
return [200, {'Content-Type': 'application/json'}, JSON.stringify({users: [ | ||
{ | ||
id: 1, | ||
slug: 'user-1', | ||
name: 'User 1', | ||
count: { | ||
posts: 5 | ||
} | ||
return [200, {'Content-Type': 'application/json'}, JSON.stringify({users: [ | ||
{ | ||
id: 1, | ||
slug: 'user-1', | ||
name: 'User 1', | ||
count: { | ||
posts: 5 | ||
} | ||
]})]; | ||
}); | ||
} | ||
]})]; | ||
}); | ||
|
||
store.queryRecord('user', {slug: 'user-1', include: 'count.posts'}).then((user) => { | ||
expect(user).to.be.ok; | ||
expect(user.get('name')).to.equal('User 1'); | ||
expect(user.get('count.posts')).to.equal(5); | ||
done(); | ||
}); | ||
store.queryRecord('user', {slug: 'user-1', include: 'count.posts'}).then((user) => { | ||
expect(user).to.be.ok; | ||
expect(user.get('name')).to.equal('User 1'); | ||
expect(user.get('count.posts')).to.equal(5); | ||
done(); | ||
}); | ||
} | ||
); | ||
}); | ||
}); |
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,46 +1,41 @@ | ||
/* jshint expr:true */ | ||
import {expect} from 'chai'; | ||
import { | ||
describeComponent, | ||
it | ||
} from 'ember-mocha'; | ||
import {describe, it} from 'mocha'; | ||
import {setupComponentTest} from 'ember-mocha'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
describeComponent( | ||
'gh-alert', | ||
'Integration: Component: gh-alert', | ||
{ | ||
describe('Integration: Component: gh-alert', function () { | ||
setupComponentTest('gh-alert', { | ||
integration: true | ||
}, | ||
function () { | ||
it('renders', function () { | ||
this.set('message', {message: 'Test message', type: 'success'}); | ||
}); | ||
|
||
this.render(hbs`{{gh-alert message=message}}`); | ||
it('renders', function () { | ||
this.set('message', {message: 'Test message', type: 'success'}); | ||
|
||
expect(this.$('article.gh-alert')).to.have.length(1); | ||
let $alert = this.$('.gh-alert'); | ||
this.render(hbs`{{gh-alert message=message}}`); | ||
|
||
expect($alert.text()).to.match(/Test message/); | ||
}); | ||
expect(this.$('article.gh-alert')).to.have.length(1); | ||
let $alert = this.$('.gh-alert'); | ||
|
||
it('maps message types to CSS classes', function () { | ||
this.set('message', {message: 'Test message', type: 'success'}); | ||
expect($alert.text()).to.match(/Test message/); | ||
}); | ||
|
||
this.render(hbs`{{gh-alert message=message}}`); | ||
let $alert = this.$('.gh-alert'); | ||
it('maps message types to CSS classes', function () { | ||
this.set('message', {message: 'Test message', type: 'success'}); | ||
|
||
this.set('message.type', 'success'); | ||
expect($alert.hasClass('gh-alert-green'), 'success class isn\'t green').to.be.true; | ||
this.render(hbs`{{gh-alert message=message}}`); | ||
let $alert = this.$('.gh-alert'); | ||
|
||
this.set('message.type', 'error'); | ||
expect($alert.hasClass('gh-alert-red'), 'success class isn\'t red').to.be.true; | ||
this.set('message.type', 'success'); | ||
expect($alert.hasClass('gh-alert-green'), 'success class isn\'t green').to.be.true; | ||
|
||
this.set('message.type', 'warn'); | ||
expect($alert.hasClass('gh-alert-yellow'), 'success class isn\'t yellow').to.be.true; | ||
this.set('message.type', 'error'); | ||
expect($alert.hasClass('gh-alert-red'), 'success class isn\'t red').to.be.true; | ||
|
||
this.set('message.type', 'info'); | ||
expect($alert.hasClass('gh-alert-blue'), 'success class isn\'t blue').to.be.true; | ||
}); | ||
} | ||
); | ||
this.set('message.type', 'warn'); | ||
expect($alert.hasClass('gh-alert-yellow'), 'success class isn\'t yellow').to.be.true; | ||
|
||
this.set('message.type', 'info'); | ||
expect($alert.hasClass('gh-alert-blue'), 'success class isn\'t blue').to.be.true; | ||
}); | ||
}); |
Oops, something went wrong.