@@ -2,30 +2,30 @@ local M = {}
2
2
local stub = require (" luassert.stub" )
3
3
local spy = require (" luassert.spy" )
4
4
local match = require (" luassert.match" )
5
- local article = require (" forem -nvim.article" )
5
+ local article = require (" devto -nvim.article" )
6
6
local busted = require (" plenary.busted" )
7
7
local describe = busted .describe
8
8
local before_each = busted .before_each
9
9
local after_each = busted .after_each
10
10
local it = busted .it
11
11
12
12
local function mock_internal (module )
13
- _G .package .loaded [" forem -nvim" ] = nil
13
+ _G .package .loaded [" devto -nvim" ] = nil
14
14
_G .package .loaded [module ] = nil
15
15
local mocked = require (module )
16
16
return mocked
17
17
end
18
18
19
19
describe (
20
- " Forem .nvim" ,
20
+ " devto .nvim" ,
21
21
function ()
22
- local forem_nvim
22
+ local devto_nvim
23
23
local snapshot
24
24
25
25
before_each (function ()
26
- vim .env .FOREM_API_KEY = " foo"
27
- _G .package .loaded [" forem -nvim" ] = nil
28
- forem_nvim = require (" forem -nvim" )
26
+ vim .env .devto_API_KEY = " foo"
27
+ _G .package .loaded [" devto -nvim" ] = nil
28
+ devto_nvim = require (" devto -nvim" )
29
29
snapshot = assert :snapshot ()
30
30
end )
31
31
@@ -36,21 +36,21 @@ describe(
36
36
it (
37
37
" should show a notification when no api key is set" ,
38
38
function ()
39
- vim .env .FOREM_API_KEY = nil
39
+ vim .env .devto_API_KEY = nil
40
40
stub .new (vim , " notify" )
41
- forem_nvim .my_articles ()
41
+ devto_nvim .my_articles ()
42
42
assert .stub (vim .notify ).was .called ()
43
43
end
44
44
)
45
45
46
46
it (
47
47
" should call the api to get the articles" ,
48
48
function ()
49
- local mocked_api = mock_internal (" forem -nvim.api" )
49
+ local mocked_api = mock_internal (" devto -nvim.api" )
50
50
mocked_api .my_articles = spy .new (function ()
51
51
end )
52
- local forem_nvim_mocked = require (" forem -nvim" )
53
- forem_nvim_mocked .my_articles ()
52
+ local devto_nvim_mocked = require (" devto -nvim" )
53
+ devto_nvim_mocked .my_articles ()
54
54
assert .spy (mocked_api .my_articles ).was .called ()
55
55
end
56
56
)
@@ -60,21 +60,21 @@ describe(
60
60
function ()
61
61
local input = stub .new (vim .fn , " input" )
62
62
input .returns (" Title" )
63
- local api = mock_internal (" forem -nvim.api" )
63
+ local api = mock_internal (" devto -nvim.api" )
64
64
local api_new_article = stub .new (api , " new_article" )
65
65
local new_article = {
66
66
id = 1 ,
67
67
body_markdown = article .get_template (" Title" )
68
68
}
69
69
api_new_article .returns ({ status = 201 , body = new_article })
70
- local buffer = mock_internal (" forem -nvim.buffer" )
70
+ local buffer = mock_internal (" devto -nvim.buffer" )
71
71
local buffer_open_my_article = spy .on (buffer , " open_my_article" )
72
- local forem_nvim_mocked = require (" forem -nvim" )
73
- forem_nvim_mocked .new_article ()
72
+ local devto_nvim_mocked = require (" devto -nvim" )
73
+ devto_nvim_mocked .new_article ()
74
74
assert .stub (api_new_article ).was .called_with (" Title" )
75
75
assert .spy (buffer_open_my_article ).was_called_with (match .is_same (new_article ))
76
76
assert .are .same (
77
- " forem ://my-article/" .. tostring (new_article .id ),
77
+ " devto ://my-article/" .. tostring (new_article .id ),
78
78
vim .api .nvim_buf_get_name (0 )
79
79
)
80
80
local buffer_content = vim .api .nvim_buf_get_lines (0 , 0 , - 1 , true )
0 commit comments