2018-06-04 07:48:32 +00:00
|
|
|
import './index.js';
|
|
|
|
|
2018-07-30 10:12:41 +00:00
|
|
|
fdescribe('Item', () => {
|
2018-06-04 07:48:32 +00:00
|
|
|
describe('Component vnItemDiary', () => {
|
|
|
|
let $componentController;
|
|
|
|
let $scope;
|
|
|
|
let controller;
|
|
|
|
let $httpBackend;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
angular.mock.module('item');
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => {
|
|
|
|
$componentController = _$componentController_;
|
|
|
|
$httpBackend = _$httpBackend_;
|
2018-06-08 11:26:06 +00:00
|
|
|
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
|
2018-06-04 07:48:32 +00:00
|
|
|
$scope = $rootScope.$new();
|
|
|
|
controller = $componentController('vnItemDiary', {$scope: $scope});
|
2018-07-04 06:50:34 +00:00
|
|
|
controller.$scope.model = {};
|
2018-06-04 07:48:32 +00:00
|
|
|
}));
|
|
|
|
|
2018-07-04 06:50:34 +00:00
|
|
|
describe('isToday()', () => {
|
|
|
|
it(`should call isToday() an return true if an specified date is the current date`, () => {
|
|
|
|
let date = new Date();
|
2018-06-04 07:48:32 +00:00
|
|
|
|
2018-07-04 06:50:34 +00:00
|
|
|
let result = controller.isToday(date);
|
|
|
|
|
|
|
|
expect(result).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should call isToday() an return false if an specified date is the current date`, () => {
|
|
|
|
let date = '2018-07-03';
|
|
|
|
|
|
|
|
let result = controller.isToday(date);
|
|
|
|
|
|
|
|
expect(result).toBeFalsy();
|
2018-06-04 07:48:32 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-30 10:12:41 +00:00
|
|
|
describe('freeLineIndex()', () => {
|
|
|
|
it(`should call freeLineIndex() and return an index from line with alertLevel 0 and current date`, () => {
|
2018-07-04 06:50:34 +00:00
|
|
|
controller.$scope.model = {data: [
|
|
|
|
{name: 'My item 1', alertLevel: 3, date: '2018-05-02'},
|
|
|
|
{name: 'My item 2', alertLevel: 1, date: '2018-05-03'},
|
|
|
|
{name: 'My item 3', alertLevel: 0, date: new Date()}]
|
|
|
|
};
|
2018-07-30 10:12:41 +00:00
|
|
|
let result = controller.freeLineIndex;
|
2018-07-04 06:50:34 +00:00
|
|
|
|
|
|
|
expect(result).toEqual(2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-30 10:12:41 +00:00
|
|
|
describe('onPreparationLineIndex()', () => {
|
|
|
|
it(`should call onPreparationLineIndex() and return an index from line with alertLevel 1 and isPicked true`, () => {
|
|
|
|
controller.$scope.model = {data: [
|
|
|
|
{name: 'My item 1', alertLevel: 3, isPicked: true, date: '2018-05-02'},
|
|
|
|
{name: 'My item 3', alertLevel: 1, isPicked: true, date: '2018-05-03'},
|
|
|
|
{name: 'My item 4', alertLevel: 1, isPicked: false, date: '2018-05-03'},
|
|
|
|
{name: 'My item 5', alertLevel: 0, isPicked: false, date: new Date()}]
|
|
|
|
};
|
|
|
|
let result = controller.onPreparationLineIndex;
|
|
|
|
|
|
|
|
expect(result).toEqual(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-04 06:50:34 +00:00
|
|
|
describe('set item()', () => {
|
|
|
|
it(`should call filterBuilder()`, () => {
|
|
|
|
spyOn(controller, 'filterBuilder');
|
|
|
|
controller.item = {id: 1};
|
|
|
|
|
|
|
|
expect(controller.filterBuilder).toHaveBeenCalledWith();
|
|
|
|
expect(controller.item).toEqual({id: 1});
|
2018-06-04 07:48:32 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|