-
Notifications
You must be signed in to change notification settings - Fork 42
/
video-shared.native.js
92 lines (84 loc) · 2.18 KB
/
video-shared.native.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
import React from "react";
import TestRenderer from "react-test-renderer";
import {
addSerializers,
compose,
enzymeRenderedSerializer,
minimaliseTransform,
minimalNativeTransform,
print,
replacePropTransform
} from "@times-components/jest-serializer";
import { hash, iterator } from "@times-components/test-utils";
import Video from "../src/video";
import defaultVideoProps from "./default-video-props";
jest.mock("@times-components/image", () => "Image");
jest.mock("@times-components/gradient", () => ({
OverlayGradient: "OverlayGradient"
}));
// eslint-disable-next-line global-require
jest.mock("@times-components/svgs", () => require("./mock-svg"));
export default () => {
addSerializers(
expect,
enzymeRenderedSerializer(),
compose(
print,
minimalNativeTransform,
minimaliseTransform(
(value, key) =>
key === "style" ||
key === "nativeBackgroundAndroid" ||
key.includes("Class")
),
replacePropTransform((value, key) => {
if (key === "uri") {
return hash(value);
}
if (key === "source" && value.uri) {
return hash(value.uri);
}
return value;
})
)
);
const tests = [
{
name: "video",
test: () => {
const testInstance = TestRenderer.create(
<Video {...defaultVideoProps} />
);
expect(testInstance.toJSON()).toMatchSnapshot();
}
},
{
name: "video without a poster image",
test: () => {
const testInstance = TestRenderer.create(
<Video {...defaultVideoProps} poster={null} />
);
expect(testInstance.toJSON()).toMatchSnapshot();
}
},
{
name: "sky sports video",
test: () => {
const testInstance = TestRenderer.create(
<Video {...defaultVideoProps} skySports />
);
expect(testInstance.toJSON()).toMatchSnapshot();
}
},
{
name: "360 video",
test: () => {
const testInstance = TestRenderer.create(
<Video {...defaultVideoProps} playerId="foo" />
);
expect(testInstance).toMatchSnapshot();
}
}
];
iterator(tests);
};