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

100% Statements 18/18
100% Branches 0/0
100% Functions 7/7
100% Lines 18/18
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 341x 1x 1x 1x   1x 1x       1x 4x     1x 4x     1x 1x     1x 1x     1x 1x     1x 1x    
import UUID from 'uuid';
import {expect} from 'chai';
import sinon from 'sinon';
import {createContentItem, DEFAULT_DURATION} from "../../src/model-factory/content-item";
 
describe('Content Model Spec', () => {
    const contents = {
        id: 123,
    };
 
    beforeEach(() => {
        sinon.stub(UUID, 'v4').returns('random uuid');
    });
 
    afterEach(() => {
        UUID.v4.restore();
    });
 
    it('adds uuid called from uuid module', () => {
        expect(createContentItem(contents).uuid).to.equal('random uuid');
    });
 
    it('adds contents with "contents" parameter', () => {
        expect(createContentItem(contents).contents).to.deep.equal(contents);
    });
 
    it('adds duration values as field', () => {
        expect(createContentItem(contents, 50).durationSeconds).to.equal(50);
    });
 
    it('adds default duration "30" if duration is not provided', () => {
        expect(createContentItem(contents).durationSeconds).to.equal(DEFAULT_DURATION);
    });
});