1local tasty = require 'tasty'
3local test = tasty.test_case
4local group = tasty.test_group
5local assert = tasty.assert
7local mediabag = require 'pandoc.mediabag'
11 test('insert adds an item to the mediabag', function ()
12 local fp = "media/hello.txt"
13 local mt = "text/plain"
14 local contents = "Hello, World!"
15 assert.are_same(mediabag.list(), {})
16 mediabag.insert(fp, mt, contents)
19 {{['path'] = fp, ['type'] = mt, ['length'] = 13}}
21 mediabag.empty() -- clean up
23 test('is idempotent', function ()
24 local fp = "media/hello.txt"
25 local mt = "text/plain"
26 local contents = "Hello, World!"
27 mediabag.insert(fp, mt, contents)
28 mediabag.insert(fp, mt, contents)
31 {{['path'] = fp, ['type'] = mt, ['length'] = 13}}
33 mediabag.empty() -- clean up
38 test('removes an item', function ()
39 assert.are_same(mediabag.list(), {})
40 mediabag.insert('test.html', 'text/html', '<aside>Who cares?</aside>')
41 mediabag.insert('test.css', 'text/plain', 'aside { color: red; }')
42 assert.are_equal(#mediabag.list(), 2)
43 mediabag.delete('test.html')
46 {{['path'] = 'test.css', ['type'] = 'text/plain', ['length'] = 21}}
48 mediabag.empty() -- clean up
53 test('iterates over all items', function ()
55 ['test.html'] = {'text/html', '<aside>Really?</aside>'},
56 ['test.css'] = {'text/plain', 'aside { color: red; }'},
57 ['test.js'] = {'application/javascript', 'alert("HI MOM!")'}
60 for name, v in pairs(input_items) do
61 mediabag.insert(name, v[1], v[2])
65 for fp, mt, c in mediabag.items() do
66 seen_items[fp] = {mt, c}
68 assert.are_same(seen_items, input_items)
69 mediabag.empty() -- clean up
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list