All files / nexshop-web-contents/spec/model-factory scene-spec.js

100% Statements 34/34
100% Branches 0/0
100% Functions 12/12
100% Lines 34/34
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 1181x 1x 1x   1x   1x 1x 1x 1x 1x 1x   1x 8x     1x 1x     1x 1x     1x 1x     1x 1x     1x 1x 1x     1x 1x 1x         1x 1x     1x 1x 1x                                                           1x                                                           1x 1x          
import React from 'react';
import {expect} from 'chai';
import {createScene, createEmptySceneFromLayouts} from "../../src/model-factory/scene";
 
describe('Scene Spec', () => {
    let createdScene;
    const name = 'A.scene';
    const panels = ['B'];
    const resolution = {width: 100, height: 50};
    const orientation = 'horizontal';
    const relatedContents = [{id: '3'}, {id: '2'}, {id: '1'}];
    const folderId = 'folderId';
 
    beforeEach(() => {
        createdScene = createScene(name, panels, folderId, resolution, orientation, relatedContents);
    });
 
    it('set name', () => {
        expect(createdScene.name).to.deep.equal(name);
    });
 
    it('set folderId', () => {
        expect(createdScene.folderId).to.deep.equal(folderId);
    });
 
    it('set panels', () => {
        expect(createdScene.metaData.panels).to.deep.equal(panels);
    });
 
    it('set resolution', () => {
        expect(createdScene.metaData.display.resolution).to.deep.equal(resolution);
    });
 
    describe('set orientation', () => {
        it('set orientation', () => {
            expect(createdScene.metaData.display.orientation).to.deep.equal(orientation);
        });
 
        it('set vertical resolution', () => {
            createdScene = createScene(name, panels, folderId, resolution, 'vertical', relatedContents);
            expect(createdScene.metaData.display.orientation).to.deep.equal('vertical');
 
        });
    });
 
    it('set relatedContents', () => {
        expect(createdScene.relatedContents).to.deep.equal(relatedContents);
    });
 
    describe('createEmptySceneFromLayouts', () => {
        it('clone scene when createEmptySceneFromLayouts called by orientation', () => {
            const horizontalLayout = {
                id: '1',
                index: 0,
                panels:
                    [
                        {
                            direction: "row",
                            domAttribute: {
                                minSize: 5,
                                resize: "dynamic",
                                size: 960
                            },
                            id: "g1",
                            panels: [
                                {
                                    domAttribute: {
                                        minSize: 5,
                                        resize: "dynamic",
                                        size: 960
                                    },
                                    id: "p1",
                                    type: "panel"
                                }
                            ],
                            type: "group"
                        }
                    ],
                type: '1-1'
            };
 
            const verticalLayout = {
                id: '1',
                index: 0,
                panels:
                    [
                        {
                            direction: "row",
                            domAttribute: {
                                minSize: 5,
                                resize: "dynamic",
                                size: 768
                            },
                            id: "g1",
                            panels: [
                                {
                                    domAttribute: {
                                        minSize: 5,
                                        resize: "dynamic",
                                        size: 768
                                    },
                                    id: "p1",
                                    type: "panel"
                                }
                            ],
                            type: "group"
                        }
                    ],
                type: '1-1'
            };
 
            expect(createEmptySceneFromLayouts('1', 'horizontal')).to.deep.equal(horizontalLayout);
            expect(createEmptySceneFromLayouts('1', 'vertical')).to.deep.equal(verticalLayout);
        });
 
    });
});