-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent_test.js
64 lines (56 loc) · 1.71 KB
/
event_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
const unitJS = require('unit.js')
const { ErrArguments } = require('./errors')
const { EventTypes, Event } = require('./event')
const VirtualPath = require('./virtualPath')
describe('Event Tests', () => {
it('EventTypes', () => {
unitJS.assert.equal('remove', EventTypes.Remove)
unitJS.assert.equal('write', EventTypes.Write)
unitJS.assert.equal('create', EventTypes.Create)
unitJS.assert.equal('rename', EventTypes.Rename)
unitJS.assert.equal('move', EventTypes.Move)
})
it('EventTransaction with valid arguments', () => {
const from = new VirtualPath('from', false),
to = new VirtualPath('to', true),
event = new Event(
EventTypes.Create,
from,
to
)
unitJS.assert.equal(EventTypes.Create, event.Type)
unitJS.assert.equal(from, event.FromPath)
unitJS.assert.equal(to, event.ToPath)
})
it('Should be ErrArguments EventTransaction is invalid type', () => {
const from = new VirtualPath('from', false),
to = new VirtualPath('to', true)
unitJS.error(() => {
new Event(
'invalid',
from,
to
)
}).is(ErrArguments)
})
it('EventTransaction String()', () => {
const from = new VirtualPath('from', false),
to = new VirtualPath('to', true),
event = new Event(
EventTypes.Create,
from,
to
)
unitJS.assert.equal('event from [create]', event.String())
})
it('EventTransaction Rename type String()', () => {
const from = new VirtualPath('from', false),
to = new VirtualPath('to', true),
event = new Event(
EventTypes.Rename,
from,
to
)
unitJS.assert.equal('event from -> to [rename]', event.String())
})
})