Skip to content

Commit 25c2f54

Browse files
committed
Add spec
1 parent c9e712b commit 25c2f54

File tree

4 files changed

+84
-4
lines changed

4 files changed

+84
-4
lines changed

spec/cson_generator_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
require 'spec_helper'
2+
require 'ever2boost/note'
3+
require 'ever2boost/cson_generator'
4+
5+
describe Ever2boost::CsonGenerator do
6+
let (:folder_hash) { '0123abcdef' }
7+
let (:title) { 'lorem' }
8+
let (:content) { "<en-note>lorem ipsum</en-note>" }
9+
let (:note) { Ever2boost::Note.new(title: title, content: content) }
10+
let (:md_note_content) { Ever2boost::MdConverter.convert(note.content) }
11+
let (:timestamp) { Ever2boost::CsonGenerator.timestamp }
12+
13+
let (:cson) {
14+
<<-EOS
15+
type: "MARKDOWN_NOTE"
16+
folder: "#{folder_hash}"
17+
title: "#{note.title}"
18+
content: '''
19+
# #{note.title}
20+
#{md_note_content}
21+
'''
22+
tags: []
23+
isStarred: false
24+
createdAt: "#{timestamp}"
25+
updatedAt: "#{timestamp}"
26+
EOS
27+
}
28+
29+
describe '#build' do
30+
it 'should return a cson' do
31+
expect(Ever2boost::CsonGenerator.build(folder_hash, note)).to eq(cson)
32+
end
33+
end
34+
end

spec/ever2boost_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,4 @@
44
it "has a version number" do
55
expect(Ever2boost::VERSION).not_to be nil
66
end
7-
8-
it "does something useful" do
9-
expect(false).to eq(true)
10-
end
117
end

spec/json_generator_spec.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
require 'spec_helper'
2+
3+
describe Ever2boost::JsonGenerator do
4+
let (:notelist1) { Ever2boost::NoteList.new(title: 'title1', guid: '012345abcdef')}
5+
let (:notelist2) { Ever2boost::NoteList.new(title: 'title2', guid: '0123456abcde')}
6+
let (:notebook_list) { [notelist1, notelist2] }
7+
let (:json) do
8+
<<-EOS
9+
{
10+
"folders": [
11+
{
12+
"key": "012345abcdef",
13+
"name": "title1",
14+
"color": "#E10051"
15+
},
16+
{
17+
"key": "0123456abcde",
18+
"name": "title2",
19+
"color": "#E10051"
20+
}
21+
],
22+
"version": "1.0"
23+
}
24+
EOS
25+
end
26+
27+
describe '#build' do
28+
before do
29+
notelist1.hash = '012345abcdef'
30+
notelist2.hash = '0123456abcde'
31+
notelist1.color = '#E10051'
32+
notelist2.color = '#E10051'
33+
end
34+
35+
it 'should return a json' do
36+
expect(Ever2boost::JsonGenerator.build(notebook_list)).to eq(json)
37+
end
38+
end
39+
end

spec/md_converter_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'spec_helper'
2+
3+
describe Ever2boost::MdConverter do
4+
let (:note_content) { "<en-note>lorem ipsum</en-note>" }
5+
6+
describe '#convert' do
7+
it 'should return md style string' do
8+
expect(Ever2boost::MdConverter.convert(note_content)).to eq("lorem ipsum")
9+
end
10+
end
11+
end

0 commit comments

Comments
 (0)