Updated tests, fixes #166

This commit is contained in:
Wyatt Johnson
2016-12-13 15:15:08 -07:00
parent 5ed961a90a
commit ce17fa8773
4 changed files with 28 additions and 29 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
"sourceMaps": true,
"presets": [
"stage-0",
"es2015-minimal"
"es2015"
],
"plugins": [
["transform-decorators-legacy"],
-1
View File
@@ -86,7 +86,6 @@
"babel-plugin-transform-react-jsx": "^6.8.0",
"babel-polyfill": "^6.16.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-es2015-minimal": "^2.1.0",
"babel-preset-stage-0": "^6.16.0",
"chai": "^3.5.0",
"chai-http": "^3.0.0",
+3 -2
View File
@@ -24,11 +24,12 @@ describe('models.Asset', () => {
});
describe('#findByUrl', ()=> {
beforeEach(() => Asset.findOrCreateByUrl('http://test.com'));
it('should find an asset by a url', () => {
return Asset.findByUrl('http://test.com')
.then((asset) => {
expect(asset).to.have.property('url')
.and.to.equal('http://test.com');
expect(asset).to.have.property('url', 'http://test.com');
});
});
+24 -25
View File
@@ -95,12 +95,17 @@ describe('models.User', () => {
});
describe('#ban', () => {
let mockComment;
beforeEach(() => {
return Promise.all([
Comment.create([{body: 'testing the comment for that user if it is rejected.', id: mockUsers[0].id}])
return Comment.create([
{
body: 'testing the comment for that user if it is rejected.',
id: mockUsers[0].id
}
])
.then((comment) => {
.then(([comment]) => {
mockComment = comment;
});
});
@@ -109,11 +114,11 @@ describe('models.User', () => {
return User
.setStatus(mockUsers[0].id, 'banned', mockComment.id)
.then(() => {
User.findById(mockUsers[0].id)
.then((user) => {
expect(user).to.have.property('status')
.and.to.equal('banned');
});
return User.findById(mockUsers[0].id);
})
.then((user) => {
expect(user).to.have.property('status')
.and.to.equal('banned');
});
});
@@ -121,23 +126,20 @@ describe('models.User', () => {
return User
.setStatus(mockUsers[0].id, 'banned', mockComment.id)
.then(() => {
Comment.findById(mockComment.id)
.then((comment) => {
expect(comment).to.have.property('status')
.and.to.equal('rejected');
});
return Comment.findById(mockComment.id);
})
.then((comment) => {
expect(comment).to.have.property('status')
.and.to.equal('rejected');
});
});
it('should still disable and ban the user if there is no comment', () => {
return User
.setStatus(mockUsers[0].id, 'banned', '')
.then(() => {
User.findById(mockUsers[0].id)
.then((user) => {
expect(user).to.have.property('status')
.and.to.equal('banned');
});
.then(() => User.findById(mockUsers[0].id))
.then((user) => {
expect(user).to.have.property('status', 'banned');
});
});
});
@@ -156,12 +158,9 @@ describe('models.User', () => {
it('should set the status to active', () => {
return User
.setStatus(mockUsers[0].id, 'active', mockComment.id)
.then(() => {
User.findById(mockUsers[0].id)
.then((user) => {
expect(user).to.have.property('status')
.and.to.equal('active');
});
.then(() => User.findById(mockUsers[0].id))
.then((user) => {
expect(user).to.have.property('status', 'active');
});
});
});