-
Notifications
You must be signed in to change notification settings - Fork 168
/
server-test.js
1456 lines (1196 loc) · 34.8 KB
/
server-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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import {
Server,
Model,
Factory,
belongsTo,
hasMany,
trait,
association
} from "@lib";
describe("Unit | Server", function() {
test("it can be instantiated", () => {
let server = new Server({ environment: "test" });
expect(server).toBeTruthy();
server.shutdown();
});
test("routes return pretender handler", () => {
let server = new Server({ environment: "test" });
let handler = server.post("foo");
expect(handler.numberOfCalls).toBe(0);
server.shutdown();
});
test("it runs the default scenario in non-test environments", () => {
expect.assertions(1);
let server = new Server({
environment: "development",
scenarios: {
default() {
expect(true).toBeTruthy();
}
}
});
server.shutdown();
});
});
describe("Unit | Server #loadConfig", function() {
test("forces timing to 0 in test environment", () => {
let server = new Server({ environment: "test" });
server.loadConfig(function() {
this.timing = 50;
});
expect(server.timing).toEqual(0);
server.shutdown();
});
test("doesn't modify user's timing config in other environments", () => {
let server = new Server({ environment: "blah" });
server.loadConfig(function() {
this.timing = 50;
});
expect(server.timing).toEqual(50);
server.shutdown();
});
});
describe("Unit | Server #db", function() {
test("its db is isolated across instances", () => {
let server1 = new Server({ environment: "test" });
server1.db.createCollection("contacts");
server1.db.contacts.insert({ name: "Sam" });
server1.shutdown();
let server2 = new Server({ environment: "test" });
expect(server2.contacts).toBeUndefined();
server2.shutdown();
});
});
describe("Unit | Server #create", function() {
test("create fails when no factories or models are registered", () => {
let server = new Server({ environment: "test" });
expect(function() {
server.create("contact");
}).toThrow(
"Mirage: You called server.create('contact') but no model or factory was found. Make sure you're passing in the singularized version of the model or factory name."
);
server.shutdown();
});
test("create fails when an expected factory isn't registered", () => {
let server = new Server({
environment: "test",
factories: {
address: Factory
}
});
expect(function() {
server.create("contact");
}).toThrow(
"Mirage: You called server.create('contact') but no model or factory was found. Make sure you're passing in the singularized version of the model or factory name."
);
server.shutdown();
});
test("create works when models but no factories are registered", () => {
let server = new Server({
environment: "test",
models: {
contact: Model
}
});
server.create("contact");
expect(server.db.contacts).toHaveLength(1);
server.shutdown();
});
test("create adds the data to the db", () => {
let server = new Server({
environment: "test",
factories: {
contact: Factory.extend({
name: "Sam"
})
}
});
server.create("contact");
let contactsInDb = server.db.contacts;
expect(contactsInDb).toHaveLength(1);
expect(contactsInDb[0]).toEqual({ id: "1", name: "Sam" });
server.shutdown();
});
test("create returns the new data in the db", () => {
let server = new Server({
environment: "test",
factories: {
contact: Factory.extend({
name: "Sam"
})
}
});
let contact = server.create("contact");
expect(contact).toEqual({ id: "1", name: "Sam" });
server.shutdown();
});
test("create allows for attr overrides", () => {
let server = new Server({
environment: "test",
factories: {
contact: Factory.extend({
name: "Sam"
})
}
});
let sam = server.create("contact");
let link = server.create("contact", { name: "Link" });
expect(sam).toEqual({ id: "1", name: "Sam" });
expect(link).toEqual({ id: "2", name: "Link" });
server.shutdown();
});
test("create allows for attr overrides with extended factories", () => {
let ContactFactory = Factory.extend({
name: "Link",
age: 500
});
let FriendFactory = ContactFactory.extend({
is_young() {
return this.age < 18;
}
});
let server = new Server({
environment: "test",
factories: {
contact: ContactFactory,
friend: FriendFactory
}
});
let link = server.create("friend");
let youngLink = server.create("friend", { age: 10 });
expect(link).toEqual({ id: "1", name: "Link", age: 500, is_young: false });
expect(youngLink).toEqual({
id: "2",
name: "Link",
age: 10,
is_young: true
});
server.shutdown();
});
test("create allows for attr overrides with arrays", () => {
let server = new Server({
environment: "test",
factories: {
contact: Factory.extend({
name: ["Sam", "Carl"]
})
}
});
let sam = server.create("contact");
let link = server.create("contact", { name: ["Link"] });
let noname = server.create("contact", { name: [] });
expect(sam).toEqual({ id: "1", name: ["Sam", "Carl"] });
expect(link).toEqual({ id: "2", name: ["Link"] });
expect(noname).toEqual({ id: "3", name: [] });
server.shutdown();
});
test("create allows for nested attr overrides", () => {
let server = new Server({
environment: "test",
factories: {
contact: Factory.extend({
address: {
streetName: "Main",
streetAddress(i) {
return 1000 + i;
}
}
})
}
});
let contact1 = server.create("contact");
let contact2 = server.create("contact");
expect(contact1).toEqual({
id: "1",
address: { streetName: "Main", streetAddress: 1000 }
});
expect(contact2).toEqual({
id: "2",
address: { streetName: "Main", streetAddress: 1001 }
});
server.shutdown();
});
test("factories can have dynamic properties that depend on attr overrides", () => {
let server = new Server({
environment: "test",
factories: {
baz: Factory.extend({
bar() {
return this.name.substr(1);
}
})
}
});
let baz1 = server.create("baz", { name: "foo" });
expect(baz1).toEqual({ id: "1", name: "foo", bar: "oo" });
server.shutdown();
});
test("create allows for arrays of attr overrides", () => {
let server = new Server({
environment: "test",
factories: {
contact: Factory.extend({
websites: [
"http://example.com",
function(i) {
return `http://placekitten.com/${320 + i}/${240 + i}`;
}
]
})
}
});
let contact1 = server.create("contact");
let contact2 = server.create("contact");
expect(contact1).toEqual({
id: "1",
websites: ["http://example.com", "http://placekitten.com/320/240"]
});
expect(contact2).toEqual({
id: "2",
websites: ["http://example.com", "http://placekitten.com/321/241"]
});
server.shutdown();
});
test("create allows to extend factory with trait", () => {
let ArticleFactory = Factory.extend({
title: "Lorem ipsum",
published: trait({
isPublished: true,
publishedAt: "2010-01-01 10:00:00"
})
});
let server = new Server({
environment: "test",
factories: {
article: ArticleFactory
}
});
let article = server.create("article");
let publishedArticle = server.create("article", "published");
expect(article).toEqual({ id: "1", title: "Lorem ipsum" });
expect(publishedArticle).toEqual({
id: "2",
title: "Lorem ipsum",
isPublished: true,
publishedAt: "2010-01-01 10:00:00"
});
server.shutdown();
});
test("create allows to extend factory with multiple traits", () => {
let ArticleFactory = Factory.extend({
title: "Lorem ipsum",
published: trait({
isPublished: true,
publishedAt: "2010-01-01 10:00:00"
}),
withContent: trait({
content: "content"
})
});
let server = new Server({
environment: "test",
factories: {
article: ArticleFactory
}
});
let article = server.create("article");
let publishedArticle = server.create("article", "published");
let publishedArticleWithContent = server.create(
"article",
"published",
"withContent"
);
expect(article).toEqual({ id: "1", title: "Lorem ipsum" });
expect(publishedArticle).toEqual({
id: "2",
title: "Lorem ipsum",
isPublished: true,
publishedAt: "2010-01-01 10:00:00"
});
expect(publishedArticleWithContent).toEqual({
id: "3",
title: "Lorem ipsum",
isPublished: true,
publishedAt: "2010-01-01 10:00:00",
content: "content"
});
server.shutdown();
});
test("create allows to extend factory with traits containing afterCreate callbacks", () => {
let CommentFactory = Factory.extend({
content: "content"
});
let ArticleFactory = Factory.extend({
title: "Lorem ipsum",
withComments: trait({
afterCreate(article, server) {
server.createList("comment", 3, { article });
}
})
});
let server = new Server({
environment: "test",
factories: {
article: ArticleFactory,
comment: CommentFactory
}
});
let articleWithComments = server.create("article", "withComments");
expect(articleWithComments).toEqual({ id: "1", title: "Lorem ipsum" });
expect(server.db.comments).toHaveLength(3);
server.shutdown();
});
test("create does not execute afterCreate callbacks from traits that are not applied", () => {
let CommentFactory = Factory.extend({
content: "content"
});
let ArticleFactory = Factory.extend({
title: "Lorem ipsum",
withComments: trait({
afterCreate(article, server) {
server.createList("comment", 3, { article });
}
})
});
let server = new Server({
environment: "test",
factories: {
article: ArticleFactory,
comment: CommentFactory
}
});
let articleWithComments = server.create("article");
expect(articleWithComments).toEqual({ id: "1", title: "Lorem ipsum" });
expect(server.db.comments).toHaveLength(0);
server.shutdown();
});
test("create allows to extend with multiple traits and to apply attr overrides", () => {
let ArticleFactory = Factory.extend({
title: "Lorem ipsum",
published: trait({
isPublished: true,
publishedAt: "2010-01-01 10:00:00"
}),
withContent: trait({
content: "content"
})
});
let server = new Server({
environment: "test",
factories: {
article: ArticleFactory
}
});
let overrides = {
publishedAt: "2012-01-01 10:00:00"
};
let publishedArticleWithContent = server.create(
"article",
"published",
"withContent",
overrides
);
expect(publishedArticleWithContent).toEqual({
id: "1",
title: "Lorem ipsum",
isPublished: true,
publishedAt: "2012-01-01 10:00:00",
content: "content"
});
server.shutdown();
});
test("create throws errors when using trait that is not defined and distinquishes between traits and non-traits", () => {
let ArticleFactory = Factory.extend({
title: "Lorem ipsum",
published: trait({
isPublished: true,
publishedAt: "2010-01-01 10:00:00"
}),
private: {
someAttr: "value"
}
});
let server = new Server({
environment: "test",
factories: {
article: ArticleFactory
}
});
expect(() => {
server.create("article", "private");
}).toThrow("'private' trait is not registered in 'article' factory");
server.shutdown();
});
test("create allows to create objects with associations", () => {
let AuthorFactory = Factory.extend({
name: "Sam"
});
let CategoryFactory = Factory.extend({
name: "splendid software"
});
let ArticleFactory = Factory.extend({
title: "Lorem ipsum",
withCategory: trait({
awesomeCategory: association()
}),
author: association()
});
let server = new Server({
environment: "test",
models: {
author: Model.extend({
articles: hasMany()
}),
category: Model.extend({}),
article: Model.extend({
author: belongsTo(),
awesomeCategory: belongsTo("category")
})
},
factories: {
article: ArticleFactory,
author: AuthorFactory,
category: CategoryFactory
}
});
let article = server.create("article", "withCategory");
expect(article.attrs).toEqual({
title: "Lorem ipsum",
id: "1",
authorId: "1",
awesomeCategoryId: "1"
});
expect(server.db.authors).toHaveLength(1);
expect(server.db.categories).toHaveLength(1);
let anotherArticle = server.create("article", "withCategory");
expect(anotherArticle.attrs).toEqual({
title: "Lorem ipsum",
id: "2",
authorId: "2",
awesomeCategoryId: "2"
});
expect(server.db.authors).toHaveLength(2);
expect(server.db.categories).toHaveLength(2);
server.shutdown();
});
test("create allows to create objects with associations with traits and overrides for associations", () => {
let CategoryFactory = Factory.extend({
name: "splendid software",
published: trait({
isPublished: true,
publishedAt: "2014-01-01 10:00:00"
})
});
let ArticleFactory = Factory.extend({
title: "Lorem ipsum",
withCategory: trait({
category: association("published", {
publishedAt: "2016-01-01 12:00:00"
})
})
});
let server = new Server({
environment: "test",
factories: {
article: ArticleFactory,
category: CategoryFactory
},
models: {
category: Model.extend({}),
article: Model.extend({
category: belongsTo("category")
})
}
});
let article = server.create("article", "withCategory");
expect(article.attrs).toEqual({
title: "Lorem ipsum",
id: "1",
categoryId: "1"
});
expect(server.db.categories).toHaveLength(1);
expect(server.db.categories[0]).toEqual({
name: "splendid software",
id: "1",
isPublished: true,
publishedAt: "2016-01-01 12:00:00"
});
server.shutdown();
});
test("create does not create (extra) models on associations when they are passed in as overrides", () => {
let MotherFactory = Factory.extend({
name: "Should not create"
});
let ChildFactory = Factory.extend({
mother: association()
});
let server = new Server({
environment: "test",
factories: {
mother: MotherFactory,
child: ChildFactory
},
models: {
mother: Model.extend({
children: hasMany("child")
}),
child: Model.extend({
mother: belongsTo("mother")
})
}
});
let mother = server.create("mother", { name: "Lynda" });
server.create("child", { name: "Don", mother });
server.create("child", { name: "Dan", mother });
expect(server.db.mothers).toHaveLength(1);
server.shutdown();
});
});
describe("Unit | Server #createList", function() {
let server = null;
beforeEach(function() {
server = new Server({ environment: "test" });
});
afterEach(function() {
server.shutdown();
});
test("createList adds the given number of elements to the db", () => {
server.loadFactories({
contact: Factory.extend({ name: "Sam" })
});
server.createList("contact", 3);
let contactsInDb = server.db.contacts;
expect(contactsInDb).toHaveLength(3);
expect(contactsInDb[0]).toEqual({ id: "1", name: "Sam" });
expect(contactsInDb[1]).toEqual({ id: "2", name: "Sam" });
expect(contactsInDb[2]).toEqual({ id: "3", name: "Sam" });
});
test("createList returns the created elements", () => {
server.loadFactories({
contact: Factory.extend({ name: "Sam" })
});
server.create("contact");
let contacts = server.createList("contact", 3);
expect(contacts).toHaveLength(3);
expect(contacts[0]).toEqual({ id: "2", name: "Sam" });
expect(contacts[1]).toEqual({ id: "3", name: "Sam" });
expect(contacts[2]).toEqual({ id: "4", name: "Sam" });
});
test("createList respects sequences", () => {
server.loadFactories({
contact: Factory.extend({
name(i) {
return `name${i}`;
}
})
});
let contacts = server.createList("contact", 3);
expect(contacts[0]).toEqual({ id: "1", name: "name0" });
expect(contacts[1]).toEqual({ id: "2", name: "name1" });
expect(contacts[2]).toEqual({ id: "3", name: "name2" });
});
test("createList respects attr overrides", () => {
server.loadFactories({
contact: Factory.extend({ name: "Sam" })
});
let sams = server.createList("contact", 2);
let links = server.createList("contact", 2, { name: "Link" });
expect(sams[0]).toEqual({ id: "1", name: "Sam" });
expect(sams[1]).toEqual({ id: "2", name: "Sam" });
expect(links[0]).toEqual({ id: "3", name: "Link" });
expect(links[1]).toEqual({ id: "4", name: "Link" });
});
test("createList respects traits", () => {
let ArticleFactory = Factory.extend({
title: "Lorem ipsum",
published: trait({
isPublished: true,
publishedAt: "2010-01-01 10:00:00"
}),
withContent: trait({
content: "content"
})
});
server.loadFactories({
article: ArticleFactory
});
let articles = server.createList("article", 2, "published", "withContent");
expect(articles[0]).toEqual({
id: "1",
title: "Lorem ipsum",
isPublished: true,
publishedAt: "2010-01-01 10:00:00",
content: "content"
});
expect(articles[1]).toEqual({
id: "2",
title: "Lorem ipsum",
isPublished: true,
publishedAt: "2010-01-01 10:00:00",
content: "content"
});
});
test("createList respects traits with attr overrides", () => {
let ArticleFactory = Factory.extend({
title: "Lorem ipsum",
published: trait({
isPublished: true,
publishedAt: "2010-01-01 10:00:00"
}),
withContent: trait({
content: "content"
})
});
server.loadFactories({
article: ArticleFactory
});
let overrides = { publishedAt: "2012-01-01 10:00:00" };
let articles = server.createList(
"article",
2,
"published",
"withContent",
overrides
);
expect(articles[0]).toEqual({
id: "1",
title: "Lorem ipsum",
isPublished: true,
publishedAt: "2012-01-01 10:00:00",
content: "content"
});
expect(articles[1]).toEqual({
id: "2",
title: "Lorem ipsum",
isPublished: true,
publishedAt: "2012-01-01 10:00:00",
content: "content"
});
});
test("createList throws errors when using trait that is not defined and distinquishes between traits and non-traits", () => {
let ArticleFactory = Factory.extend({
title: "Lorem ipsum",
published: trait({
isPublished: true,
publishedAt: "2010-01-01 10:00:00"
}),
private: {
someAttr: "value"
}
});
server.loadFactories({
article: ArticleFactory
});
expect(() => {
server.createList("article", 2, "private");
}).toThrow("'private' trait is not registered in 'article' factory");
});
test("createList throws an error if the second argument is not an integer", () => {
let ArticleFactory = Factory.extend({
title: "Lorem ipsum",
published: trait({
isPublished: true,
publishedAt: "2010-01-01 10:00:00"
})
});
server.loadFactories({
article: ArticleFactory
});
expect(() => {
server.createList("article", "published");
}).toThrow(
"Mirage: second argument has to be an integer, you passed: string"
);
});
});
describe("Unit | Server #build", function() {
let server = null;
beforeEach(function() {
server = new Server({ environment: "test" });
});
afterEach(function() {
server.shutdown();
});
test("build does not add the data to the db", () => {
server.loadFactories({
contact: Factory.extend({ name: "Sam" })
});
server.build("contact");
let contactsInDb = server.db.contacts;
expect(contactsInDb).toHaveLength(0);
});
test("build returns the new attrs with no id", () => {
server.loadFactories({
contact: Factory.extend({ name: "Sam" })
});
let contact = server.build("contact");
expect(contact).toEqual({ name: "Sam" });
});
test("build allows for attr overrides", () => {
server.loadFactories({
contact: Factory.extend({ name: "Sam" })
});
let sam = server.build("contact");
let link = server.build("contact", { name: "Link" });
expect(sam).toEqual({ name: "Sam" });
expect(link).toEqual({ name: "Link" });
});
test("build allows for attr overrides with extended factories", () => {
let ContactFactory = Factory.extend({
name: "Link",
age: 500
});
let FriendFactory = ContactFactory.extend({
is_young() {
return this.age < 18;
}
});
server.loadFactories({
contact: ContactFactory,
friend: FriendFactory
});
let link = server.build("friend");
let youngLink = server.build("friend", { age: 10 });
expect(link).toEqual({ name: "Link", age: 500, is_young: false });
expect(youngLink).toEqual({ name: "Link", age: 10, is_young: true });
});
test("build allows for attr overrides with arrays", () => {
server.loadFactories({
contact: Factory.extend({ name: ["Sam", "Carl"] })
});
let sam = server.build("contact");
let link = server.build("contact", { name: ["Link"] });
let noname = server.build("contact", { name: [] });
expect(sam).toEqual({ name: ["Sam", "Carl"] });
expect(link).toEqual({ name: ["Link"] });
expect(noname).toEqual({ name: [] });
});
test("build allows for nested attr overrides", () => {
server.loadFactories({
contact: Factory.extend({
address: {
streetName: "Main",
streetAddress(i) {
return 1000 + i;
}
}
})
});
let contact1 = server.build("contact");
let contact2 = server.build("contact");
expect(contact1).toEqual({
address: { streetName: "Main", streetAddress: 1000 }
});
expect(contact2).toEqual({
address: { streetName: "Main", streetAddress: 1001 }
});
});
test("build allows for arrays of attr overrides", () => {
server.loadFactories({
contact: Factory.extend({
websites: [
"http://example.com",
function(i) {
return `http://placekitten.com/${320 + i}/${240 + i}`;
}
]
})
});
let contact1 = server.build("contact");
let contact2 = server.build("contact");
expect(contact1).toEqual({
websites: ["http://example.com", "http://placekitten.com/320/240"]
});
expect(contact2).toEqual({
websites: ["http://example.com", "http://placekitten.com/321/241"]
});
});
test("build allows to extend factory with trait", () => {
let ArticleFactory = Factory.extend({
title: "Lorem ipsum",
published: trait({
isPublished: true,
publishedAt: "2010-01-01 10:00:00"
})
});