1 | 'use strict'
|
2 |
|
3 | const analysedFileCollection = require('../analysed-files-collection')
|
4 |
|
5 | describe('mygreate', () => {
|
6 | const filesAnalyseResult = [
|
7 | { name: '20170914182600', locations: [ 'local' ] },
|
8 | { name: '20170914202400', locations: [ 'remote', 'local' ] },
|
9 | { name: '20170914205000', locations: [ 'remote' ] },
|
10 | { name: '20170914210300', locations: [ 'remote', 'local' ] },
|
11 | { name: '20170914213400', locations: [ 'local' ] },
|
12 | { name: '20170914213500', locations: [ 'local' ] }
|
13 | ]
|
14 |
|
15 | describe('analysed-files-collection(filesAnalyseResult Array[Object]): Object', () => {
|
16 | const collection = analysedFileCollection(filesAnalyseResult)
|
17 |
|
18 | describe('.all(): Array[Object]', () => {
|
19 | it('returns all analysed files\' results', () => {
|
20 | expect( collection.all() ).to.be.deep.equals(filesAnalyseResult)
|
21 | })
|
22 | })
|
23 |
|
24 | describe('.after(filename String): Promise<Array[Object]>', () => {
|
25 | it('returns all registered files after the given one', () => {
|
26 | return expect( collection.after('20170914182600') ).to.eventually.be.deep.equals([
|
27 | { name: '20170914202400', locations: [ 'remote', 'local' ] },
|
28 | { name: '20170914205000', locations: [ 'remote' ] },
|
29 | { name: '20170914210300', locations: [ 'remote', 'local' ] },
|
30 | { name: '20170914213400', locations: [ 'local' ] },
|
31 | { name: '20170914213500', locations: [ 'local' ] }
|
32 | ])
|
33 | })
|
34 |
|
35 | it('if the given file is the last one, an empty array will be returned', () => {
|
36 | return expect( collection.after('20170914213500') )
|
37 | .to.eventually.be.deep.equals([])
|
38 | })
|
39 | })
|
40 |
|
41 | describe('.before(filename String): Promise<Array[Object]>', () => {
|
42 | it('returns all registered files before the given one', () => {
|
43 | return expect( collection.before('20170914213500') ).to.eventually.be.deep.equals([
|
44 | { name: '20170914182600', locations: [ 'local' ] },
|
45 | { name: '20170914202400', locations: [ 'remote', 'local' ] },
|
46 | { name: '20170914205000', locations: [ 'remote' ] },
|
47 | { name: '20170914210300', locations: [ 'remote', 'local' ] },
|
48 | { name: '20170914213400', locations: [ 'local' ] },
|
49 | ])
|
50 | })
|
51 |
|
52 | it('if the given file is the first one, an empty array will be returned', () => {
|
53 | return expect( collection.before('20170914182600') )
|
54 | .to.eventually.be.deep.equals([])
|
55 | })
|
56 | })
|
57 |
|
58 | describe('.conflicting(): Promise<Array[Object]>', () => {
|
59 | it('returns all registered files which would cause conflicts', () => {
|
60 | return expect( collection.conflicting() ).to.eventually.be.deep.equals([
|
61 | { name: '20170914182600', locations: [ 'local' ] },
|
62 | { name: '20170914205000', locations: [ 'remote' ] }
|
63 | ])
|
64 | })
|
65 | })
|
66 |
|
67 | describe('.synced(): Promise<Array[Object]>', () => {
|
68 | it('returns all registered files which are sync from both local and remote', () => {
|
69 | return expect( collection.synced() ).to.eventually.be.deep.equals([
|
70 | { name: '20170914202400', locations: [ 'remote', 'local' ] },
|
71 | { name: '20170914210300', locations: [ 'remote', 'local' ] },
|
72 | ])
|
73 | })
|
74 | })
|
75 |
|
76 | describe('.unsynced(): Promise<Array[Object]>', () => {
|
77 | it('returns all registered files which are not sync from both local and remote', () => {
|
78 | return expect( collection.unsynced() ).to.eventually.be.deep.equals([
|
79 | { name: '20170914182600', locations: [ 'local' ] },
|
80 | { name: '20170914205000', locations: [ 'remote' ] },
|
81 | { name: '20170914213400', locations: [ 'local' ] },
|
82 | { name: '20170914213500', locations: [ 'local' ] }
|
83 | ])
|
84 | })
|
85 | })
|
86 | })
|
87 | })
|