forked from Hubs-Foundation/hubs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponent-mappings.test.js
40 lines (35 loc) · 1.03 KB
/
component-mappings.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
import test from "ava";
import { getSanitizedComponentMapping } from "../../../src/utils/component-mappings";
test("getSanitizedComponentMapping", t => {
const publicComponents = {
video: {
mappedComponent: "video-pause-state",
publicProperties: {
paused: {
mappedProperty: "pausedVideo",
getMappedValue(value) {
return !!value;
}
}
}
}
};
const { mappedComponent, mappedProperty, getMappedValue } = getSanitizedComponentMapping(
"video",
"paused",
publicComponents
);
t.is(mappedComponent, "video-pause-state");
t.is(mappedProperty, "pausedVideo");
t.is(getMappedValue(true), true);
t.is(getMappedValue(false), false);
t.is(getMappedValue(null), false);
// Non public component should throw.
t.throws(() => {
getSanitizedComponentMapping("gltf-model-plus", "src", publicComponents);
});
// Non public property should throw.
t.throws(() => {
getSanitizedComponentMapping("video", "src", publicComponents);
});
});