Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
drill-lancer committed Sep 28, 2023
1 parent 24bc4c9 commit 68958a0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
7 changes: 6 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ module.exports = ( api ) => {
api.cache( true );

return {
presets: [ '@wordpress/babel-preset-default' ],
presets: [
['@babel/preset-env', {
"modules": "commonjs"
}],
'@wordpress/babel-preset-default'
],
plugins: [
'@emotion/babel-plugin',
'babel-plugin-inline-json-import'
Expand Down
1 change: 1 addition & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global.TextEncoder = require("util").TextEncoder;
2 changes: 1 addition & 1 deletion languages/vk-blocks-pro.pot
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2023-09-28T06:05:56+00:00\n"
"POT-Creation-Date: 2023-09-28T07:17:25+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.8.1\n"
"X-Domain: vk-blocks-pro\n"
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"stop": "wp-env stop",
"destroy": "wp-env destroy",
"watch": "npm run build && concurrently \"wp-scripts start\" \"npx gulp watch\"",
"update": "npx ncu -u -x '@wordpress/env sass react react-dom' && rm -rf node_modules/ package-lock.json && npm install && npm run build",
"update": "npx ncu -u -x '@wordpress/env sass react react-dom' && rimraf node_modules/ package-lock.json && npm install && npm run build",
"dist": "npm run build && composer install --no-dev && gulp dist && composer install",
"prebuild": "npx rimraf ./inc/vk-blocks/build/*",
"prebuild": "rimraf ./inc/vk-blocks/build/*",
"build:dev": "composer install && gulp text-domain-pro && wp-scripts build --webpack-copy-php --config webpack.config.js --progress --mode=development && gulp build:dev:pro",
"build": "composer install && gulp text-domain-pro && wp-scripts build --webpack-copy-php --config webpack.config.js --progress && gulp build:pro && npm run translate",
"build:dev:cache": "composer install && gulp text-domain-pro && wp-scripts build --webpack-copy-php --config webpack.config.js --progress --mode=development --env enableCache=true && gulp build:dev:pro",
Expand All @@ -23,7 +23,7 @@
"gulp": "npx gulp",
"lint": "wp-scripts format src/ && wp-scripts lint-js src/ --fix",
"lint:php": "composer install && composer format && composer phpcs",
"fixtures:clean": "rimraf \"test/e2e-tests/fixtures/blocks/*.+(json|serialized.html)\"",
"fixtures:clean": "rimraf test/e2e-tests/fixtures/blocks/*.json test/e2e-tests/fixtures/blocks/*.serialized.html",
"fixtures:generate": "cross-env GENERATE_MISSING_FIXTURES=y wp-scripts test-unit-js --config test/jest.config.js test/integration/full-content/full-content.test.js",
"fixtures:regenerate": "npm run build && npm run fixtures:clean && npm run fixtures:generate",
"test-unit": "npm run test-unit:clean && npm run fixtures:regenerate",
Expand All @@ -36,7 +36,7 @@
"phpunit:free": "composer install && wp-env run phpunit \"phpunit -c /var/www/html/wp-content/plugins/vk-blocks/.phpunit.xml --verbose\"",
"cli": "npx wp-env run cli",
"packages-update": "npx wp-scripts packages-update",
"reinstall": "rm -rf node_modules/ && npm install && npm run build",
"reinstall": "rimraf node_modules/ && npm install && npm run build",
"prepare": "husky install",
"wp-env": "wp-env"
},
Expand Down
20 changes: 10 additions & 10 deletions test/e2e-tests/fixtures/blocks/vk-blocks__outer__default.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<!-- wp:vk-blocks/outer {"bgColor":"#8ed1fc","bgImage":"https://www.vektor-inc.co.jp/wp-content/uploads/2020/04/vws_logo_2020_og.png","bgImageTablet":"https://www.vektor-inc.co.jp/wp-content/uploads/2020/08/vk-blocks-logo_og.png","bgImageMobile":"https://www.vektor-inc.co.jp/wp-content/uploads/2020/08/vk-blocks-logo_og.png","upper_level":43,"lower_level":-56,"borderColor":"#000","blockId":"1a85def9-ff66-40a4-a115-aac39b59e05e"} -->
<div class="wp-block-vk-blocks-outer vkb-outer-1a85def9-ff66-40a4-a115-aac39b59e05e vk_outer vk_outer-width-normal vk_outer-paddingLR-none vk_outer-paddingVertical-use vk_outer-bgPosition-normal" style="border:none;border-radius:0px"><style>
<!-- wp:vk-blocks/outer {"bgColor":"#8ed1fc","bgImage":"https://www.vektor-inc.co.jp/wp-content/uploads/2020/04/vws_logo_2020_og.png","bgImageTablet":"https://www.vektor-inc.co.jp/wp-content/uploads/2020/08/vk-blocks-logo_og.png","bgImageMobile":"https://www.vektor-inc.co.jp/wp-content/uploads/2020/08/vk-blocks-logo_og.png","upper_level":43,"lower_level":-56,"borderColor":"#000","blockId":"49d5b682-3de0-462f-9197-946759350655"} -->
<div class="wp-block-vk-blocks-outer vkb-outer-49d5b682-3de0-462f-9197-946759350655 vk_outer vk_outer-width-normal vk_outer-paddingLR-none vk_outer-paddingVertical-use vk_outer-bgPosition-normal" style="border:none;border-radius:0px"><style>
@media screen and (max-width: 575.98px) {
.vkb-outer-1a85def9-ff66-40a4-a115-aac39b59e05e{background-image: url(https://www.vektor-inc.co.jp/wp-content/uploads/2020/08/vk-blocks-logo_og.png); }
.vkb-outer-49d5b682-3de0-462f-9197-946759350655{background-image: url(https://www.vektor-inc.co.jp/wp-content/uploads/2020/08/vk-blocks-logo_og.png); }
}
@media screen and (min-width: 576px) {
.vkb-outer-1a85def9-ff66-40a4-a115-aac39b59e05e{background-image: url(https://www.vektor-inc.co.jp/wp-content/uploads/2020/08/vk-blocks-logo_og.png); }
.vkb-outer-49d5b682-3de0-462f-9197-946759350655{background-image: url(https://www.vektor-inc.co.jp/wp-content/uploads/2020/08/vk-blocks-logo_og.png); }
}
@media screen and (min-width: 992px) {
.vkb-outer-1a85def9-ff66-40a4-a115-aac39b59e05e{background-image: url(https://www.vektor-inc.co.jp/wp-content/uploads/2020/04/vws_logo_2020_og.png); }
.vkb-outer-49d5b682-3de0-462f-9197-946759350655{background-image: url(https://www.vektor-inc.co.jp/wp-content/uploads/2020/04/vws_logo_2020_og.png); }
}
</style><span class="vk_outer-background-area has-background has-background-dim" style="background-color:#8ed1fc;opacity:0.5"></span><div><div class="vk_outer_separator vk_outer_separator-position-upper vk_outer_separator-type-tilt" style="padding-bottom:43px"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><path d="m0,57 L100,100 L0,100 z" strokewidth="0" fill="#fff" class="has-text-color"></path></svg></div><div class="vk_outer_container"></div><div class="vk_outer_separator vk_outer_separator-position-lower vk_outer_separator-type-tilt" style="padding-top:56px"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><path d="m100,44 L0,100 L100,100 z" strokewidth="0" fill="#fff" class="has-text-color"></path></svg></div></div></div><style type="text/css">
.vk_outer.vkb-outer-1a85def9-ff66-40a4-a115-aac39b59e05e > div > .vk_outer_container{
</style><span class="vk_outer-background-area has-background has-background-dim" style="background-color:#8ed1fc;opacity:0.5"></span><div><div class="vk_outer_separator vk_outer_separator-position-upper vk_outer_separator-type-tilt" style="padding-bottom:43px"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><path d="m0,57 L100,100 L0,100 z" stroke-width="0" fill="#fff" class="has-text-color"></path></svg></div><div class="vk_outer_container"></div><div class="vk_outer_separator vk_outer_separator-position-lower vk_outer_separator-type-tilt" style="padding-top:56px"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><path d="m100,44 L0,100 L100,100 z" stroke-width="0" fill="#fff" class="has-text-color"></path></svg></div></div></div><style type="text/css">
.vk_outer.vkb-outer-49d5b682-3de0-462f-9197-946759350655 > div > .vk_outer_container{
padding-left:0px!important;
padding-right:0px!important;
}
@media (min-width: 576px) {
.vk_outer.vkb-outer-1a85def9-ff66-40a4-a115-aac39b59e05e > div > .vk_outer_container{
.vk_outer.vkb-outer-49d5b682-3de0-462f-9197-946759350655 > div > .vk_outer_container{
padding-left:0px!important;
padding-right:0px!important;
}
}
@media (min-width: 992px) {
.vk_outer.vkb-outer-1a85def9-ff66-40a4-a115-aac39b59e05e > div > .vk_outer_container{
.vk_outer.vkb-outer-49d5b682-3de0-462f-9197-946759350655 > div > .vk_outer_container{
padding-left:0px!important;
padding-right:0px!important;
}
}
</style>
<!-- /wp:vk-blocks/outer -->
<!-- /wp:vk-blocks/outer -->
7 changes: 5 additions & 2 deletions test/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
module.exports = {
rootDir: '../',
// @vkblocks エイリアスを jestで使う
moduleNameMapper: {
"^@vkblocks/(.+)": "<rootDir>/src/$1"
},
preset: '@wordpress/jest-preset-default',
transform : {
"^.+\\.js$": "babel-jest",
".+\\.(svg|css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub"
}
},
transformIgnorePatterns: [
"/node_modules/(?!uuid|lib0)/.+\\.js$"
],
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"]
};

0 comments on commit 68958a0

Please sign in to comment.