Skip to content

Commit

Permalink
test: update test to use lwc imports (#2794)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmdartus authored Apr 19, 2022
1 parent 3a47f2f commit 4be2a04
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 36 deletions.
12 changes: 8 additions & 4 deletions packages/integration-karma/test/act/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { createElement, LightningElement } from 'lwc';
import {
createElement,
LightningElement,
registerComponent,
registerTemplate,
registerDecorators,
} from 'lwc';

import HtmlTags from 'html/tags';
import UiSomething from 'ui/something';
import UiSomethingElse from 'ui/somethingElse';
Expand Down Expand Up @@ -29,9 +36,6 @@ import testStyleAttr from './act-components/test-style-attr';
// Tests that confirm that the runtime LWC engine-dom is compatible with the compiled templates
// from the ACTCompiler
describe('ACTCompiler', () => {
// These can't be imported from 'lwc'` because @lwc/rollup-plugin won't allow it
const { registerComponent, registerTemplate, registerDecorators } = LWC;

function createComponentFromTemplate(
template,
{ props = {}, propsToTrack = [], methods = {} } = {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// TODO [#1284]: Import this from the lwc module once we move validation from compiler to linter
const { isNodeFromTemplate } = LWC;

import { createElement } from 'lwc';
import { createElement, isNodeFromTemplate } from 'lwc';
import Test from 'x/test';

function testNonNodes(type, obj) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// TODO [#1284]: Import this from the lwc module once we move validation from compiler to linter
const { registerTemplate } = LWC;

import { createElement } from 'lwc';
import { createElement, registerTemplate } from 'lwc';
import { LightningElement } from 'lwc';

it('should accepts a function return the same value', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { createElement } from 'lwc';
import { createElement, registerTemplate } from 'lwc';

import DynamicTemplate, { template1, template2 } from 'x/dynamicTemplate';
import RenderThrow from 'x/renderThrow';

// TODO [#1284]: Import this from the lwc module once we move validation from compiler to linter
const { registerTemplate } = LWC;

function testInvalidTemplate(type, template) {
it(`throws an error if returns ${type}`, () => {
const elm = createElement('x-dynamic-template', { is: DynamicTemplate });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { createElement, LightningElement } from 'lwc';
import { createElement, LightningElement, registerTemplate, registerComponent } from 'lwc';
import Component from 'x/component';
import ComponentWithProp from 'x/componentWithProp';
import ComponentWithTemplateAndStylesheet from 'x/componentWithTemplateAndStylesheet';

// TODO [#1284]: Import this from the lwc module once we move validation from compiler to linter
const { registerTemplate, registerComponent } = LWC;

if (!process.env.COMPAT) {
describe('compiler version mismatch', () => {
describe('stamped with version number', () => {
Expand Down
4 changes: 1 addition & 3 deletions packages/integration-karma/test/services/hooks/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { createElement } from 'lwc';
import { createElement, register } from 'lwc';

import XHooks from 'x/hooks';

const { register } = LWC;

describe('Service hooks', () => {
let entries = [];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { createElement, setFeatureFlagForTest } from 'lwc';

// TODO [#1869]: getting the global API from global LWC in tests until it is allowed in compiler
const { swapComponent } = LWC;
import { createElement, setFeatureFlagForTest, swapComponent } from 'lwc';

import Container from 'base/container';
import A from 'base/a';
Expand Down
7 changes: 2 additions & 5 deletions packages/integration-karma/test/swapping/styles/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { createElement } from 'lwc';

// TODO [#1869]: getting the global API from global LWC in tests until it is allowed in compiler
const { swapStyle } = LWC;

import { createElement, swapStyle } from 'lwc';
import Simple from 'base/simple';

const { blockStyle, inlineStyle, noneStyle } = Simple;

describe('style swapping', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { createElement } from 'lwc';

// TODO [#1869]: getting the global API from global LWC in tests until it is allowed in compiler
const { swapTemplate } = LWC;
import { createElement, swapTemplate } from 'lwc';

import Simple from 'base/simple';
import Advanced from 'base/advanced';
Expand Down

0 comments on commit 4be2a04

Please sign in to comment.