first commit
This commit is contained in:
41
modules/blockwishlist/tests/UI/Button.spec.js
Normal file
41
modules/blockwishlist/tests/UI/Button.spec.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import Vue from 'vue';
|
||||
import {shallowMount} from '@vue/test-utils';
|
||||
import Button from '@components/Button/Button.vue';
|
||||
import EventBus from '@components/EventBus';
|
||||
|
||||
describe('Button.vue', () => {
|
||||
it('should stay unchecked if user is not logged in', async () => {
|
||||
const wrapper = shallowMount(Button);
|
||||
|
||||
expect(wrapper.vm.isChecked).toBe(false);
|
||||
|
||||
wrapper.find('button').trigger('click');
|
||||
await Vue.nextTick();
|
||||
expect(wrapper.vm.isChecked).toBe(false);
|
||||
});
|
||||
|
||||
it('should be checked if it receive the event addedToWishlist', async () => {
|
||||
const wrapper = shallowMount(Button, {
|
||||
propsData: {
|
||||
productId: 1
|
||||
}
|
||||
});
|
||||
|
||||
EventBus.$emit('addedToWishlist', {
|
||||
detail: {productId: 1, listId: 1}
|
||||
});
|
||||
|
||||
expect(wrapper.vm.isChecked).toBe(true);
|
||||
});
|
||||
|
||||
it('should be checked if we passe checked as a prop', async () => {
|
||||
const wrapper = shallowMount(Button, {
|
||||
propsData: {
|
||||
productId: 1,
|
||||
checked: 'true'
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.vm.isChecked).toBe(true);
|
||||
});
|
||||
});
|
||||
22
modules/blockwishlist/tests/UI/Create.spec.js
Normal file
22
modules/blockwishlist/tests/UI/Create.spec.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import Vue from 'vue';
|
||||
import {shallowMount, mount} from '@vue/test-utils';
|
||||
import Create from '@components/Create/Create.vue';
|
||||
import EventBus from '@components/EventBus';
|
||||
|
||||
describe('Create.vue', () => {
|
||||
it(`should'nt be hidden if it receive the event showCreateWishlist`, async () => {
|
||||
const wrapper = shallowMount(Create);
|
||||
|
||||
EventBus.$emit('showCreateWishlist');
|
||||
|
||||
expect(wrapper.vm.isHidden).toBe(false);
|
||||
});
|
||||
|
||||
it('value should be empty if it receive the event addedToWishlist', async () => {
|
||||
const wrapper = shallowMount(Create);
|
||||
|
||||
EventBus.$emit('showCreateWishlist');
|
||||
|
||||
expect(wrapper.vm.value).toBe('');
|
||||
});
|
||||
});
|
||||
19
modules/blockwishlist/tests/UI/Delete.spec.js
Normal file
19
modules/blockwishlist/tests/UI/Delete.spec.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import {shallowMount} from '@vue/test-utils';
|
||||
import Delete from '@components/Delete/Delete.vue';
|
||||
import EventBus from '@components/EventBus';
|
||||
|
||||
describe('Delete.vue', () => {
|
||||
it(`should'nt be hidden if it receive the event showDelete`, async () => {
|
||||
const wrapper = shallowMount(Delete);
|
||||
|
||||
EventBus.$emit('showDeleteWishlist', {
|
||||
detail: {
|
||||
listId: 1,
|
||||
productId: 1,
|
||||
productAttributeId: 1
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.vm.isHidden).toBe(false);
|
||||
});
|
||||
});
|
||||
112
modules/blockwishlist/tests/UI/List.spec.js
Normal file
112
modules/blockwishlist/tests/UI/List.spec.js
Normal file
@@ -0,0 +1,112 @@
|
||||
import Vue from 'vue';
|
||||
import { shallowMount, mount } from '@vue/test-utils';
|
||||
import List from '@components/List/List.vue';
|
||||
import EventBus from '@components/EventBus';
|
||||
|
||||
const items = [
|
||||
{
|
||||
id_wishlist: 1,
|
||||
nbProducts: 2,
|
||||
name: 'Test of list number one',
|
||||
listUrl: '#'
|
||||
},
|
||||
{
|
||||
id_wishlist: 2,
|
||||
nbProducts: 2,
|
||||
name: 'Test of list 2',
|
||||
listUrl: '#'
|
||||
}
|
||||
];
|
||||
|
||||
describe('List.vue', () => {
|
||||
it('should be loading if no items are provided', async () => {
|
||||
const wrapper = shallowMount(List);
|
||||
|
||||
expect(wrapper.vm.loading).toBe(true);
|
||||
});
|
||||
|
||||
it('should render a list of items if they are provided', async () => {
|
||||
const wrapper = shallowMount(List, {
|
||||
propsData: {
|
||||
loading: false,
|
||||
items
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.vm.loading).toBe(false);
|
||||
|
||||
expect(wrapper.find('ul li').exists()).toBe(true);
|
||||
expect(wrapper.findAll('li')).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('should open links popup', async () => {
|
||||
const wrapper = mount(List, {
|
||||
propsData: {
|
||||
loading: false,
|
||||
items
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.vm.loading).toBe(false);
|
||||
|
||||
const lists = wrapper.findAll('li');
|
||||
|
||||
lists.wrappers.forEach(list => {
|
||||
list.find('.wishlist-list-item-actions').trigger('click');
|
||||
});
|
||||
|
||||
expect(wrapper.vm.activeDropdowns.length).toBe(1);
|
||||
});
|
||||
|
||||
it('should click on share and open share modal', async () => {
|
||||
EventBus.$on('showShareWishlist', e => {
|
||||
expect(e.detail.listId).toBe(1);
|
||||
});
|
||||
|
||||
const wrapper = mount(List, {
|
||||
propsData: {
|
||||
loading: false,
|
||||
items,
|
||||
listId: 1
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.vm.loading).toBe(false);
|
||||
|
||||
const list = wrapper.find('li:first-child');
|
||||
|
||||
list.find('.wishlist-list-item-actions').trigger('click');
|
||||
await Vue.nextTick();
|
||||
|
||||
list.find('.dropdown-menu button:last-child').trigger('click');
|
||||
await Vue.nextTick();
|
||||
|
||||
expect(wrapper.vm.activeDropdowns.length).toBe(1);
|
||||
});
|
||||
|
||||
it('should click on rename and open rename modal', async () => {
|
||||
EventBus.$on('showRenameWishlist', e => {
|
||||
expect(e.detail.listId).toBe(1);
|
||||
});
|
||||
|
||||
const wrapper = mount(List, {
|
||||
propsData: {
|
||||
loading: false,
|
||||
items,
|
||||
listId: 1
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.vm.loading).toBe(false);
|
||||
|
||||
const list = wrapper.find('li:first-child');
|
||||
|
||||
list.find('.wishlist-list-item-actions').trigger('click');
|
||||
await Vue.nextTick();
|
||||
|
||||
list.find('.dropdown-menu button:first-child').trigger('click');
|
||||
await Vue.nextTick();
|
||||
|
||||
expect(wrapper.vm.activeDropdowns.length).toBe(1);
|
||||
});
|
||||
});
|
||||
14
modules/blockwishlist/tests/UI/Login.spec.js
Normal file
14
modules/blockwishlist/tests/UI/Login.spec.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import Vue from 'vue';
|
||||
import {shallowMount, mount} from '@vue/test-utils';
|
||||
import Login from '@components/Login/Login.vue';
|
||||
import EventBus from '@components/EventBus';
|
||||
|
||||
describe('Login.vue', () => {
|
||||
it(`should'nt be hidden if it receive the event showLogin`, async () => {
|
||||
const wrapper = shallowMount(Login);
|
||||
|
||||
EventBus.$emit('showLogin');
|
||||
|
||||
expect(wrapper.vm.isHidden).toBe(false);
|
||||
});
|
||||
});
|
||||
19
modules/blockwishlist/tests/UI/Rename.spec.js
Normal file
19
modules/blockwishlist/tests/UI/Rename.spec.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import Vue from 'vue';
|
||||
import {shallowMount, mount} from '@vue/test-utils';
|
||||
import Rename from '@components/Rename/Rename.vue';
|
||||
import EventBus from '@components/EventBus';
|
||||
|
||||
describe('Rename.vue', () => {
|
||||
it(`should'nt be hidden if it receive the event showRenameWishlist`, async () => {
|
||||
const wrapper = shallowMount(Rename);
|
||||
|
||||
EventBus.$emit('showRenameWishlist', {
|
||||
detail: {
|
||||
listId: 1,
|
||||
title: 'Test of title'
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.vm.isHidden).toBe(false);
|
||||
});
|
||||
});
|
||||
48
modules/blockwishlist/tests/UI/Toast.spec.js
Normal file
48
modules/blockwishlist/tests/UI/Toast.spec.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import Vue from 'vue';
|
||||
import {shallowMount, mount} from '@vue/test-utils';
|
||||
import Toast from '@components/Toast/Toast.vue';
|
||||
import EventBus from '@components/EventBus';
|
||||
|
||||
describe('Toast.vue', () => {
|
||||
it(`should'nt be hidden if it receive the event showToast`, async () => {
|
||||
const wrapper = shallowMount(Toast);
|
||||
|
||||
EventBus.$emit('showToast', {
|
||||
detail: {
|
||||
message: 'Test of message'
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.vm.active).toBe(true);
|
||||
});
|
||||
|
||||
it(`should have a custom message`, async () => {
|
||||
const wrapper = shallowMount(Toast);
|
||||
|
||||
EventBus.$emit('showToast', {
|
||||
detail: {
|
||||
message: 'custom'
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.vm.text).toBe('custom');
|
||||
});
|
||||
|
||||
it(`should be hidden after 2.5s`, function(done) {
|
||||
const wrapper = shallowMount(Toast);
|
||||
this.timeout(4000);
|
||||
|
||||
EventBus.$emit('showToast', {
|
||||
detail: {
|
||||
message: 'Test of message'
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.vm.active).toBe(true);
|
||||
|
||||
setTimeout(() => {
|
||||
expect(wrapper.vm.active).toBe(false);
|
||||
done();
|
||||
}, 3000);
|
||||
});
|
||||
});
|
||||
8
modules/blockwishlist/tests/UI/setup.js
Normal file
8
modules/blockwishlist/tests/UI/setup.js
Normal file
@@ -0,0 +1,8 @@
|
||||
require('jsdom-global')();
|
||||
global.productsAlreadyTagged = [];
|
||||
global.window.prestashop = {
|
||||
customer: {
|
||||
is_logged: false
|
||||
}
|
||||
};
|
||||
global.expect = require('expect');
|
||||
28
modules/blockwishlist/tests/phpstan.sh
Normal file
28
modules/blockwishlist/tests/phpstan.sh
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
PS_VERSION=$1
|
||||
|
||||
set -e
|
||||
|
||||
# Docker images prestashop/prestashop may be used, even if the shop remains uninstalled
|
||||
echo "Pull PrestaShop files (Tag ${PS_VERSION})"
|
||||
|
||||
docker rm -f temp-ps || true
|
||||
docker volume rm -f ps-volume || true
|
||||
|
||||
docker run -tid --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:$PS_VERSION
|
||||
|
||||
# Clear previous instance of the module in the PrestaShop volume
|
||||
echo "Clear previous module"
|
||||
|
||||
docker exec -t temp-ps rm -rf /var/www/html/modules/blockwishlist
|
||||
|
||||
# Run a container for PHPStan, having access to the module content and PrestaShop sources.
|
||||
# This tool is outside the composer.json because of the compatibility with PHP 5.6
|
||||
echo "Run PHPStan using phpstan-${PS_VERSION}.neon file"
|
||||
|
||||
docker run --rm --volumes-from temp-ps \
|
||||
-v $PWD:/var/www/html/modules/blockwishlist \
|
||||
-e _PS_ROOT_DIR_=/var/www/html \
|
||||
--workdir=/var/www/html/modules/blockwishlist phpstan/phpstan:0.12 \
|
||||
analyse \
|
||||
--configuration=/var/www/html/modules/blockwishlist/tests/phpstan/phpstan-$PS_VERSION.neon
|
||||
35
modules/blockwishlist/tests/phpstan/index.php
Normal file
35
modules/blockwishlist/tests/phpstan/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2015 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2015 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
11
modules/blockwishlist/tests/phpstan/phpstan-1.7.6.neon
Normal file
11
modules/blockwishlist/tests/phpstan/phpstan-1.7.6.neon
Normal file
@@ -0,0 +1,11 @@
|
||||
includes:
|
||||
- %currentWorkingDirectory%/tests/phpstan/phpstan.neon
|
||||
|
||||
parameters:
|
||||
ignoreErrors:
|
||||
- '#Call to an undefined static method Attribute\:\:getAttributeMinimalQty\(\).#'
|
||||
- '#Call to static method getAttributeMinimalQty\(\) on an unknown class ProductAttribute.#'
|
||||
- '#Parameter \#1 \$hook_name of method ModuleCore\:\:registerHook\(\) expects string, array<int, string> given.#'
|
||||
- '#Parameter \#1 \$value of method ControllerCore\:\:ajaxRender\(\) expects null, string\|false given.#'
|
||||
- '#Parameter \#2 \$value of static method CacheCore\:\:store\(\) expects string, array\|mysqli_result\|PDOStatement\|resource\|false\|null given.#'
|
||||
- '#Property ModuleCore\:\:\$version \(float\) does not accept string.#'
|
||||
8
modules/blockwishlist/tests/phpstan/phpstan-1.7.7.neon
Normal file
8
modules/blockwishlist/tests/phpstan/phpstan-1.7.7.neon
Normal file
@@ -0,0 +1,8 @@
|
||||
includes:
|
||||
- %currentWorkingDirectory%/tests/phpstan/phpstan.neon
|
||||
|
||||
parameters:
|
||||
ignoreErrors:
|
||||
- '#Call to an undefined static method Attribute\:\:getAttributeMinimalQty\(\).#'
|
||||
- '#Call to static method getAttributeMinimalQty\(\) on an unknown class ProductAttribute.#'
|
||||
- '#Parameter \#1 \$value of method ControllerCore\:\:ajaxRender\(\) expects null, string\|false given.#'
|
||||
7
modules/blockwishlist/tests/phpstan/phpstan-1.7.8.neon
Normal file
7
modules/blockwishlist/tests/phpstan/phpstan-1.7.8.neon
Normal file
@@ -0,0 +1,7 @@
|
||||
includes:
|
||||
- %currentWorkingDirectory%/tests/phpstan/phpstan.neon
|
||||
|
||||
parameters:
|
||||
ignoreErrors:
|
||||
- '#Call to an undefined static method Attribute\:\:getAttributeMinimalQty\(\).#'
|
||||
- '#Call to static method getAttributeMinimalQty\(\) on an unknown class ProductAttribute.#'
|
||||
7
modules/blockwishlist/tests/phpstan/phpstan-latest.neon
Normal file
7
modules/blockwishlist/tests/phpstan/phpstan-latest.neon
Normal file
@@ -0,0 +1,7 @@
|
||||
includes:
|
||||
- %currentWorkingDirectory%/tests/phpstan/phpstan.neon
|
||||
|
||||
parameters:
|
||||
ignoreErrors:
|
||||
- '#Call to an undefined static method Attribute\:\:getAttributeMinimalQty\(\).#'
|
||||
- '#Call to static method getAttributeMinimalQty\(\) on an unknown class ProductAttribute.#'
|
||||
14
modules/blockwishlist/tests/phpstan/phpstan.neon
Normal file
14
modules/blockwishlist/tests/phpstan/phpstan.neon
Normal file
@@ -0,0 +1,14 @@
|
||||
includes:
|
||||
- %currentWorkingDirectory%/vendor/prestashop/php-dev-tools/phpstan/ps-module-extension.neon
|
||||
|
||||
parameters:
|
||||
paths:
|
||||
# From PHPStan 0.12, paths to check are relative to the neon file
|
||||
- ../../blockwishlist.php
|
||||
- ../../classes/
|
||||
- ../../controllers/
|
||||
- ../../src/
|
||||
- ../../upgrade/
|
||||
ignoreErrors:
|
||||
reportUnmatchedIgnoredErrors: false
|
||||
level: 5
|
||||
Reference in New Issue
Block a user