@@ -29,124 +29,6 @@ describe("dataset resolvers", () => {
2929 expect ( dsId ) . toEqual ( expect . stringMatching ( / ^ d s [ 0 - 9 ] { 6 } $ / ) )
3030 } )
3131 } )
32- describe ( "snapshotCreationComparison()" , ( ) => {
33- it ( 'sorts array of objects by the "created" and "tag" properties' , ( ) => {
34- const testArray = [
35- { id : 2 , created : new Date ( "2018-11-20T00:05:43.473Z" ) , tag : "1.0.0" } ,
36- { id : 1 , created : new Date ( "2018-11-19T00:05:43.473Z" ) , tag : "1.0.1" } ,
37- { id : 3 , created : new Date ( "2018-11-23T00:05:43.473Z" ) , tag : "1.0.2" } ,
38- { id : 5 , created : new Date ( "2018-11-23T00:05:43.473Z" ) , tag : "1.0.10" } ,
39- { id : 4 , created : new Date ( "2018-11-23T00:05:43.473Z" ) , tag : "1.0.3" } ,
40- ]
41- const sorted = testArray . sort ( ds . snapshotCreationComparison )
42- expect ( sorted [ 0 ] . id ) . toBe ( 2 )
43- expect ( sorted [ 1 ] . id ) . toBe ( 1 )
44- expect ( sorted [ 2 ] . id ) . toBe ( 3 )
45- expect ( sorted [ 3 ] . id ) . toBe ( 4 )
46- expect ( sorted [ 4 ] . id ) . toBe ( 5 )
47- } )
48- it ( 'sorts array of objects by the "created" property as strings' , ( ) => {
49- const testArray = [
50- { id : 2 , created : "2018-11-20T00:05:43.473Z" , tag : "2.0.0" } ,
51- { id : 1 , created : "2018-11-19T00:05:43.473Z" , tag : "1.0.0" } ,
52- { id : 3 , created : "2018-11-23T00:05:43.473Z" , tag : "3.0.0" } ,
53- ]
54- const sorted = testArray . sort ( ds . snapshotCreationComparison )
55- expect ( sorted [ 0 ] . id ) . toBe ( 1 )
56- expect ( sorted [ 1 ] . id ) . toBe ( 2 )
57- expect ( sorted [ 2 ] . id ) . toBe ( 3 )
58- } )
59- it ( "sorts non-semver tags mixed with semver tags" , ( ) => {
60- const testArray = [
61- { id : 2 , created : new Date ( "2018-11-19T00:05:43.473Z" ) , tag : "1.0.2" } ,
62- {
63- id : 1 ,
64- created : new Date ( "2018-11-19T00:05:43.473Z" ) ,
65- tag : "57fed018cce88d000ac1757f" ,
66- } ,
67- { id : 3 , created : new Date ( "2018-11-19T00:05:43.473Z" ) , tag : "1.0.1" } ,
68- ]
69- const sorted = testArray . sort ( ds . snapshotCreationComparison )
70- expect ( sorted [ 0 ] . id ) . toBe ( 2 )
71- expect ( sorted [ 1 ] . id ) . toBe ( 1 )
72- expect ( sorted [ 2 ] . id ) . toBe ( 3 )
73- } )
74- it ( "sorts snapshots with only non-semver tags" , ( ) => {
75- const testArray = [
76- {
77- id : 2 ,
78- created : new Date ( "2018-11-19T00:05:43.473Z" ) ,
79- tag : "00001" ,
80- } ,
81- {
82- id : 1 ,
83- created : new Date ( "2018-11-19T00:05:43.473Z" ) ,
84- tag : "57fed018cce88d000ac1757f" ,
85- } ,
86- {
87- id : 3 ,
88- created : new Date ( "2018-11-19T00:05:43.473Z" ) ,
89- tag : "57fed018cce88d000ac1757f" ,
90- } ,
91- ]
92- const sorted = testArray . sort ( ds . snapshotCreationComparison )
93- expect ( sorted [ 0 ] . id ) . toBe ( 2 )
94- expect ( sorted [ 1 ] . id ) . toBe ( 1 )
95- expect ( sorted [ 2 ] . id ) . toBe ( 3 )
96- } )
97- it ( "sorts very similar creation times by semver order" , ( ) => {
98- const testSnapshots = [
99- {
100- id : "ds002680:1.0.0" ,
101- created : "2020-04-03T23:19:56.000Z" ,
102- tag : "1.0.0" ,
103- } ,
104- {
105- id : "ds002680:1.2.0" ,
106- created : "2021-10-19T16:26:43.000Z" ,
107- tag : "1.2.0" ,
108- } ,
109- {
110- id : "ds002680:1.1.0" ,
111- created : "2021-10-19T16:26:44.000Z" ,
112- tag : "1.1.0" ,
113- } ,
114- ]
115- const sorted = testSnapshots . sort ( ds . snapshotCreationComparison )
116- expect ( sorted [ 0 ] . id ) . toBe ( "ds002680:1.0.0" )
117- expect ( sorted [ 1 ] . id ) . toBe ( "ds002680:1.1.0" )
118- expect ( sorted [ 2 ] . id ) . toBe ( "ds002680:1.2.0" )
119- } )
120- it ( "sorts 000002 (legacy snapshots) before 1.0.1 (current format)" , ( ) => {
121- const testSnapshots = [
122- {
123- id : "ds000247:00002" ,
124- created : "2018-07-18T02:27:39.000Z" ,
125- tag : "00002" ,
126- } ,
127- {
128- id : "ds000247:00001" ,
129- created : "2018-07-18T02:35:37.000Z" ,
130- tag : "00001" ,
131- } ,
132- {
133- id : "ds000247:1.0.0" ,
134- created : "2021-07-05T15:58:18.000Z" ,
135- tag : "1.0.0" ,
136- } ,
137- {
138- id : "ds000247:1.0.1" ,
139- created : "2021-08-25T23:37:53.000Z" ,
140- tag : "1.0.1" ,
141- } ,
142- ]
143- const sorted = testSnapshots . sort ( ds . snapshotCreationComparison )
144- expect ( sorted [ 0 ] . id ) . toBe ( "ds000247:00002" )
145- expect ( sorted [ 1 ] . id ) . toBe ( "ds000247:00001" )
146- expect ( sorted [ 2 ] . id ) . toBe ( "ds000247:1.0.0" )
147- expect ( sorted [ 3 ] . id ) . toBe ( "ds000247:1.0.1" )
148- } )
149- } )
15032 describe ( "deleteFiles" , ( ) => {
15133 beforeEach ( ( ) => {
15234 request . post . mockClear ( )
0 commit comments