diff --git a/tests/index.ts b/tests/index.ts index 7fa7394..10f8ec8 100644 --- a/tests/index.ts +++ b/tests/index.ts @@ -1,5 +1,5 @@ -import { test, is, ok, run } from "testra"; -import { getServer } from "../vendor/tangible/template-system/framework/env"; +import { test, is, ok, run } from 'testra' +import { getServer } from '../vendor/tangible/template-system/framework/env' async function ensurePlugin({ wpx }) { return wpx/* php */ ` @@ -22,7 +22,7 @@ if ( !get_option('site_init_done') ) { } return true; -`; +` } /** @@ -39,61 +39,22 @@ export default run(async () => { setSiteTemplate, resetSiteTemplate, } = await getServer({ - phpVersion: process.env.PHP_VERSION || "7.4", + phpVersion: process.env.PHP_VERSION || '7.4', mappings: process.env.TEST_ARCHIVE ? { - "wp-content/plugins/tangible-loops-and-logic": - "../publish/tangible-loops-and-logic", + 'wp-content/plugins/tangible-loops-and-logic': + '../publish/tangible-loops-and-logic', } : {}, reset: true, - }); + }) - let result: any; + let result: any test('Plugin - Activate', async () => { - let result = await ensurePlugin({ wpx }); - is(true, result, "activate plugin"); + let result = await ensurePlugin({ wpx }) + is(true, result, 'activate plugin') }) - // Framework - await import("../vendor/tangible/template-system/framework/tests/index.ts"); - - test("Template system - Basic", async () => { - // console.log(await wpx/* php */`return scandir(ABSPATH . 'wp-content/plugins');`) - - result = await wpx`return function_exists('tangible_template_system');`; - is(true, result, "tangible_template_system() exists"); - - result = await wpx`return function_exists('tangible_template');`; - is(true, result, "tangible_template() exists"); - - let template = `Hello, world.`; - result = await wpx`return tangible_template('${template}');`; - is(template, result, "tangible_template(string) runs"); - - /** - * Create a post and get it - * @see https://developer.wordpress.org/reference/functions/wp_insert_post/ - */ - - const postTitle = "Test 123"; - result = await wpx/* php */ ` -return wp_insert_post([ - 'post_type' => 'post', - 'post_status' => 'publish', - 'post_title' => '${postTitle}', - 'post_content' => '', - 'post_excerpt' => '', -]);`; - - is("number", typeof result, "create post returns ID"); - - template = ``; - result = await wpx`return tangible_template('${template}');`; - - is(postTitle, result, "get test post"); - }); - - // await import('./loop/index.ts') -}); + await import(`../vendor/tangible/template-system/tests/index.ts`) +})