-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
84 lines (78 loc) · 2.74 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
describe('Assumptions', function() {
describe('Strings', function() {
it('Should interpolate as expected', function() {
var name = "Joe";
var result = `Hello ${name}!`
var expected = "Hello Joe!";
chai.assert.equal(result, expected);
});
});
});
describe('Github Blog', function() {
describe('loadIndex() function', function() {
it('should load the index from an existing blog', function(done) {
var blog = new GithubBlog('liberdade-organizacao/posts');
blog.loadIndex(function(index) {
chai.assert.notExists(index.error);
chai.assert.isAbove(index.length, 3);
for (var i = 0; i < index.length; i++) {
var post = index[i];
chai.assert.exists(post.link);
chai.assert.exists(post.title);
chai.assert.exists(post.description);
}
done();
});
});
it('should not load the index from an invalid blog', function(done) {
var notBlog = new GithubBlog('liberdade-organizacao/nothing-really');
notBlog.loadIndex(function(index) {
chai.assert.exists(index.error);
done();
});
});
});
describe('loadPost() function', function() {
it('should load the index from an existing blog', function(done) {
var blog = new GithubBlog('liberdade-organizacao/posts');
blog.loadPost('maker-101.md', function(post) {
chai.assert.notExists(post.error);
done();
});
});
it('should not load posts from an invalid blog', function(done) {
var notBlog = new GithubBlog('liberdade-organizacao/nothing-really');
notBlog.loadPost('nope.html', function(post) {
chai.assert.exists(post.error);
done();
});
});
});
});
describe("Gitlab Blog", function() {
describe("loadIndex() function", function() {
it("should load index from Gitlab blog", function(done) {
var blog = new GitlabBlog('liberdade-controle-automacao/posts');
blog.loadIndex(function(index) {
chai.assert.notExists(index.error);
chai.assert.isAbove(index.length, 3);
for (var i = 0; i < index.length; i++) {
var post = index[i];
chai.assert.exists(post.path);
chai.assert.exists(post.title);
chai.assert.exists(post.description);
}
done();
});
});
});
describe("loadPost() function", function() {
it("should load posts from Gitlab blog", function(done) {
var blog = new GitlabBlog('liberdade-controle-automacao/posts');
blog.loadPost('linux_terminal_programs.md', function(post) {
chai.assert.notExists(post.error);
done();
});
});
});
});