Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Update tests to use lwc restricted imports #2794

Merged
merged 1 commit into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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