Update remote.js for vue-resource

master
Raymonzut 5 years ago
parent 307e71408b
commit a1a09a59ab
No known key found for this signature in database
GPG Key ID: 97CF2D8BE2C69FC7
  1. 15
      client/src/remote.js
  2. 25
      client/test/remote.js

@ -1,7 +1,12 @@
module.exports = {
postData: [
{ title: 'A walk in the park' },
{ title: 'Down the road', author: 'Alice' },
{ title: 'On a summer day', author: 'Bob' },
],
getPosts: function() {
this.$http
.get('http://localhost:5000/api/posts')
.then(res => {
this.posts = res.body
})
.catch(err => {
console.log(`Error: ${err}`)
})
},
}

@ -1,25 +0,0 @@
const assert = require('chai').assert
const remote = require('../src/remote')
describe('remote', () => {
const data = remote.postData
describe('postData', () => {
it('should return an array', () => {
assert.typeOf(data, 'array')
})
it('should not be empty', () => {
assert.isAtLeast(data.length, 1)
})
it('should contain objects', () => {
for (obj of data) {
assert.typeOf(obj, 'object')
}
})
it('should have objects with properties', () => {
for (obj of data) {
assert.isAtLeast(Object.keys(obj).length, 1)
}
})
})
})
Loading…
Cancel
Save